Merge "Add granularity argument to measures show"

This commit is contained in:
Jenkins 2016-01-22 18:20:40 +00:00 committed by Gerrit Code Review
commit b32b59d5d5
3 changed files with 9 additions and 2 deletions

View File

@ -96,6 +96,7 @@ class MetricClientTest(base.ClientTestBase):
result = self.retry_gnocchi(
5, 'measures', params=("show %s "
"--aggregation mean "
"--granularity 1 "
"--start 2015-03-06T14:32:00 "
"--stop 2015-03-06T14:36:00"
) % metric["id"])

View File

@ -123,7 +123,7 @@ class MetricManager(base.Manager):
data=jsonutils.dumps(measures))
def get_measures(self, metric, start=None, stop=None, aggregation=None,
resource_id=None, **kwargs):
granularity=None, resource_id=None, **kwargs):
"""Get measurements of a metric
:param metric: ID or Name of the metric
@ -134,6 +134,8 @@ class MetricManager(base.Manager):
:type stop: timestamp
:param aggregation: aggregation to retrieve
:type aggregation: str
:param granularity: granularity to retrieve (in seconds)
:type granularity: int
:param resource_id: ID of the resource (required
to get a metric by name)
:type resource_id: str
@ -147,7 +149,8 @@ class MetricManager(base.Manager):
if isinstance(stop, datetime.datetime):
stop = stop.isoformat()
params = dict(start=start, stop=stop, aggregation=aggregation)
params = dict(start=start, stop=stop, aggregation=aggregation,
granularity=granularity)
params.update(kwargs)
if resource_id is None:
self._ensure_metric_is_uuid(metric)

View File

@ -121,6 +121,8 @@ class CliMeasuresShow(CliMetricWithResourceID, lister.Lister):
help="beginning of the period")
parser.add_argument("--stop",
help="end of the period")
parser.add_argument("--granularity",
help="granularity to retrieve (in seconds)")
return parser
def take_action(self, parsed_args):
@ -130,6 +132,7 @@ class CliMeasuresShow(CliMetricWithResourceID, lister.Lister):
aggregation=parsed_args.aggregation,
start=parsed_args.start,
stop=parsed_args.stop,
granularity=parsed_args.granularity,
)
return self.COLS, measures