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
This commit is contained in:
Mehdi Abaakouk
2015-11-19 16:26:42 +01:00
parent 7be79a22f1
commit 52d518537d
3 changed files with 11 additions and 4 deletions

View File

@@ -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 = \

View File

@@ -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

View File

@@ -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