improve statistic_aggregation

improve statistic_aggregation

Change-Id: Ic1fb19780fa4a39c5eb74e5ed30db0e4c06d0e09
This commit is contained in:
licanwei
2016-12-12 17:10:38 +08:00
parent c08666b2fa
commit 7a72371df8

View File

@@ -134,19 +134,16 @@ class CeilometerHelper(object):
aggregate='avg'):
"""Representing a statistic aggregate by operators
:param resource_id: id
:param meter_name: meter names of which we want the statistics
:param period: `period`: In seconds. If no period is given, only one
aggregate statistic is returned. If given, a faceted
result will be returned, divided into given periods.
Periods with no data are ignored.
:param aggregate:
:return:
:param resource_id: id of resource to list statistics for.
:param meter_name: Name of meter to list statistics for.
:param period: Period in seconds over which to group samples.
:param aggregate: Available aggregates are: count, cardinality,
min, max, sum, stddev, avg. Defaults to avg.
:return: Return the latest statistical data, None if no data.
"""
end_time = datetime.datetime.utcnow()
start_time = (datetime.datetime.utcnow() -
datetime.timedelta(seconds=int(period)))
start_time = end_time - datetime.timedelta(seconds=int(period))
query = self.build_query(
resource_id=resource_id, start_time=start_time, end_time=end_time)
statistic = self.query_retry(f=self.ceilometer.statistics.list,