summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2012-05-04 12:28:35 -0500
committerDean Troyer <dtroyer@gmail.com>2012-05-04 16:37:18 -0500
commit70b3246a1983700736b7ce4c83e9381d987cc598 (patch)
treede32c02c765df7d7a765ef09d10a930ac5f79d9d /openstackclient/common
parent5e4032150d360a305397e0220e51c5a66f2f5313 (diff)
downloadpython-openstackclient-70b3246a1983700736b7ce4c83e9381d987cc598.tar.gz
Add Identity to ClientManager
* Make the Identity client in identity.client.make_client() * Auth via ClientManager.identity * Skip extra auth roundtrip in compute client Change-Id: I0190639e38f83997c233195f6cc27ff3afdfba10
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/clientmanager.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index 66d3ce76..ab47cc5d 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -5,8 +5,7 @@ import logging
from openstackclient.common import exceptions as exc
from openstackclient.compute import client as compute_client
-
-from keystoneclient.v2_0 import client as keystone_client
+from openstackclient.identity import client as identity_client
LOG = logging.getLogger(__name__)
@@ -31,6 +30,9 @@ class ClientManager(object):
"""Manages access to API clients, including authentication.
"""
+ # Identity client is instantiated in init_token()
+ # otherwise we have a recursion problem
+ identity = None
compute = ClientCache(compute_client.make_client)
def __init__(self, token=None, url=None,
@@ -82,15 +84,11 @@ class ClientManager(object):
"You must provide an auth url via"
" either --os-auth-url or via env[OS_AUTH_URL]")
- kwargs = {
- 'username': self._username,
- 'password': self._password,
- 'tenant_id': self._tenant_id,
- 'tenant_name': self._tenant_name,
- 'auth_url': self._auth_url
- }
- self._auth_client = keystone_client.Client(**kwargs)
- self._token = self._auth_client.auth_token
+ # Get an Identity client and keep a token and catalog
+ if not self.identity:
+ self.identity = identity_client.make_client(self)
+ self._token = self.identity.auth_token
+ self._service_catalog = self.identity.service_catalog
return
def get_endpoint_for_service_type(self, service_type):
@@ -98,8 +96,8 @@ class ClientManager(object):
"""
# See if we are using password flow auth, i.e. we have a
# service catalog to select endpoints from
- if self._auth_client and self._auth_client.service_catalog:
- endpoint = self._auth_client.service_catalog.url_for(
+ if self._service_catalog:
+ endpoint = self._service_catalog.url_for(
service_type=service_type)
else:
# Hope we were given the correct URL.