From f96dcd714e494dc31612e01a9927beded691e2e8 Mon Sep 17 00:00:00 2001 From: jenny-shieh Date: Fri, 20 Sep 2013 12:28:45 -0700 Subject: [PATCH] Fix the failure of fetching the version in cinder endpoint To search for verion in cinder endpoint string, instead of using hard code position Implements: search for verion in cinder endpoint string Closes-Bug: #1227307 Change-Id: Ie38806ad995e6fd49155f448abf9b2ef43f24a0e --- cinderclient/client.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cinderclient/client.py b/cinderclient/client.py index 4846e4ace..ab9b8dd2c 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -384,13 +384,14 @@ class HTTPClient(object): def get_volume_api_version_from_endpoint(self): magic_tuple = urlparse.urlsplit(self.management_url) scheme, netloc, path, query, frag = magic_tuple - v = path.split("/")[1] + components = path.split("/") valid_versions = ['v1', 'v2'] - if v not in valid_versions: - msg = "Invalid client version '%s'. must be one of: %s" % ( - (v, ', '.join(valid_versions))) - raise exceptions.UnsupportedVersion(msg) - return v[1:] + for version in valid_versions: + if version in components: + return version[1:] + msg = "Invalid client version '%s'. must be one of: %s" % ( + (version, ', '.join(valid_versions))) + raise exceptions.UnsupportedVersion(msg) def get_client_class(version):