diff options
author | Jamie Lennox <jamielennox@gmail.com> | 2016-08-24 18:33:54 +1000 |
---|---|---|
committer | Jamie Lennox <jamielennox@gmail.com> | 2016-08-24 18:52:36 +1000 |
commit | 5b91fedd650613f7ba480039fca7df83c1ff6bed (patch) | |
tree | 08459126ec74a7759b608f22a972d17d2c6089d2 /keystoneclient/utils.py | |
parent | f557170404ec2b7f5c562e55ad212b6e444655c8 (diff) | |
download | python-keystoneclient-5b91fedd650613f7ba480039fca7df83c1ff6bed.tar.gz |
Use exceptions from Keystoneauth
As keystoneclient and other services rely more on keystoneauth we should
assume that keystoneauth is our base auth library, not keystoneclient
and start to default to the objects provided from there. This will make
it easier to remove these objects when the time comes.
For the session independant parts of keystoneclient we should use the
exception names as provided by keystoneauth instead of the aliases in
keystoneclient.
Change-Id: Ic513046f8398a76c244e145d6cc3117cdf6bb4cd
Diffstat (limited to 'keystoneclient/utils.py')
-rw-r--r-- | keystoneclient/utils.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/keystoneclient/utils.py b/keystoneclient/utils.py index 7030f51..4685111 100644 --- a/keystoneclient/utils.py +++ b/keystoneclient/utils.py @@ -15,13 +15,14 @@ import hashlib import logging import sys +from keystoneauth1 import exceptions as ksa_exceptions from oslo_utils import timeutils # NOTE(stevemar): do not remove positional. We need this to stay for a while # since versions of auth_token require it here. from positional import positional # noqa import six -from keystoneclient import exceptions +from keystoneclient import exceptions as ksc_exceptions logger = logging.getLogger(__name__) @@ -32,8 +33,8 @@ def find_resource(manager, name_or_id): # first try the entity as a string try: return manager.get(name_or_id) - except (exceptions.NotFound): # nosec(cjschaef): try to find 'name_or_id' - # as a six.binary_type instead + except (ksa_exceptions.NotFound): # nosec(cjschaef): try to find + # 'name_or_id' as a six.binary_type instead pass # finally try to find entity by name @@ -41,15 +42,15 @@ def find_resource(manager, name_or_id): if isinstance(name_or_id, six.binary_type): name_or_id = name_or_id.decode('utf-8', 'strict') return manager.find(name=name_or_id) - except exceptions.NotFound: + except ksa_exceptions.NotFound: msg = ("No %s with a name or ID of '%s' exists." % (manager.resource_class.__name__.lower(), name_or_id)) - raise exceptions.CommandError(msg) - except exceptions.NoUniqueMatch: + raise ksc_exceptions.CommandError(msg) + except ksc_exceptions.NoUniqueMatch: msg = ("Multiple %s matches found for '%s', use an ID to be more" " specific." % (manager.resource_class.__name__.lower(), name_or_id)) - raise exceptions.CommandError(msg) + raise ksc_exceptions.CommandError(msg) def unauthenticated(f): |