From d6639d849f69582bac0fdc337f8955ed92d38101 Mon Sep 17 00:00:00 2001 From: Ala Rezmerita Date: Wed, 18 Dec 2013 11:50:20 +0100 Subject: [PATCH] Change endpoint_type parameter Replace endpoint_type parameter by os_endpoint_type parameter expected by ceilometerclient. Change-Id: I676247b289f8efa7c047a34dc9333361d094b024 Closes-Bug: #1257232 --- ceilometer/alarm/evaluator/__init__.py | 2 +- ceilometer/alarm/service.py | 2 +- .../tests/alarm/evaluator/test_threshold.py | 22 +++++++++++++++++++ .../tests/alarm/test_singleton_alarm_svc.py | 21 ++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ceilometer/alarm/evaluator/__init__.py b/ceilometer/alarm/evaluator/__init__.py index 0d2b4922f..e54166498 100644 --- a/ceilometer/alarm/evaluator/__init__.py +++ b/ceilometer/alarm/evaluator/__init__.py @@ -53,7 +53,7 @@ class Evaluator(object): os_password=auth_config.os_password, os_username=auth_config.os_username, cacert=auth_config.os_cacert, - endpoint_type=auth_config.os_endpoint_type, + os_endpoint_type=auth_config.os_endpoint_type, ) self.api_client = ceiloclient.get_client(2, **creds) return self.api_client diff --git a/ceilometer/alarm/service.py b/ceilometer/alarm/service.py index dea227812..a2f87bc47 100644 --- a/ceilometer/alarm/service.py +++ b/ceilometer/alarm/service.py @@ -85,7 +85,7 @@ class AlarmService(object): os_password=auth_config.os_password, os_username=auth_config.os_username, cacert=auth_config.os_cacert, - endpoint_type=auth_config.os_endpoint_type, + os_endpoint_type=auth_config.os_endpoint_type, ) self.api_client = ceiloclient.get_client(2, **creds) return self.api_client diff --git a/ceilometer/tests/alarm/evaluator/test_threshold.py b/ceilometer/tests/alarm/evaluator/test_threshold.py index 15881d540..f9fb7efd3 100644 --- a/ceilometer/tests/alarm/evaluator/test_threshold.py +++ b/ceilometer/tests/alarm/evaluator/test_threshold.py @@ -27,6 +27,7 @@ from ceilometer.storage import models from ceilometer.tests.alarm.evaluator import base from ceilometerclient import exc from ceilometerclient.v2 import statistics +from oslo.config import cfg class TestEvaluate(base.TestEvaluatorBase): @@ -289,3 +290,24 @@ class TestEvaluate(base.TestEvaluatorBase): 'op': 'ge', 'value': '2012-07-02T10:39:00'}, ]) + + def test_threshold_endpoint_types(self): + endpoint_types = ["internalURL", "publicURL"] + for endpoint_type in endpoint_types: + cfg.CONF.set_override('os_endpoint_type', + endpoint_type, + group='service_credentials') + with mock.patch('ceilometerclient.client.get_client') as client: + self.evaluator.api_client = None + self._evaluate_all_alarms() + conf = cfg.CONF.service_credentials + expected = [mock.call(2, + os_auth_url=conf.os_auth_url, + os_region_name=conf.os_region_name, + os_tenant_name=conf.os_tenant_name, + os_password=conf.os_password, + os_username=conf.os_username, + cacert=conf.os_cacert, + os_endpoint_type=conf.os_endpoint_type)] + actual = client.call_args_list + self.assertEqual(actual, expected) diff --git a/ceilometer/tests/alarm/test_singleton_alarm_svc.py b/ceilometer/tests/alarm/test_singleton_alarm_svc.py index 20e78dc2b..cabf90ec7 100644 --- a/ceilometer/tests/alarm/test_singleton_alarm_svc.py +++ b/ceilometer/tests/alarm/test_singleton_alarm_svc.py @@ -83,3 +83,24 @@ class TestSingletonAlarmService(test.BaseTestCase): self.singleton.start() self.singleton._evaluate_assigned_alarms() self.threshold_eval.evaluate.assert_called_once_with(alarms[1]) + + def test_singleton_endpoint_types(self): + endpoint_types = ["internalURL", "publicURL"] + for endpoint_type in endpoint_types: + cfg.CONF.set_override('os_endpoint_type', + endpoint_type, + group='service_credentials') + with mock.patch('ceilometerclient.client.get_client') as client: + self.singleton.api_client = None + self.singleton._evaluate_assigned_alarms() + conf = cfg.CONF.service_credentials + expected = [mock.call(2, + os_auth_url=conf.os_auth_url, + os_region_name=conf.os_region_name, + os_tenant_name=conf.os_tenant_name, + os_password=conf.os_password, + os_username=conf.os_username, + cacert=conf.os_cacert, + os_endpoint_type=conf.os_endpoint_type)] + actual = client.call_args_list + self.assertEqual(actual, expected)