summaryrefslogtreecommitdiff
path: root/openstackclient/common/clientmanager.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2012-05-09 17:15:43 -0500
committerDean Troyer <dtroyer@gmail.com>2012-05-10 13:54:58 -0500
commit6fb1a4e496f6860c800f08e68c05b7e95be36c3b (patch)
treef109c8da9544b54f59313006f4c219e10bd8ff8f /openstackclient/common/clientmanager.py
parenta7da2b8008c7429eab270aa937f563dfa3353afa (diff)
downloadpython-openstackclient-6fb1a4e496f6860c800f08e68c05b7e95be36c3b.tar.gz
More identity client config
* move auth option checking back to OpenStackShell() to keep the shell-level interaction at that level; add checking for token flow options * make identity.client.make_client() configure keystoneclient.v2_0.Client() properly for both password flow and token flow auth * eliminated ClientManager.init_token(), set _service_catalog in __init__() * compute client handles token flow Change-Id: I42481b5424489387798c4ec6d3e2a723ab1e6067
Diffstat (limited to 'openstackclient/common/clientmanager.py')
-rw-r--r--openstackclient/common/clientmanager.py43
1 files changed, 8 insertions, 35 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index ab47cc5d..04aef1db 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -21,7 +21,6 @@ class ClientCache(object):
def __get__(self, instance, owner):
# Tell the ClientManager to login to keystone
if self._handle is None:
- instance.init_token()
self._handle = self.factory(instance)
return self._handle
@@ -30,9 +29,7 @@ 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
+ identity = ClientCache(identity_client.make_client)
compute = ClientCache(compute_client.make_client)
def __init__(self, token=None, url=None,
@@ -55,40 +52,16 @@ class ClientManager(object):
self._identity_api_version = identity_api_version
self._compute_api_version = compute_api_version
self._image_api_version = image_api_version
+ self._service_catalog = None
- def init_token(self):
- """Return the auth token and endpoint.
- """
- if self._token:
- LOG.debug('using existing auth token')
- return
-
- LOG.debug('validating authentication options')
- if not self._username:
- raise exc.CommandError(
- "You must provide a username via"
- " either --os-username or env[OS_USERNAME]")
-
- if not self._password:
- raise exc.CommandError(
- "You must provide a password via"
- " either --os-password or env[OS_PASSWORD]")
-
- if not (self._tenant_id or self._tenant_name):
- raise exc.CommandError(
- "You must provide a tenant_id via"
- " either --os-tenant-id or via env[OS_TENANT_ID]")
+ # Create the identity client
+ self.identity
- if not self._auth_url:
- raise exc.CommandError(
- "You must provide an auth url via"
- " either --os-auth-url or via env[OS_AUTH_URL]")
+ if not self._url:
+ # Populate other password flow attributes
+ self._token = self.identity.auth_token
+ self._service_catalog = self.identity.service_catalog
- # 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):