From d6c5d22e3b0db92b685d1cf0efeb578b9d168f54 Mon Sep 17 00:00:00 2001 From: Roman Vasilets Date: Tue, 31 May 2016 20:40:54 +0300 Subject: [PATCH] Fix ceilometer bug with required contexts Add ceilometer required context where its needed. Change-Id: I7581a55535e6a27451c73ee177ead8f660a12321 Closes-bug: #1557642 --- .../openstack/scenarios/ceilometer/meters.py | 2 ++ .../scenarios/ceilometer/resources.py | 2 ++ .../openstack/scenarios/ceilometer/samples.py | 2 ++ .../openstack/scenarios/ceilometer/stats.py | 1 + .../openstack/scenarios/ceilometer/utils.py | 20 ++++++++----------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/rally/plugins/openstack/scenarios/ceilometer/meters.py b/rally/plugins/openstack/scenarios/ceilometer/meters.py index 62ded029..6510f716 100644 --- a/rally/plugins/openstack/scenarios/ceilometer/meters.py +++ b/rally/plugins/openstack/scenarios/ceilometer/meters.py @@ -22,6 +22,7 @@ class CeilometerMeters(ceiloutils.CeilometerScenario): """Benchmark scenarios for Ceilometer Meters API.""" @validation.required_services(consts.Service.CEILOMETER) + @validation.required_contexts("ceilometer") @validation.required_openstack(users=True) @scenario.configure() def list_meters(self, metadata_query=None, limit=None): @@ -40,6 +41,7 @@ class CeilometerMeters(ceiloutils.CeilometerScenario): self.list_matched_meters(limit=limit) @validation.required_services(consts.Service.CEILOMETER) + @validation.required_contexts("ceilometer") @validation.required_openstack(users=True) @scenario.configure() def list_matched_meters(self, filter_by_user_id=False, diff --git a/rally/plugins/openstack/scenarios/ceilometer/resources.py b/rally/plugins/openstack/scenarios/ceilometer/resources.py index 80e44ed3..1ab15291 100644 --- a/rally/plugins/openstack/scenarios/ceilometer/resources.py +++ b/rally/plugins/openstack/scenarios/ceilometer/resources.py @@ -23,6 +23,7 @@ class CeilometerResource(ceiloutils.CeilometerScenario): """Benchmark scenarios for Ceilometer Resource API.""" @validation.required_services(consts.Service.CEILOMETER) + @validation.required_contexts("ceilometer") @validation.required_openstack(users=True) @scenario.configure() def list_resources(self, metadata_query=None, @@ -71,6 +72,7 @@ class CeilometerResource(ceiloutils.CeilometerScenario): self._get_resource(res_id) @validation.required_services(consts.Service.CEILOMETER) + @validation.required_contexts("ceilometer") @validation.required_openstack(users=True) @scenario.configure() def list_matched_resources(self, filter_by_user_id=False, diff --git a/rally/plugins/openstack/scenarios/ceilometer/samples.py b/rally/plugins/openstack/scenarios/ceilometer/samples.py index 31232892..8b8f7f91 100644 --- a/rally/plugins/openstack/scenarios/ceilometer/samples.py +++ b/rally/plugins/openstack/scenarios/ceilometer/samples.py @@ -22,6 +22,7 @@ class CeilometerSamples(ceiloutils.CeilometerScenario): """Benchmark scenarios for Ceilometer Samples API.""" @validation.required_services(consts.Service.CEILOMETER) + @validation.required_contexts("ceilometer") @validation.required_openstack(users=True) @scenario.configure() def list_matched_samples(self, filter_by_resource_id=False, @@ -43,6 +44,7 @@ class CeilometerSamples(ceiloutils.CeilometerScenario): self._list_samples(query, limit) @validation.required_services(consts.Service.CEILOMETER) + @validation.required_contexts("ceilometer") @validation.required_openstack(users=True) @scenario.configure() def list_samples(self, metadata_query=None, limit=None): diff --git a/rally/plugins/openstack/scenarios/ceilometer/stats.py b/rally/plugins/openstack/scenarios/ceilometer/stats.py index d18686fa..83dbef31 100644 --- a/rally/plugins/openstack/scenarios/ceilometer/stats.py +++ b/rally/plugins/openstack/scenarios/ceilometer/stats.py @@ -39,6 +39,7 @@ class CeilometerStats(utils.CeilometerScenario): self._get_stats(meter.counter_name) @validation.required_services(consts.Service.CEILOMETER) + @validation.required_contexts("ceilometer") @validation.required_openstack(users=True) @scenario.configure() def get_stats(self, meter_name, filter_by_user_id=False, diff --git a/rally/plugins/openstack/scenarios/ceilometer/utils.py b/rally/plugins/openstack/scenarios/ceilometer/utils.py index 362f5122..6f4f5876 100644 --- a/rally/plugins/openstack/scenarios/ceilometer/utils.py +++ b/rally/plugins/openstack/scenarios/ceilometer/utils.py @@ -112,18 +112,14 @@ class CeilometerScenario(scenario.OpenStackScenario): metadata_query = metadata_query or {} if filter_by_user_id: - user_id = self.context["user"]["id"] - query.append(self._make_query_item("user_id", "eq", user_id)) - - if filter_by_project_id or filter_by_resource_id: - project_id = self.context["tenant"]["id"] - if filter_by_project_id: - query.append(self._make_query_item("project_id", "eq", - project_id)) - if filter_by_resource_id: - resource_id = self.context["tenant"]["resources"][0] - query.append(self._make_query_item("resource_id", "eq", - resource_id)) + query.append(self._make_query_item("user_id", "eq", + self.context["user"]["id"])) + if filter_by_project_id: + query.append(self._make_query_item( + "project_id", "eq", self.context["tenant"]["id"])) + if filter_by_resource_id: + query.append(self._make_query_item( + "resource_id", "eq", self.context["tenant"]["resources"][0])) for key, value in metadata_query.items(): query.append(self._make_query_item("metadata.%s" % key,