Merge "metric: fix measures --stop argument"
This commit is contained in:
@@ -316,6 +316,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)
|
||||
|
||||
@@ -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',
|
||||
@@ -197,7 +197,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',
|
||||
@@ -215,7 +215,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',
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -118,8 +118,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
|
||||
|
||||
@@ -129,7 +129,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
|
||||
|
||||
@@ -176,8 +176,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 "
|
||||
@@ -198,7 +198,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
|
||||
|
||||
Reference in New Issue
Block a user