From f43c1f76559ae8b5b738b7ae8b69b15c379f9145 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 13 Apr 2015 16:47:49 -0500 Subject: 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 --- openstackclient/volume/client.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'openstackclient/volume') 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], -- cgit v1.2.1