From fa4a4a37d6ce931a9832677dea1edffd228300a4 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 10 May 2012 16:25:31 -0500 Subject: Move get_client_class() to common.utils * add constants for API_NAME Change-Id: I8ccf72f032227e0a452d96303181549b1b11a5d1 --- openstackclient/identity/client.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'openstackclient/identity/client.py') diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py index 318bfe32..b7066e5e 100644 --- a/openstackclient/identity/client.py +++ b/openstackclient/identity/client.py @@ -22,28 +22,20 @@ from openstackclient.common import utils LOG = logging.getLogger(__name__) +API_NAME = 'identity' API_VERSIONS = { '2.0': 'keystoneclient.v2_0.client.Client', } -def get_client_class(version): - """Returns the client class for the requested API version - """ - try: - client_path = API_VERSIONS[str(version)] - except (KeyError, ValueError): - msg = "Invalid client version '%s'. must be one of: %s" % ( - (version, ', '.join(API_VERSIONS.keys()))) - raise exc.UnsupportedVersion(msg) - - return utils.import_class(client_path) - - def make_client(instance): """Returns an identity service client. """ - identity_client = get_client_class(instance._api_version['identity']) + identity_client = utils.get_client_class( + API_NAME, + instance._api_version[API_NAME], + API_VERSIONS, + ) if instance._url: LOG.debug('instantiating identity client: token flow') client = identity_client( -- cgit v1.2.1