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/utils.py | |
| 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/utils.py')
| -rw-r--r-- | openstackclient/common/utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
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) |
