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
This commit is contained in:
jenny-shieh 2013-09-20 12:28:45 -07:00 committed by Jay S. Bryant
parent 4a507601d7
commit f96dcd714e

View File

@ -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):