Remove now-unnecessary client creation hacks

Clients that can use ksc Session don't need the old junk to
fake auth anymore:
* compute
* volume

Clients that still need to be fed credentials can pick directly
from the auth object in clientmanager.  The _token attribute is
removed, the token can be retrieved from the auth object:

  openstackclient/tests/common/test_clientmanager.py

This change will break any plugin that relies on getting a token
from instance._token. They should be updated to use the above, or
preferable, to use keystoneclient.session.Session to create its
HTTP interface object.

Change-Id: I877a29de97a42f85f12a14c274fc003e6fba5135
This commit is contained in:
Dean Troyer 2014-10-17 22:26:57 -05:00
parent 68130fa921
commit 0de67016c7
6 changed files with 6 additions and 41 deletions

View File

@ -106,9 +106,6 @@ class ClientManager(object):
self.auth_ref = self.auth.get_auth_ref(self.session)
self._service_catalog = self.auth_ref.service_catalog
# This begone when clients no longer need it...
self._token = self.auth.get_token(self.session)
return
def get_endpoint_for_service_type(self, service_type, region_name=None):

View File

@ -43,6 +43,7 @@ def make_client(instance):
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
extensions = [extension.Extension('list_extensions', list_extensions)]
client = compute_client(
session=instance.session,
extensions=extensions,
@ -50,14 +51,6 @@ def make_client(instance):
timings=instance.timing,
)
# Populate the Nova client to skip another auth query to Identity
if 'token' not in instance._auth_params:
# password flow
client.client.management_url = instance.get_endpoint_for_service_type(
API_NAME, region_name=instance._region_name)
client.client.service_catalog = instance._service_catalog
client.client.auth_token = instance.auth.get_token(instance.session)
return client

View File

@ -45,7 +45,7 @@ def make_client(instance):
return image_client(
instance._url,
token=instance._token,
token=instance.auth.get_token(instance.session),
cacert=instance._cacert,
insecure=instance._insecure,
)

View File

@ -44,7 +44,7 @@ def make_client(instance):
region_name=instance._region_name,
auth_url=instance._auth_url,
endpoint_url=instance._url,
token=instance._token,
token=instance.auth.get_token(instance.session),
insecure=instance._insecure,
ca_cert=instance._cacert,
)

View File

@ -89,10 +89,9 @@ class TestClientManager(utils.TestCase):
fakes.AUTH_URL,
client_manager._url,
)
self.assertEqual(
fakes.AUTH_TOKEN,
client_manager._token,
client_manager.auth.get_token(None),
)
self.assertIsInstance(
client_manager.auth,
@ -111,10 +110,6 @@ class TestClientManager(utils.TestCase):
verify=True
)
self.assertEqual(
fakes.AUTH_TOKEN,
client_manager._token,
)
self.assertEqual(
fakes.AUTH_URL,
client_manager._auth_url,
@ -160,10 +155,6 @@ class TestClientManager(utils.TestCase):
AUTH_REF,
client_manager.auth_ref,
)
self.assertEqual(
fakes.AUTH_TOKEN,
client_manager._token,
)
self.assertEqual(
dir(SERVICE_CATALOG),
dir(client_manager._service_catalog),

View File

@ -49,29 +49,13 @@ def make_client(instance):
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
extensions = [extension.Extension('list_extensions', list_extensions)]
client = volume_client(
username=instance._username,
api_key=instance._password,
project_id=instance._project_name,
auth_url=instance._auth_url,
cacert=instance._cacert,
insecure=instance._insecure,
region_name=instance._region_name,
session=instance.session,
extensions=extensions,
http_log_debug=http_log_debug,
)
# Populate the Cinder client to skip another auth query to Identity
if instance._url:
# token flow
client.client.management_url = instance._url
else:
# password flow
client.client.management_url = instance.get_endpoint_for_service_type(
API_NAME, region_name=instance._region_name)
client.client.service_catalog = instance._service_catalog
client.client.auth_token = instance._token
return client