diff options
| author | Andrey Kurilin <akurilin@mirantis.com> | 2015-09-11 16:23:54 +0300 |
|---|---|---|
| committer | Andrey Kurilin <akurilin@mirantis.com> | 2015-09-11 16:23:54 +0300 |
| commit | 9e6f99e2ab4763c5288e5e876dee2708d0ddc273 (patch) | |
| tree | fe9ba89329148ea82ccbd6ca70f3feb3a25e2d80 /openstackclient/compute | |
| parent | a936c308936a0d24c3c023481104df82cada1dff (diff) | |
| download | python-openstackclient-9e6f99e2ab4763c5288e5e876dee2708d0ddc273.tar.gz | |
Use `discover_extensions` for novaclient
novaclien v2.26.0 includes `discover_extensions` method, which returns
list of all nova extensions based of version. Such method allows us to
reduce imports of novaclient's modules and construct novaclient instance
simpler.
Change-Id: Idbe3ed275fb4a7e3918b11669dcfad47b8de4fb9
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/client.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py index 8ac5f324..23a4deca 100644 --- a/openstackclient/compute/client.py +++ b/openstackclient/compute/client.py @@ -34,13 +34,8 @@ _compute_api_version = None def make_client(instance): """Returns a compute service client.""" - # Defer client imports until we actually need them + # Defer client import 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 if _compute_api_version is not None: version = _compute_api_version @@ -52,7 +47,8 @@ def make_client(instance): # Set client http_log_debug to True if verbosity level is high enough http_log_debug = utils.get_effective_log_level() <= logging.DEBUG - extensions = [extension.Extension('list_extensions', list_extensions)] + extensions = [ext for ext in nova_client.discover_extensions(version) + if ext.name == "list_extensions"] # Remember interface only if it is set kwargs = utils.build_kwargs_dict('endpoint_type', instance._interface) |
