From 1ea9662cac8ce33fe7c14a98d41ea43eea8a5d96 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 23 Jul 2015 12:10:52 +0200 Subject: [PATCH] Move Gnocchi options out of the "alarms" group Which was actually a typo I think since all the rest of the options were in "alarm" and opts.py was declaring Gnocchi options in "alarm" too. Change-Id: Ic8d06ff31ad09e21b59ad224d46fc3dcd2da5320 --- aodh/api/controllers/v2/alarm_rules/gnocchi.py | 9 ++++----- aodh/evaluator/gnocchi.py | 4 ++-- aodh/opts.py | 4 ++-- aodh/tests/api/v2/test_alarm_scenarios.py | 5 ++--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/aodh/api/controllers/v2/alarm_rules/gnocchi.py b/aodh/api/controllers/v2/alarm_rules/gnocchi.py index e4aec7d4..55c749df 100644 --- a/aodh/api/controllers/v2/alarm_rules/gnocchi.py +++ b/aodh/api/controllers/v2/alarm_rules/gnocchi.py @@ -24,8 +24,7 @@ from aodh.api.controllers.v2 import utils as v2_utils from aodh import keystone_client -cfg.CONF.import_opt('gnocchi_url', 'aodh.evaluator.gnocchi', - group="alarms") +cfg.CONF.import_opt('gnocchi_url', 'aodh.evaluator.gnocchi') class GnocchiUnavailable(Exception): @@ -65,7 +64,7 @@ class AlarmGnocchiThresholdRule(base.AlarmRule): @staticmethod def _get_aggregation_methods(): ks_client = keystone_client.get_client() - gnocchi_url = cfg.CONF.alarms.gnocchi_url + gnocchi_url = cfg.CONF.gnocchi_url headers = {'Content-Type': "application/json", 'X-Auth-Token': ks_client.auth_token} try: @@ -105,7 +104,7 @@ class MetricOfResourceRule(AlarmGnocchiThresholdRule): rule = alarm.gnocchi_resources_threshold_rule ks_client = keystone_client.get_client() - gnocchi_url = cfg.CONF.alarms.gnocchi_url + gnocchi_url = cfg.CONF.gnocchi_url headers = {'Content-Type': "application/json", 'X-Auth-Token': ks_client.auth_token} try: @@ -165,7 +164,7 @@ class AggregationMetricByResourcesLookupRule(AlarmGnocchiThresholdRule): ks_client = keystone_client.get_client() request = { 'url': "%s/v1/aggregation/resource/%s/metric/%s" % ( - cfg.CONF.alarms.gnocchi_url, + cfg.CONF.gnocchi_url, rule.resource_type, rule.metric), 'headers': {'Content-Type': "application/json", diff --git a/aodh/evaluator/gnocchi.py b/aodh/evaluator/gnocchi.py index 5bd27a34..4931f13d 100644 --- a/aodh/evaluator/gnocchi.py +++ b/aodh/evaluator/gnocchi.py @@ -30,7 +30,7 @@ OPTS = [ help='URL to Gnocchi.'), ] -cfg.CONF.register_opts(OPTS, group="alarms") +cfg.CONF.register_opts(OPTS) cfg.CONF.import_opt('http_timeout', 'aodh.service') @@ -38,7 +38,7 @@ class GnocchiThresholdEvaluator(threshold.ThresholdEvaluator): def __init__(self, notifier): super(threshold.ThresholdEvaluator, self).__init__(notifier) - self.gnocchi_url = cfg.CONF.alarms.gnocchi_url + self.gnocchi_url = cfg.CONF.gnocchi_url self._ks_client = None @property diff --git a/aodh/opts.py b/aodh/opts.py index c1f0db8a..0caf3bfe 100644 --- a/aodh/opts.py +++ b/aodh/opts.py @@ -32,8 +32,8 @@ def list_opts(): aodh.notifier.rest.OPTS, aodh.service.OPTS, aodh.rpc.OPTS, - aodh.storage.OLD_OPTS,)), - ('alarm', aodh.api.controllers.v2.alarms.ALARM_API_OPTS), + aodh.storage.OLD_OPTS, + aodh.api.controllers.v2.alarms.ALARM_API_OPTS)), ('api', itertools.chain(aodh.api.OPTS, aodh.api.app.API_OPTS,)), diff --git a/aodh/tests/api/v2/test_alarm_scenarios.py b/aodh/tests/api/v2/test_alarm_scenarios.py index c211687f..f287ee23 100644 --- a/aodh/tests/api/v2/test_alarm_scenarios.py +++ b/aodh/tests/api/v2/test_alarm_scenarios.py @@ -2365,7 +2365,7 @@ class TestAlarms(TestAlarmsBase): ) as gnocchi_get: self.post_json('/alarms', params=json, headers=self.auth_headers) - gnocchi_url = self.CONF.alarms.gnocchi_url + gnocchi_url = self.CONF.gnocchi_url capabilities_url = urlparse.urljoin(gnocchi_url, '/v1/capabilities') resource_url = urlparse.urljoin( @@ -2418,8 +2418,7 @@ class TestAlarms(TestAlarmsBase): @mock.patch('aodh.keystone_client.get_client') def test_post_gnocchi_aggregation_alarm_project_constraint(self, __): - self.CONF.set_override('gnocchi_url', 'http://localhost:8041', - group='alarms') + self.CONF.set_override('gnocchi_url', 'http://localhost:8041') json = { 'enabled': False, 'name': 'project_constraint',