summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-05-16 22:57:28 +0000
committerGerrit Code Review <review@openstack.org>2016-05-16 22:57:28 +0000
commit948c76b0a42640ef7705214c6c2b6c7616dbe606 (patch)
tree1d8309325121804de37dcd250eb207cdc26da9a1 /openstackclient
parent3d12ae8e0364a9cd745d10e260e4918e6658e1e7 (diff)
parenta5a343a5a86658246cc136a330eee951e32c7b56 (diff)
downloadpython-openstackclient-948c76b0a42640ef7705214c6c2b6c7616dbe606.tar.gz
Merge "Support X.latest format for OS_COMPUTE_API_VERSION"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/compute/client.py45
1 files changed, 26 insertions, 19 deletions
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py
index 1481ed65..82f09cec 100644
--- a/openstackclient/compute/client.py
+++ b/openstackclient/compute/client.py
@@ -41,8 +41,18 @@ def make_client(instance):
version = _compute_api_version
else:
version = instance._api_version[API_NAME]
+ from novaclient import api_versions
+ # convert to APIVersion object
+ version = api_versions.get_api_version(version)
+
+ if version.is_latest():
+ import novaclient
+ # NOTE(RuiChen): executing version discovery make sense, but that need
+ # an initialized REST client, it's not available now,
+ # fallback to use the max version of novaclient side.
+ version = novaclient.API_MAX_VERSION
- LOG.debug('Instantiating compute client for V%s', version)
+ LOG.debug('Instantiating compute client for %s', version)
# Set client http_log_debug to True if verbosity level is high enough
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
@@ -91,30 +101,27 @@ def check_api_version(check_version):
"""
# Defer client imports until we actually need them
- try:
- from novaclient import api_versions
- except ImportError:
- # Retain previous behaviour
- return False
-
import novaclient
+ from novaclient import api_versions
global _compute_api_version
- # Copy some logic from novaclient 2.27.0 for basic version detection
+ # Copy some logic from novaclient 3.3.0 for basic version detection
# NOTE(dtroyer): This is only enough to resume operations using API
# version 2.0 or any valid version supplied by the user.
_compute_api_version = api_versions.get_api_version(check_version)
- if _compute_api_version > api_versions.APIVersion("2.0"):
- if not _compute_api_version.matches(
- novaclient.API_MIN_VERSION,
- novaclient.API_MAX_VERSION,
- ):
- raise exceptions.CommandError(
- "versions supported by client: %s - %s" % (
- novaclient.API_MIN_VERSION.get_string(),
- novaclient.API_MAX_VERSION.get_string(),
- ),
- )
+ # Bypass X.latest format microversion
+ if not _compute_api_version.is_latest():
+ if _compute_api_version > api_versions.APIVersion("2.0"):
+ if not _compute_api_version.matches(
+ novaclient.API_MIN_VERSION,
+ novaclient.API_MAX_VERSION,
+ ):
+ raise exceptions.CommandError(
+ "versions supported by client: %s - %s" % (
+ novaclient.API_MIN_VERSION.get_string(),
+ novaclient.API_MAX_VERSION.get_string(),
+ ),
+ )
return True