diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2012-05-10 16:25:31 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2012-05-11 13:49:45 -0500 |
| commit | fa4a4a37d6ce931a9832677dea1edffd228300a4 (patch) | |
| tree | cc54f5d6db37cce400de5eab2128145135e8bfd9 /openstackclient/identity/client.py | |
| parent | 5378322906a636bc2b9685e7403950549ef213f5 (diff) | |
| download | python-openstackclient-fa4a4a37d6ce931a9832677dea1edffd228300a4.tar.gz | |
Move get_client_class() to common.utils
* add constants for API_NAME
Change-Id: I8ccf72f032227e0a452d96303181549b1b11a5d1
Diffstat (limited to 'openstackclient/identity/client.py')
| -rw-r--r-- | openstackclient/identity/client.py | 20 |
1 files changed, 6 insertions, 14 deletions
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( |
