diff options
| author | scottda <scott.dangelo@hpe.com> | 2016-10-12 16:03:14 -0600 |
|---|---|---|
| committer | John Griffith <john.griffith8@gmail.com> | 2017-03-09 21:42:28 +0000 |
| commit | 3220566e46f2480098801546345d429dd6dfc9d6 (patch) | |
| tree | 3a856aa49adf7baf257349020f3ecf54a98d4541 /cinderclient/client.py | |
| parent | 4395dbdda6415b337a41afe5f289281a13465c5d (diff) | |
| download | python-cinderclient-3220566e46f2480098801546345d429dd6dfc9d6.tar.gz | |
Fix discover_version
discover_version needs to find the proper module for server_api_version
method, and it needs to properly parse a list of versions.
Do some refactor to clean things up.
Add unit tests.
Co-Authored-By: waj334 <justin.wilson@intel.com>
Change-Id: I742bc33074cc55fe5f9682b8b97a82573c51183f
Closes-Bug: #1632872
Diffstat (limited to 'cinderclient/client.py')
| -rw-r--r-- | cinderclient/client.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cinderclient/client.py b/cinderclient/client.py index 298ec94..b3abe2f 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -93,10 +93,17 @@ def get_server_version(url): api_versions.APIVersion(version['version'])) except exceptions.ClientException as e: logger.warning(_LW("Error in server version query:%s\n" - "Returning APIVersion 2.0") % six.text_type(e.message)) + "Returning APIVersion 2.0"), six.text_type(e.message)) return api_versions.APIVersion("2.0"), api_versions.APIVersion("2.0") +def get_highest_client_server_version(url): + min_server, max_server = get_server_version(url) + max_server_version = api_versions.APIVersion.get_string(max_server) + + return min(float(max_server_version), float(api_versions.MAX_VERSION)) + + def get_volume_api_from_url(url): scheme, netloc, path, query, frag = urlparse.urlsplit(url) components = path.split("/") @@ -203,7 +210,7 @@ class SessionClient(adapter.LegacyJsonAdapter): 'auth plugin.') def _cs_request_base_url(self, url, method, **kwargs): - base_url = self._get_base_url(**kwargs) + base_url = self._get_base_url() return self._cs_request( base_url + url, method, |
