From 5b91fedd650613f7ba480039fca7df83c1ff6bed Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Wed, 24 Aug 2016 18:33:54 +1000 Subject: 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 --- keystoneclient/base.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'keystoneclient/base.py') diff --git a/keystoneclient/base.py b/keystoneclient/base.py index fc16298..7067fb8 100644 --- a/keystoneclient/base.py +++ b/keystoneclient/base.py @@ -22,12 +22,13 @@ import copy import functools import warnings +from keystoneauth1 import exceptions as ksa_exceptions from keystoneauth1 import plugin from oslo_utils import strutils import six from six.moves import urllib -from keystoneclient import exceptions +from keystoneclient import exceptions as ksc_exceptions from keystoneclient.i18n import _ @@ -226,8 +227,8 @@ class Manager(object): resp, body = methods[method](url, body=body, **kwargs) except KeyError: - raise exceptions.ClientException(_("Invalid update method: %s") - % method) + raise ksc_exceptions.ClientException(_("Invalid update method: %s") + % method) # PUT requests may not return a body if body: return self.resource_class(self, body[response_key]) @@ -253,9 +254,9 @@ class ManagerWithFind(Manager): if num == 0: msg = _("No %(name)s matching %(kwargs)s.") % { 'name': self.resource_class.__name__, 'kwargs': kwargs} - raise exceptions.NotFound(404, msg) + raise ksa_exceptions.NotFound(404, msg) elif num > 1: - raise exceptions.NoUniqueMatch + raise ksc_exceptions.NoUniqueMatch else: return rl[0] @@ -384,7 +385,7 @@ class CrudManager(Manager): return self._list( url_query, self.collection_key) - except exceptions.EmptyCatalog: + except ksa_exceptions.EmptyCatalog: if fallback_to_auth: return self._list( url_query, @@ -431,9 +432,9 @@ class CrudManager(Manager): if num == 0: msg = _("No %(name)s matching %(kwargs)s.") % { 'name': self.resource_class.__name__, 'kwargs': kwargs} - raise exceptions.NotFound(404, msg) + raise ksa_exceptions.NotFound(404, msg) elif num > 1: - raise exceptions.NoUniqueMatch + raise ksc_exceptions.NoUniqueMatch else: return rl[0] -- cgit v1.2.1