Merge "Fix the failure of fetching the version in cinder endpoint"

This commit is contained in:
Jenkins 2013-10-14 20:00:40 +00:00 committed by Gerrit Code Review
commit 873bed99a8

View File

@ -384,13 +384,14 @@ class HTTPClient(object):
def get_volume_api_version_from_endpoint(self): def get_volume_api_version_from_endpoint(self):
magic_tuple = urlparse.urlsplit(self.management_url) magic_tuple = urlparse.urlsplit(self.management_url)
scheme, netloc, path, query, frag = magic_tuple scheme, netloc, path, query, frag = magic_tuple
v = path.split("/")[1] components = path.split("/")
valid_versions = ['v1', 'v2'] valid_versions = ['v1', 'v2']
if v not in valid_versions: for version in valid_versions:
msg = "Invalid client version '%s'. must be one of: %s" % ( if version in components:
(v, ', '.join(valid_versions))) return version[1:]
raise exceptions.UnsupportedVersion(msg) msg = "Invalid client version '%s'. must be one of: %s" % (
return v[1:] (version, ', '.join(valid_versions)))
raise exceptions.UnsupportedVersion(msg)
def get_client_class(version): def get_client_class(version):