From 4f38595e4e173e3f615fd30dd35eff8a512b8e7c Mon Sep 17 00:00:00 2001 From: mergalievibragim Date: Tue, 18 Jul 2017 22:06:49 +0300 Subject: [PATCH] Modification of statistic_aggregation method In this patch feching resource_id by resource's original_id was added to statistic_aggregation method. Closes-Bug: #1707653 Change-Id: I70b9346146f810e2236ccdb31de4c3fedf200568 --- watcher/datasource/gnocchi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/watcher/datasource/gnocchi.py b/watcher/datasource/gnocchi.py index 539fa34dc..d47148154 100644 --- a/watcher/datasource/gnocchi.py +++ b/watcher/datasource/gnocchi.py @@ -24,6 +24,7 @@ from oslo_log import log from watcher.common import clients from watcher.common import exception +from watcher.common import utils as common_utils CONF = cfg.CONF LOG = log.getLogger(__name__) @@ -72,6 +73,17 @@ class GnocchiHelper(object): raise exception.InvalidParameter(parameter='stop_time', parameter_type=datetime) + if not common_utils.is_uuid_like(resource_id): + kwargs = dict(query={"=": {"original_resource_id": resource_id}}, + limit=1) + resources = self.query_retry( + f=self.gnocchi.resource.search, **kwargs) + + if not resources: + raise exception.ResourceNotFound(name=resource_id) + + resource_id = resources[0]['id'] + raw_kwargs = dict( metric=metric, start=start_time,