Add support for cinder api microversions
Change-Id: I72ee9ac9a67f76176d516be16cafe6d769147818
This commit is contained in:
parent
89646a6cb4
commit
9511371f73
@ -19,6 +19,11 @@ Changelog
|
||||
unreleased
|
||||
----------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
* Support for specifying microversions for Cinder service.
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -19,8 +19,8 @@
|
||||
"version": 2.2
|
||||
},
|
||||
"cinder": {
|
||||
"version": 2,
|
||||
"service_type": "volumev2"
|
||||
"version": 3.1,
|
||||
"service_type": "volumev3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,5 @@
|
||||
nova:
|
||||
version: 2.2
|
||||
cinder:
|
||||
version: 2
|
||||
service_type: "volumev2"
|
||||
version: 3.1
|
||||
service_type: "volumev3"
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user