Replace get_cinder_client_version in cinder.py
Due to bug 1386232 Nova has forked get_volume_api_from_url method from python-cinderclient. As the bug is fixed now this commit removes Nova's version and replaces usages with cinderclient's one. Depends-On: Idce26be00db8551d265fe668975a5843c772dd65 Change-Id: Ib0043786c808b470078d65db0d874720f99e583e Closes-Bug: 1465627
This commit is contained in:
@@ -70,7 +70,6 @@ class CinderApiTestCase(test.NoDBTestCase):
|
||||
self.mox.StubOutWithMock(cinder, 'cinderclient')
|
||||
self.mox.StubOutWithMock(cinder, '_untranslate_volume_summary_view')
|
||||
self.mox.StubOutWithMock(cinder, '_untranslate_snapshot_summary_view')
|
||||
self.mox.StubOutWithMock(cinder, 'get_cinder_client_version')
|
||||
|
||||
def test_get(self):
|
||||
volume_id = 'volume_id1'
|
||||
|
@@ -30,7 +30,6 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from nova import availability_zones as az
|
||||
from nova import exception
|
||||
@@ -116,7 +115,7 @@ def cinderclient(context):
|
||||
# TODO(jamielennox): This should be using proper version discovery from
|
||||
# the cinder service rather than just inspecting the URL for certain string
|
||||
# values.
|
||||
version = get_cinder_client_version(url)
|
||||
version = cinder_client.get_volume_api_from_url(url)
|
||||
|
||||
if version == '1' and not _V1_ERROR_RAISED:
|
||||
msg = _LW('Cinder V1 API is deprecated as of the Juno '
|
||||
@@ -256,27 +255,6 @@ def translate_snapshot_exception(method):
|
||||
return wrapper
|
||||
|
||||
|
||||
def get_cinder_client_version(url):
|
||||
"""Parse cinder client version by endpoint url.
|
||||
|
||||
:param url: URL for cinder.
|
||||
:return: str value(1 or 2).
|
||||
"""
|
||||
# FIXME(jamielennox): Use cinder_client.get_volume_api_from_url when
|
||||
# bug #1386232 is fixed.
|
||||
valid_versions = ['v1', 'v2']
|
||||
scheme, netloc, path, query, frag = urlparse.urlsplit(url)
|
||||
components = path.split("/")
|
||||
|
||||
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 cinder_exception.UnsupportedVersion(msg)
|
||||
|
||||
|
||||
class API(object):
|
||||
"""API for interacting with the volume manager."""
|
||||
|
||||
|
Reference in New Issue
Block a user