Skip to content

Commit defbb95

Browse files
author
Eoghan Glynn
committed
Ensure statistics aggregates are ordered with parameterized first
Fixes bug 1298528 Due to WSME re-ordering of query parameters, in the mixed case any parameterized aggregates must be specified in the URL first, prior to any unparameterized aggregates. Otherwise the aggregate parameter will be associated with the wrong aggregate function. Change-Id: Ib2c76d03a4fc91d13074a03caade2c776d2309b3
1 parent fcfffac commit defbb95

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

ceilometerclient/tests/v2/test_statistics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ def test_list_by_meter_name_with_groupby(self):
181181

182182
def test_list_by_meter_name_with_aggregates(self):
183183
aggregates = [
184+
{
185+
'func': 'count',
186+
},
184187
{
185188
'func': 'cardinality',
186189
'param': 'resource_id',
187190
},
188-
{
189-
'func': 'count',
190-
}
191191
]
192192
stats = list(self.mgr.list(meter_name='instance',
193193
aggregates=aggregates))

ceilometerclient/v2/statistics.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ class StatisticsManager(base.Manager):
2626
def _build_aggregates(self, aggregates):
2727
url_aggregates = []
2828
for aggregate in aggregates:
29-
url_aggregates.append(
30-
"aggregate.func=%(func)s" % aggregate
31-
)
3229
if 'param' in aggregate:
33-
url_aggregates.append(
30+
url_aggregates.insert(
31+
0,
3432
"aggregate.param=%(param)s" % aggregate
3533
)
34+
url_aggregates.insert(
35+
0,
36+
"aggregate.func=%(func)s" % aggregate
37+
)
38+
else:
39+
url_aggregates.append(
40+
"aggregate.func=%(func)s" % aggregate
41+
)
3642
return url_aggregates
3743

3844
def list(self, meter_name, q=None, period=None, groupby=[], aggregates=[]):

0 commit comments

Comments
 (0)