diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7690ba8c..8d98074d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,11 @@ Changelog unreleased ---------- +Added +~~~~~ + +* Support for specifying microversions for Cinder service. + Removed ~~~~~~~ diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index 2f905ca3..bfabb6e8 100755 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -499,12 +499,12 @@ times: 2 concurrency: 2 contexts: + api_versions: + cinder: + version: 3.42 users: tenants: 2 users_per_tenant: 1 - sla: - failure_rate: - max: 100 - title: NovaServers.boot_server_from_volume_and_resize tests scenario: diff --git a/rally_openstack/common/osclients.py b/rally_openstack/common/osclients.py index 71bb4d0d..c291f4a5 100644 --- a/rally_openstack/common/osclients.py +++ b/rally_openstack/common/osclients.py @@ -505,13 +505,33 @@ class Heat(OSClient): return client -@configure("cinder", default_version="3", default_service_type="block-storage", - supported_versions=["1", "2", "3"]) +@configure("cinder", default_version="3", default_service_type="block-storage") class Cinder(OSClient): """Wrapper for CinderClient which returns an authenticated native client. """ + @classmethod + def validate_version(cls, version): + from cinderclient import api_versions + from cinderclient import exceptions as cinder_exc + + version = str(version) + if version in api_versions.REPLACEMENT_VERSIONS: + LOG.warning( + f"Version {version} is not supported by Cinder. Switching " + f"to {api_versions.REPLACEMENT_VERSIONS[version]}." + ) + version = api_versions.REPLACEMENT_VERSIONS[version] + + try: + version_obj = api_versions.get_api_version(version) + if version_obj > api_versions.APIVersion(api_versions.MAX_VERSION): + raise cinder_exc.UnsupportedVersion() + except cinder_exc.UnsupportedVersion: + raise exceptions.RallyException( + "Version string '%s' is unsupported." % version) from None + def create_client(self, version=None, service_type=None): """Return cinder client.""" from cinderclient import client as cinder diff --git a/samples/tasks/contexts/api-versions.json b/samples/tasks/contexts/api-versions.json index 095681ca..e4f64d41 100644 --- a/samples/tasks/contexts/api-versions.json +++ b/samples/tasks/contexts/api-versions.json @@ -19,8 +19,8 @@ "version": 2.2 }, "cinder": { - "version": 2, - "service_type": "volumev2" + "version": 3.1, + "service_type": "volumev3" } } } diff --git a/samples/tasks/contexts/api-versions.yaml b/samples/tasks/contexts/api-versions.yaml index b68c403a..c9861dd2 100644 --- a/samples/tasks/contexts/api-versions.yaml +++ b/samples/tasks/contexts/api-versions.yaml @@ -15,5 +15,5 @@ nova: version: 2.2 cinder: - version: 2 - service_type: "volumev2" \ No newline at end of file + version: 3.1 + service_type: "volumev3" \ No newline at end of file diff --git a/tests/unit/common/test_osclients.py b/tests/unit/common/test_osclients.py index f63d4f67..3fd50e04 100644 --- a/tests/unit/common/test_osclients.py +++ b/tests/unit/common/test_osclients.py @@ -649,6 +649,16 @@ class OSClientsTestCase(test.TestCase): "3", **kw) self.assertEqual(fake_cinder, self.clients.cache["cinder"]) + def test_cinder_validate_version(self): + osclients.Cinder.validate_version("2") + osclients.Cinder.validate_version("3") + osclients.Cinder.validate_version("3.0") + osclients.Cinder.validate_version("3.10") + self.assertRaises(exceptions.RallyException, + osclients.Cinder.validate_version, "foo") + self.assertRaises(exceptions.RallyException, + osclients.Cinder.validate_version, "3.1000") + @mock.patch("%s.Manila._get_endpoint" % PATH) def test_manila(self, mock_manila__get_endpoint): mock_manila = mock.MagicMock()