1515
1616import simplejson as json
1717
18- from keystoneclient import exceptions as ksc_exceptions
19- from keystoneclient import session as ksc_session
18+ from keystoneauth1 import exceptions as ks_exceptions
19+ from keystoneauth1 import session as ks_session
20+
2021from openstackclient .common import exceptions
2122
2223
2324class KeystoneSession (object ):
2425 """Wrapper for the Keystone Session
2526
2627 Restore some requests.session.Session compatibility;
27- keystoneclient .session.Session.request() has the method and url
28+ keystoneauth1 .session.Session.request() has the method and url
2829 arguments swapped from the rest of the requests-using world.
2930
3031 """
@@ -70,7 +71,7 @@ def _request(self, method, url, session=None, **kwargs):
7071 if not session :
7172 session = self .session
7273 if not session :
73- session = ksc_session .Session ()
74+ session = ks_session .Session ()
7475
7576 if self .endpoint :
7677 if url :
@@ -255,7 +256,7 @@ def getlist(kw):
255256 return data [0 ]
256257 if len (data ) > 1 :
257258 msg = "Multiple %s exist with %s='%s'"
258- raise ksc_exceptions .CommandError (
259+ raise exceptions .CommandError (
259260 msg % (resource , attr , value ),
260261 )
261262
@@ -314,7 +315,7 @@ def find_one(
314315 num_bulk = len (bulk_list )
315316 if num_bulk == 0 :
316317 msg = "none found"
317- raise ksc_exceptions .NotFound (msg )
318+ raise exceptions .NotFound (msg )
318319 elif num_bulk > 1 :
319320 msg = "many found"
320321 raise RuntimeError (msg )
@@ -338,12 +339,12 @@ def find(
338339
339340 try :
340341 ret = self ._request ('GET' , "/%s/%s" % (path , value )).json ()
341- except ksc_exceptions .NotFound :
342+ except ks_exceptions .NotFound :
342343 kwargs = {attr : value }
343344 try :
344345 ret = self .find_one ("/%s/detail" % (path ), ** kwargs )
345- except ksc_exceptions .NotFound :
346+ except ks_exceptions .NotFound :
346347 msg = "%s not found" % value
347- raise ksc_exceptions .NotFound (msg )
348+ raise exceptions .NotFound (msg )
348349
349350 return ret
0 commit comments