summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ceilometerclient/tests/unit/test_client.py9
-rw-r--r--ceilometerclient/v2/client.py23
2 files changed, 26 insertions, 6 deletions
diff --git a/ceilometerclient/tests/unit/test_client.py b/ceilometerclient/tests/unit/test_client.py
index b4e1f65..085e259 100644
--- a/ceilometerclient/tests/unit/test_client.py
+++ b/ceilometerclient/tests/unit/test_client.py
@@ -371,6 +371,15 @@ class ClientAuthTest(utils.BaseTestCase):
session_instance_mock.get_endpoint.assert_called_with(
region_name=None, interface='publicURL', service_type='alarming')
+ def test_get_aodh_endpoint_without_auth_url(self):
+ env = FAKE_ENV.copy()
+ env.pop('auth_plugin', None)
+ env.pop('endpoint', None)
+ env.pop('auth_url', None)
+ client = self.create_client(env, endpoint='fake_endpoint')
+ self.assertEqual(client.alarm_auth_plugin.opts,
+ client.auth_plugin.opts)
+
@mock.patch('ceilometerclient.client._get_keystone_session')
@mock.patch('ceilometerclient.client._get_token_auth_ks_session')
def test_get_different_endpoint_type(self, token_session, session):
diff --git a/ceilometerclient/v2/client.py b/ceilometerclient/v2/client.py
index 8813860..0ba76e5 100644
--- a/ceilometerclient/v2/client.py
+++ b/ceilometerclient/v2/client.py
@@ -87,14 +87,25 @@ class Client(object):
def _get_alarm_client(self, **kwargs):
"""Get client for alarm manager that redirect to aodh."""
+
self.alarm_auth_plugin = copy.deepcopy(self.auth_plugin)
- try:
- # NOTE(liusheng): Getting the aodh's endpoint to rewrite
- # the endpoint of alarm auth_plugin.
- self.alarm_auth_plugin.redirect_to_aodh_endpoint(
- kwargs.get('timeout'))
- except exceptions.EndpointNotFound:
+ aodh_endpoint = kwargs.get('aodh_endpoint')
+ if aodh_endpoint:
+ self.alarm_auth_plugin.opts['endpoint'] = aodh_endpoint
+ elif not kwargs.get('auth_url'):
+ # Users may just provided ceilometer endpoint and token, and no
+ # auth_url, in this case, we need 'aodh_endpoint' also provided,
+ # otherwise we cannot get aodh endpoint from keystone, and assume
+ # aodh is unavailable.
return self.http_client, False
+ else:
+ try:
+ # NOTE(liusheng): Getting the aodh's endpoint to rewrite
+ # the endpoint of alarm auth_plugin.
+ self.alarm_auth_plugin.redirect_to_aodh_endpoint(
+ kwargs.get('timeout'))
+ except exceptions.EndpointNotFound:
+ return self.http_client, False
alarm_client = client.HTTPClient(
auth_plugin=self.alarm_auth_plugin,
region_name=kwargs.get('region_name'),