summaryrefslogtreecommitdiff
path: root/openstackclient/compute/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/compute/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/compute/client.py')
-rw-r--r--openstackclient/compute/client.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py
index 7ca08a4f..461c3926 100644
--- a/openstackclient/compute/client.py
+++ b/openstackclient/compute/client.py
@@ -15,14 +15,6 @@
import logging
-from novaclient import client as nova_client
-from novaclient import extension
-
-try:
- from novaclient.v2.contrib import list_extensions
-except ImportError:
- from novaclient.v1_1.contrib import list_extensions
-
from openstackclient.common import utils
LOG = logging.getLogger(__name__)
@@ -34,6 +26,15 @@ API_NAME = 'compute'
def make_client(instance):
"""Returns a compute service client."""
+
+ # Defer client imports until we actually need them
+ from novaclient import client as nova_client
+ from novaclient import extension
+ try:
+ from novaclient.v2.contrib import list_extensions
+ except ImportError:
+ from novaclient.v1_1.contrib import list_extensions
+
compute_client = nova_client.get_client_class(
instance._api_version[API_NAME],
)