From 6daa3168291bd00624265fae91c03237026f2e80 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 15 Oct 2015 18:11:55 +0200 Subject: [PATCH] metric: fix measures --stop argument The API parameter is actually `stop', not `end'. Change-Id: I9807eddb43a2b693ef74488e4666975e9fedb628 --- gnocchiclient/benchmark.py | 2 +- gnocchiclient/tests/functional/test_metric.py | 8 +++--- gnocchiclient/v1/metric.py | 28 +++++++++---------- gnocchiclient/v1/metric_cli.py | 12 ++++---- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/gnocchiclient/benchmark.py b/gnocchiclient/benchmark.py index 1f95830..b2adad8 100644 --- a/gnocchiclient/benchmark.py +++ b/gnocchiclient/benchmark.py @@ -308,6 +308,6 @@ class CliBenchmarkMeasuresShow(CliBenchmarkBase, resource_id=parsed_args.resource_id, aggregation=parsed_args.aggregation, start=parsed_args.start, - end=parsed_args.end) + stop=parsed_args.stop) result, runtime, stats = pool.wait_job("show", futures) return self.dict2columns(stats) diff --git a/gnocchiclient/tests/functional/test_metric.py b/gnocchiclient/tests/functional/test_metric.py index 7ac555d..ed9ea5d 100644 --- a/gnocchiclient/tests/functional/test_metric.py +++ b/gnocchiclient/tests/functional/test_metric.py @@ -97,7 +97,7 @@ class MetricClientTest(base.ClientTestBase): 5, 'measures', params=("show %s " "--aggregation mean " "--start 2015-03-06T14:32:00 " - "--end 2015-03-06T14:36:00" + "--stop 2015-03-06T14:36:00" ) % metric["id"]) measures = self.parser.listing(result) self.assertEqual([{'granularity': '1.0', @@ -113,7 +113,7 @@ class MetricClientTest(base.ClientTestBase): "--metric %s " "--aggregation mean " "--start 2015-03-06T14:32:00 " - "--end 2015-03-06T14:36:00" + "--stop 2015-03-06T14:36:00" ) % metric["id"]) measures = self.parser.listing(result) self.assertEqual([{'granularity': '1.0', @@ -188,7 +188,7 @@ class MetricClientTest(base.ClientTestBase): 5, 'measures', params=("show metric-name -r metric-res " "--aggregation mean " "--start 2015-03-06T14:32:00 " - "--end 2015-03-06T14:36:00")) + "--stop 2015-03-06T14:36:00")) measures = self.parser.listing(result) self.assertEqual([{'granularity': '1.0', @@ -206,7 +206,7 @@ class MetricClientTest(base.ClientTestBase): "--aggregation mean " "--needed-overlap 0 " "--start 2015-03-06T14:32:00 " - "--end 2015-03-06T14:36:00")) + "--stop 2015-03-06T14:36:00")) measures = self.parser.listing(result) self.assertEqual([{'granularity': '1.0', 'timestamp': '2015-03-06T14:33:57+00:00', diff --git a/gnocchiclient/v1/metric.py b/gnocchiclient/v1/metric.py index 08d925c..881ea4f 100644 --- a/gnocchiclient/v1/metric.py +++ b/gnocchiclient/v1/metric.py @@ -122,16 +122,16 @@ class MetricManager(base.Manager): url, headers={'Content-Type': "application/json"}, data=jsonutils.dumps(measures)) - def get_measures(self, metric, start=None, end=None, aggregation=None, + def get_measures(self, metric, start=None, stop=None, aggregation=None, resource_id=None, **kwargs): """Get measurements of a metric :param metric: ID or Name of the metric :type metric: str - :param start: begin of the period + :param start: beginning of the period :type start: timestamp - :param end: end of the period - :type end: timestamp + :param stop: end of the period + :type stop: timestamp :param aggregation: aggregation to retrieve :type aggregation: str :param resource_id: ID of the resource (required @@ -144,10 +144,10 @@ class MetricManager(base.Manager): if isinstance(start, datetime.datetime): start = start.isoformat() - if isinstance(end, datetime.datetime): - end = end.isoformat() + if isinstance(stop, datetime.datetime): + stop = stop.isoformat() - params = dict(start=start, end=end, aggregation=aggregation) + params = dict(start=start, stop=stop, aggregation=aggregation) params.update(kwargs) if resource_id is None: self._ensure_metric_is_uuid(metric) @@ -157,7 +157,7 @@ class MetricManager(base.Manager): return self._get(url, params=params).json() def aggregation(self, metrics, query=None, - start=None, end=None, aggregation=None, + start=None, stop=None, aggregation=None, needed_overlap=None): """Get measurements of a aggregated metrics @@ -165,10 +165,10 @@ class MetricManager(base.Manager): :type metric: list or str :param query: The query dictionary :type query: dict - :param start: begin of the period + :param start: beginning of the period :type start: timestamp - :param end: end of the period - :type end: timestamp + :param stop: end of the period + :type stop: timestamp :param aggregation: aggregation to retrieve :type aggregation: str @@ -179,10 +179,10 @@ class MetricManager(base.Manager): if isinstance(start, datetime.datetime): start = start.isoformat() - if isinstance(end, datetime.datetime): - end = end.isoformat() + if isinstance(stop, datetime.datetime): + stop = stop.isoformat() - params = dict(start=start, end=end, aggregation=aggregation, + params = dict(start=start, stop=stop, aggregation=aggregation, needed_overlap=needed_overlap) if query is None: for metric in metrics: diff --git a/gnocchiclient/v1/metric_cli.py b/gnocchiclient/v1/metric_cli.py index 73154d5..46b642d 100644 --- a/gnocchiclient/v1/metric_cli.py +++ b/gnocchiclient/v1/metric_cli.py @@ -109,8 +109,8 @@ class CliMeasuresShow(CliMetricWithResourceID, lister.Lister): parser.add_argument("--aggregation", help="aggregation to retrieve") parser.add_argument("--start", - help="start of the period") - parser.add_argument("--end", + help="beginning of the period") + parser.add_argument("--stop", help="end of the period") return parser @@ -120,7 +120,7 @@ class CliMeasuresShow(CliMetricWithResourceID, lister.Lister): resource_id=parsed_args.resource_id, aggregation=parsed_args.aggregation, start=parsed_args.start, - end=parsed_args.end, + stop=parsed_args.stop, ) return self.COLS, measures @@ -163,8 +163,8 @@ class CliMeasuresAggregation(lister.Lister): parser.add_argument("--aggregation", help="aggregation to retrieve") parser.add_argument("--start", - help="start of the period") - parser.add_argument("--end", + help="beginning of the period") + parser.add_argument("--stop", help="end of the period") parser.add_argument("--needed-overlap", type=float, help=("percent of datapoints in each " @@ -185,7 +185,7 @@ class CliMeasuresAggregation(lister.Lister): query=query, aggregation=parsed_args.aggregation, start=parsed_args.start, - end=parsed_args.end, + stop=parsed_args.stop, needed_overlap=parsed_args.needed_overlap, ) return self.COLS, measures