Skip to content

Commit bf090c6

Browse files
Dean TroyerSteve Martinelli
authored andcommitted
Switch to ksa Session
* Change session imports to keystoneauth1 * Change keystoneclient.exception imports to keystoneauth1 * Change exceptions raised from internal API from keystoneclient to openstack.common Change-Id: I046d89f561d6fe04baae53726f9749d2e7fe2056
1 parent a9a7caf commit bf090c6

15 files changed

Lines changed: 41 additions & 39 deletions

File tree

examples/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import sys
3838
import traceback
3939

40-
from keystoneclient import session as ksc_session
40+
from keystoneauth1 import session as ks_session
4141

4242
from openstackclient.api import auth
4343

@@ -226,7 +226,7 @@ def make_session(opts, **kwargs):
226226
)
227227
auth_p = auth_plugin.load_from_options(**auth_params)
228228

229-
session = ksc_session.Session(
229+
session = ks_session.Session(
230230
auth=auth_p,
231231
**kwargs
232232
)

openstackclient/api/api.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@
1515

1616
import 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+
2021
from openstackclient.common import exceptions
2122

2223

2324
class 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

openstackclient/common/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# under the License.
1212
#
1313

14-
"""Subclass of keystoneclient.session"""
14+
"""Subclass of keystoneauth1.session"""
1515

16-
from keystoneclient import session
16+
from keystoneauth1 import session
1717

1818

1919
class TimingSession(session.Session):

openstackclient/compute/v2/security_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from cliff import lister
2424
from cliff import show
2525

26-
from keystoneclient import exceptions as ksc_exc
26+
from keystoneauth1 import exceptions as ks_exc
2727

2828
try:
2929
from novaclient.v2 import security_group_rules
@@ -241,7 +241,7 @@ def _get_project(project_id):
241241
project_hash = {}
242242
try:
243243
projects = self.app.client_manager.identity.projects.list()
244-
except ksc_exc.ClientException:
244+
except ks_exc.ClientException:
245245
# This fails when the user is not an admin, just move along
246246
pass
247247
else:

openstackclient/identity/v2_0/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from cliff import command
2222
from cliff import lister
2323
from cliff import show
24-
from keystoneclient import exceptions as ksc_exc
24+
from keystoneauth1 import exceptions as ks_exc
2525

2626
from openstackclient.common import parseractions
2727
from openstackclient.common import utils
@@ -88,7 +88,7 @@ def take_action(self, parsed_args):
8888
enabled=enabled,
8989
**kwargs
9090
)
91-
except ksc_exc.Conflict as e:
91+
except ks_exc.Conflict as e:
9292
if parsed_args.or_show:
9393
project = utils.find_resource(
9494
identity_client.tenants,
@@ -264,7 +264,7 @@ def take_action(self, parsed_args):
264264
parsed_args.project,
265265
)
266266
info.update(project._info)
267-
except ksc_exc.Forbidden as e:
267+
except ks_exc.Forbidden as e:
268268
auth_ref = self.app.client_manager.auth_ref
269269
if (
270270
parsed_args.project == auth_ref.project_id or

openstackclient/identity/v2_0/role.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from cliff import command
2222
from cliff import lister
2323
from cliff import show
24-
from keystoneclient import exceptions as ksc_exc
24+
from keystoneauth1 import exceptions as ks_exc
2525

2626
from openstackclient.common import exceptions
2727
from openstackclient.common import utils
@@ -98,7 +98,7 @@ def take_action(self, parsed_args):
9898
identity_client = self.app.client_manager.identity
9999
try:
100100
role = identity_client.roles.create(parsed_args.role_name)
101-
except ksc_exc.Conflict as e:
101+
except ks_exc.Conflict as e:
102102
if parsed_args.or_show:
103103
role = utils.find_resource(
104104
identity_client.roles,

openstackclient/identity/v2_0/user.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from cliff import command
2222
from cliff import lister
2323
from cliff import show
24-
from keystoneclient import exceptions as ksc_exc
24+
from keystoneauth1 import exceptions as ks_exc
2525

2626
from openstackclient.common import utils
2727
from openstackclient.i18n import _ # noqa
@@ -104,7 +104,7 @@ def take_action(self, parsed_args):
104104
tenant_id=project_id,
105105
enabled=enabled,
106106
)
107-
except ksc_exc.Conflict as e:
107+
except ks_exc.Conflict as e:
108108
if parsed_args.or_show:
109109
user = utils.find_resource(
110110
identity_client.users,
@@ -373,7 +373,7 @@ def take_action(self, parsed_args):
373373
parsed_args.user,
374374
)
375375
info.update(user._info)
376-
except ksc_exc.Forbidden as e:
376+
except ks_exc.Forbidden as e:
377377
auth_ref = self.app.client_manager.auth_ref
378378
if (
379379
parsed_args.user == auth_ref.user_id or

openstackclient/identity/v3/domain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from cliff import command
2323
from cliff import lister
2424
from cliff import show
25-
from keystoneclient import exceptions as ksc_exc
25+
from keystoneauth1 import exceptions as ks_exc
2626

2727
from openstackclient.common import utils
2828
from openstackclient.i18n import _ # noqa
@@ -77,7 +77,7 @@ def take_action(self, parsed_args):
7777
description=parsed_args.description,
7878
enabled=enabled,
7979
)
80-
except ksc_exc.Conflict as e:
80+
except ks_exc.Conflict as e:
8181
if parsed_args.or_show:
8282
domain = utils.find_resource(identity_client.domains,
8383
parsed_args.name)

openstackclient/identity/v3/group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from cliff import command
2323
from cliff import lister
2424
from cliff import show
25-
from keystoneclient import exceptions as ksc_exc
25+
from keystoneauth1 import exceptions as ks_exc
2626

2727
from openstackclient.common import utils
2828
from openstackclient.i18n import _ # noqa
@@ -156,7 +156,7 @@ def take_action(self, parsed_args):
156156
name=parsed_args.name,
157157
domain=domain,
158158
description=parsed_args.description)
159-
except ksc_exc.Conflict as e:
159+
except ks_exc.Conflict as e:
160160
if parsed_args.or_show:
161161
group = utils.find_resource(identity_client.groups,
162162
parsed_args.name,

openstackclient/identity/v3/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from cliff import command
2222
from cliff import lister
2323
from cliff import show
24-
from keystoneclient import exceptions as ksc_exc
24+
from keystoneauth1 import exceptions as ks_exc
2525

2626
from openstackclient.common import parseractions
2727
from openstackclient.common import utils
@@ -113,7 +113,7 @@ def take_action(self, parsed_args):
113113
enabled=enabled,
114114
**kwargs
115115
)
116-
except ksc_exc.Conflict as e:
116+
except ks_exc.Conflict as e:
117117
if parsed_args.or_show:
118118
project = utils.find_resource(identity_client.projects,
119119
parsed_args.name,

0 commit comments

Comments
 (0)