diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2012-05-10 15:47:59 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2012-05-10 15:52:15 -0500 |
| commit | 712a8c7f9c5c89071f7f3d87a8d4484921581cf6 (patch) | |
| tree | 956d2609e54436b72e02cda56918d55aae111f46 /openstackclient/common | |
| parent | 9d224b3bf811c9c0b41246b7bfe937dd172ed95e (diff) | |
| download | python-openstackclient-712a8c7f9c5c89071f7f3d87a8d4484921581cf6.tar.gz | |
Add API versioning support
* Specific versions supported are managed in XXXXXX.client.py with a
mapping from version to client class. This is based on the scheme
that is included in novaclient; none of the other client libs have
that capability.
Change-Id: I930b197f1189e7f52c3b0096e73e0773cf925542
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/clientmanager.py | 8 | ||||
| -rw-r--r-- | openstackclient/common/exceptions.py | 6 | ||||
| -rw-r--r-- | openstackclient/common/utils.py | 8 |
3 files changed, 16 insertions, 6 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index e3f8588a..0a9f9102 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -54,9 +54,7 @@ class ClientManager(object): tenant_name=None, tenant_id=None, username=None, password=None, region_name=None, - identity_api_version=None, - compute_api_version=None, - image_api_version=None, + api_version=None, ): self._token = token self._url = url @@ -66,9 +64,7 @@ class ClientManager(object): self._username = username self._password = password self._region_name = region_name - self._identity_api_version = identity_api_version - self._compute_api_version = compute_api_version - self._image_api_version = image_api_version + self._api_version = api_version self._service_catalog = None if not self._url: diff --git a/openstackclient/common/exceptions.py b/openstackclient/common/exceptions.py index 4b4a0fb4..aa070b37 100644 --- a/openstackclient/common/exceptions.py +++ b/openstackclient/common/exceptions.py @@ -39,6 +39,12 @@ class EndpointNotFound(Exception): pass +class UnsupportedVersion(Exception): + """Indicates that the user is trying to use an unsupported + version of the API""" + pass + + class ClientException(Exception): """ The base exception class for all exceptions this library raises. diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index fe0e5bcb..e0f35ad4 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -20,6 +20,7 @@ Common client utilities """ import os +import sys import uuid import prettytable @@ -67,3 +68,10 @@ def env(*vars, **kwargs): if value: return value return kwargs.get('default', '') + + +def import_class(import_str): + """Returns a class from a string including module and class.""" + mod_str, _sep, class_str = import_str.rpartition('.') + __import__(mod_str) + return getattr(sys.modules[mod_str], class_str) |
