diff options
| author | Mehdi Abaakouk <sileht@redhat.com> | 2015-11-19 16:26:42 +0100 |
|---|---|---|
| committer | Mehdi Abaakouk <sileht@redhat.com> | 2015-11-20 07:34:20 +0100 |
| commit | 52d518537df335432fc487ccd5c81a500049cd28 (patch) | |
| tree | f1cb3eff92882e03e2f107cc62fd05dff7a57ead | |
| parent | 7be79a22f151c35b86e747d3eb9af78f0fbea06b (diff) | |
| download | python-ceilometerclient-52d518537df335432fc487ccd5c81a500049cd28.tar.gz | |
Catch exception raised by keystoneauth1
We must support session object that comes from keystoneauth1 and
keystoneclient.
This change adds code path for keystoneauth1 when it misses.
Change-Id: I1164a0a0745605b6bc4fd1fc8fb2813c7e40fb9b
| -rw-r--r-- | ceilometerclient/tests/unit/test_client.py | 3 | ||||
| -rw-r--r-- | ceilometerclient/v2/client.py | 11 | ||||
| -rw-r--r-- | requirements.txt | 1 |
3 files changed, 11 insertions, 4 deletions
diff --git a/ceilometerclient/tests/unit/test_client.py b/ceilometerclient/tests/unit/test_client.py index 3021699..99fa212 100644 --- a/ceilometerclient/tests/unit/test_client.py +++ b/ceilometerclient/tests/unit/test_client.py @@ -12,6 +12,7 @@ import types +from keystoneauth1 import exceptions as ka_exc from keystoneclient.auth.identity import v2 as v2_auth from keystoneclient.auth.identity import v3 as v3_auth from keystoneclient import exceptions as ks_exc @@ -46,7 +47,7 @@ class ClientTest(utils.BaseTestCase): if not env.get('auth_plugin'): with mock.patch('ceilometerclient.client.AuthPlugin.' 'redirect_to_aodh_endpoint') as redirect_aodh: - redirect_aodh.side_effect = ks_exc.EndpointNotFound + redirect_aodh.side_effect = ka_exc.EndpointNotFound return client.get_client(api_version, **env) else: env['auth_plugin'].redirect_to_aodh_endpoint.side_effect = \ diff --git a/ceilometerclient/v2/client.py b/ceilometerclient/v2/client.py index b3272a1..0014636 100644 --- a/ceilometerclient/v2/client.py +++ b/ceilometerclient/v2/client.py @@ -28,7 +28,8 @@ from ceilometerclient.v2 import samples from ceilometerclient.v2 import statistics from ceilometerclient.v2 import trait_descriptions from ceilometerclient.v2 import traits -from keystoneclient import exceptions +from keystoneauth1 import exceptions as ka_exc +from keystoneclient import exceptions as kc_exc class Client(object): @@ -94,7 +95,9 @@ class Client(object): kwargs["service_type"] = "alarming" try: return ceiloclient._construct_http_client(**kwargs), True - except exceptions.EndpointNotFound: + except ka_exc.EndpointNotFound: + return self.http_client, False + except kc_exc.EndpointNotFound: return self.http_client, False else: if aodh_endpoint: @@ -111,6 +114,8 @@ class Client(object): # the endpoint of alarm auth_plugin. kwargs["auth_plugin"].redirect_to_aodh_endpoint( kwargs.get('timeout')) - except exceptions.EndpointNotFound: + except ka_exc.EndpointNotFound: + return self.http_client, False + except kc_exc.EndpointNotFound: return self.http_client, False return ceiloclient._construct_http_client(**kwargs), True diff --git a/requirements.txt b/requirements.txt index 2949542..4ddf8b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ pbr>=1.6 argparse iso8601>=0.1.9 +keystoneauth1>=1.0.0 oslo.i18n>=1.5.0 # Apache-2.0 oslo.serialization>=1.10.0 # Apache-2.0 oslo.utils!=2.6.0,>=2.4.0 # Apache-2.0 |
