diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-09-07 10:51:43 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-09-07 10:51:43 +0000 |
| commit | 9b3c84e9e19785dd377ef5c3f754bfddebc75f06 (patch) | |
| tree | 8479bee875331a435f0f4d504aa73d6d8e1f1939 /openstackclient/common/utils.py | |
| parent | 0bc4377b0ab1f4fa227c1d97068f16ceacd5afa7 (diff) | |
| parent | c43854048c308c76c04e1f43b8a366353cb13816 (diff) | |
| download | python-openstackclient-9b3c84e9e19785dd377ef5c3f754bfddebc75f06.tar.gz | |
Merge "Leverage openstack.common.importutils for import_class"
Diffstat (limited to 'openstackclient/common/utils.py')
| -rw-r--r-- | openstackclient/common/utils.py | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 51c3ed4b..cef9dcee 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -19,10 +19,10 @@ import getpass import logging import os import six -import sys import time from openstackclient.common import exceptions +from openstackclient.openstack.common import importutils def find_resource(manager, name_or_id): @@ -157,17 +157,6 @@ def env(*vars, **kwargs): return kwargs.get('default', '') -def import_class(import_str): - """Returns a class from a string including module and class - - :param import_str: a string representation of the class name - :rtype: the requested class - """ - mod_str, _sep, class_str = import_str.rpartition('.') - __import__(mod_str) - return getattr(sys.modules[mod_str], class_str) - - def get_client_class(api_name, version, version_map): """Returns the client class for the requested API version @@ -183,7 +172,7 @@ def get_client_class(api_name, version, version_map): (api_name, version, ', '.join(version_map.keys()))) raise exceptions.UnsupportedVersion(msg) - return import_class(client_path) + return importutils.import_class(client_path) def wait_for_status(status_f, |
