summaryrefslogtreecommitdiff
path: root/openstackclient/volume/client.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2015-04-13 16:47:49 -0500
committerDean Troyer <dtroyer@gmail.com>2015-04-15 22:40:52 -0500
commitf43c1f76559ae8b5b738b7ae8b69b15c379f9145 (patch)
tree0312547c04ebfc6ae09119b734945e6bbfcbb651 /openstackclient/volume/client.py
parente60bf28ae3bdb34b65316249f0e7615048aa1f95 (diff)
downloadpython-openstackclient-f43c1f76559ae8b5b738b7ae8b69b15c379f9145.tar.gz
Defer client imports
So we really weren't deferring the loading of client libs dadgummit, do that for real where possible. This shaves a couple of tenths off the static import times. Also defer as much import-time procesing as possible. This is a little ugly in api.auth but this also eliminates import of the auth plugins until they are needed. Change-Id: Ia11d4b9cf98231d37449103fc29101dc17afb009
Diffstat (limited to 'openstackclient/volume/client.py')
-rw-r--r--openstackclient/volume/client.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py
index 21072aeb..a7b64def 100644
--- a/openstackclient/volume/client.py
+++ b/openstackclient/volume/client.py
@@ -15,17 +15,8 @@
import logging
-from cinderclient import extension
-from cinderclient.v1.contrib import list_extensions
-from cinderclient.v1 import volume_snapshots
-from cinderclient.v1 import volumes
-
from openstackclient.common import utils
-# Monkey patch for v1 cinderclient
-volumes.Volume.NAME_ATTR = 'display_name'
-volume_snapshots.Snapshot.NAME_ATTR = 'display_name'
-
LOG = logging.getLogger(__name__)
DEFAULT_VOLUME_API_VERSION = '1'
@@ -38,6 +29,17 @@ API_VERSIONS = {
def make_client(instance):
"""Returns a volume service client."""
+
+ # Defer client imports until we actually need them
+ from cinderclient import extension
+ from cinderclient.v1.contrib import list_extensions
+ from cinderclient.v1 import volume_snapshots
+ from cinderclient.v1 import volumes
+
+ # Monkey patch for v1 cinderclient
+ volumes.Volume.NAME_ATTR = 'display_name'
+ volume_snapshots.Snapshot.NAME_ATTR = 'display_name'
+
volume_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],