summaryrefslogtreecommitdiff
path: root/openstackclient/api/api.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2015-10-21 12:01:56 -0500
committerSteve Martinelli <stevemar@ca.ibm.com>2015-12-02 01:55:14 +0000
commitbf090c69c2e055285fc4fe45af0a5f66d6dc7759 (patch)
tree16447f8742a5b091e35c0812e0e396a28b180d33 /openstackclient/api/api.py
parenta9a7caf934f36c95727c30bdf2b1275609d3c0fc (diff)
downloadpython-openstackclient-bf090c69c2e055285fc4fe45af0a5f66d6dc7759.tar.gz
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
Diffstat (limited to 'openstackclient/api/api.py')
-rw-r--r--openstackclient/api/api.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/openstackclient/api/api.py b/openstackclient/api/api.py
index ba83ce4d..97eb7e4a 100644
--- a/openstackclient/api/api.py
+++ b/openstackclient/api/api.py
@@ -15,8 +15,9 @@
import simplejson as json
-from keystoneclient import exceptions as ksc_exceptions
-from keystoneclient import session as ksc_session
+from keystoneauth1 import exceptions as ks_exceptions
+from keystoneauth1 import session as ks_session
+
from openstackclient.common import exceptions
@@ -24,7 +25,7 @@ class KeystoneSession(object):
"""Wrapper for the Keystone Session
Restore some requests.session.Session compatibility;
- keystoneclient.session.Session.request() has the method and url
+ keystoneauth1.session.Session.request() has the method and url
arguments swapped from the rest of the requests-using world.
"""
@@ -70,7 +71,7 @@ class KeystoneSession(object):
if not session:
session = self.session
if not session:
- session = ksc_session.Session()
+ session = ks_session.Session()
if self.endpoint:
if url:
@@ -255,7 +256,7 @@ class BaseAPI(KeystoneSession):
return data[0]
if len(data) > 1:
msg = "Multiple %s exist with %s='%s'"
- raise ksc_exceptions.CommandError(
+ raise exceptions.CommandError(
msg % (resource, attr, value),
)
@@ -314,7 +315,7 @@ class BaseAPI(KeystoneSession):
num_bulk = len(bulk_list)
if num_bulk == 0:
msg = "none found"
- raise ksc_exceptions.NotFound(msg)
+ raise exceptions.NotFound(msg)
elif num_bulk > 1:
msg = "many found"
raise RuntimeError(msg)
@@ -338,12 +339,12 @@ class BaseAPI(KeystoneSession):
try:
ret = self._request('GET', "/%s/%s" % (path, value)).json()
- except ksc_exceptions.NotFound:
+ except ks_exceptions.NotFound:
kwargs = {attr: value}
try:
ret = self.find_one("/%s/detail" % (path), **kwargs)
- except ksc_exceptions.NotFound:
+ except ks_exceptions.NotFound:
msg = "%s not found" % value
- raise ksc_exceptions.NotFound(msg)
+ raise exceptions.NotFound(msg)
return ret