summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Wei <wei.li@easystack.cn>2016-10-21 15:57:39 +0800
committerChangBo Guo(gcb) <glongwave@gmail.com>2016-12-06 09:35:55 +0000
commit4773c9667251043333d9c3e0c56e9d262186380d (patch)
tree95f5e0b88da2e6d7bd57672f668d2d76ab31a922
parent1505a47ff38a7bca50f32cd37002f50fa5561909 (diff)
downloadpython-glanceclient-4773c9667251043333d9c3e0c56e9d262186380d.tar.gz
Use import_versioned_module from oslo.utils
oslo.utils 3.17 provides this funtion, so just use it directly. Change-Id: I85cb78a6fd33a5b1f7e09648efed1b0737678eee Closes-Bug: #1627313
-rw-r--r--glanceclient/client.py5
-rw-r--r--glanceclient/common/utils.py8
-rw-r--r--glanceclient/shell.py3
3 files changed, 6 insertions, 10 deletions
diff --git a/glanceclient/client.py b/glanceclient/client.py
index 714c96a..c0e8cc8 100644
--- a/glanceclient/client.py
+++ b/glanceclient/client.py
@@ -15,6 +15,8 @@
import warnings
+from oslo_utils import importutils
+
from glanceclient.common import utils
@@ -56,6 +58,7 @@ def Client(version=None, endpoint=None, session=None, *args, **kwargs):
"http://$HOST:$PORT/v$VERSION_NUMBER")
raise RuntimeError(msg)
- module = utils.import_versioned_module(int(version), 'client')
+ module = importutils.import_versioned_module('glanceclient', int(version),
+ 'client')
client_class = getattr(module, 'Client')
return client_class(endpoint, *args, session=session, **kwargs)
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py
index 9f3a1fe..93229e6 100644
--- a/glanceclient/common/utils.py
+++ b/glanceclient/common/utils.py
@@ -26,7 +26,6 @@ import sys
import threading
import uuid
-from oslo_utils import importutils
import six
if os.name == 'nt':
@@ -259,13 +258,6 @@ def env(*vars, **kwargs):
return kwargs.get('default', '')
-def import_versioned_module(version, submodule=None):
- module = 'glanceclient.v%s' % version
- if submodule:
- module = '.'.join((module, submodule))
- return importutils.import_module(module)
-
-
def exit(msg='', exit_code=1):
if msg:
print_err(msg)
diff --git a/glanceclient/shell.py b/glanceclient/shell.py
index 51e02a6..2c5fb4b 100644
--- a/glanceclient/shell.py
+++ b/glanceclient/shell.py
@@ -211,7 +211,8 @@ class OpenStackImagesShell(object):
self.subcommands = {}
subparsers = parser.add_subparsers(metavar='<subcommand>')
- submodule = utils.import_versioned_module(version, 'shell')
+ submodule = importutils.import_versioned_module('glanceclient',
+ version, 'shell')
self._find_actions(subparsers, submodule)
self._find_actions(subparsers, self)