From 6b5733803336eda074b4eafc7fa91ccd49f7cc02 Mon Sep 17 00:00:00 2001 From: Michal Dulko Date: Tue, 16 Jun 2015 15:17:54 +0200 Subject: [PATCH] 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 --- nova/tests/unit/volume/test_cinder.py | 1 - nova/volume/cinder.py | 24 +----------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/nova/tests/unit/volume/test_cinder.py b/nova/tests/unit/volume/test_cinder.py index 7821719cbc37..4e5e4892f571 100644 --- a/nova/tests/unit/volume/test_cinder.py +++ b/nova/tests/unit/volume/test_cinder.py @@ -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' diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index 962e77f4b314..088013754f1e 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -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."""