Merge "Add CinderVolumeTypes.create_and_update_encryption_type"
This commit is contained in:
commit
b4473fdeb9
@ -1140,3 +1140,32 @@
|
|||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
|
||||||
|
CinderVolumeTypes.create_and_update_encryption_type:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
create_provider: "LuksEncryptor"
|
||||||
|
create_cipher: "aes-xts-plain64"
|
||||||
|
create_key_size: 512
|
||||||
|
create_control_location: "front-end"
|
||||||
|
update_provider: "CryptsetupEncryptor"
|
||||||
|
update_cipher: "aes-xts-plain"
|
||||||
|
update_key_size: 256
|
||||||
|
update_control_location: "back-end"
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 4
|
||||||
|
concurrency: 1
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 2
|
||||||
|
users_per_tenant: 2
|
||||||
|
volume_types: [
|
||||||
|
"test_type1",
|
||||||
|
"test_type2",
|
||||||
|
"test_type3",
|
||||||
|
"test_type4"
|
||||||
|
]
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
@ -276,3 +276,55 @@ class CreateAndDeleteEncryptionType(cinder_utils.CinderBasic):
|
|||||||
self.admin_cinder.create_encryption_type(volume_type["id"],
|
self.admin_cinder.create_encryption_type(volume_type["id"],
|
||||||
specs=specs)
|
specs=specs)
|
||||||
self.admin_cinder.delete_encryption_type(volume_type["id"])
|
self.admin_cinder.delete_encryption_type(volume_type["id"])
|
||||||
|
|
||||||
|
|
||||||
|
@validation.required_services(consts.Service.CINDER)
|
||||||
|
@validation.required_contexts("volume_types")
|
||||||
|
@validation.add("required_platform", platform="openstack", admin=True)
|
||||||
|
@scenario.configure(context={"admin_cleanup": ["cinder"]},
|
||||||
|
name="CinderVolumeTypes.create_and_update_encryption_type")
|
||||||
|
class CreateAndUpdateEncryptionType(cinder_utils.CinderBasic):
|
||||||
|
|
||||||
|
def run(self, create_provider=None, create_cipher=None,
|
||||||
|
create_key_size=None, create_control_location="front-end",
|
||||||
|
update_provider=None, update_cipher=None,
|
||||||
|
update_key_size=None, update_control_location=None):
|
||||||
|
"""Create and update encryption type
|
||||||
|
|
||||||
|
This scenario firstly creates a volume type, secondly creates an
|
||||||
|
encryption type for the volume type, thirdly updates the encryption
|
||||||
|
type.
|
||||||
|
|
||||||
|
:param create_provider: The class that provides encryption support. For
|
||||||
|
example, LuksEncryptor.
|
||||||
|
:param create_cipher: The encryption algorithm or mode.
|
||||||
|
:param create_key_size: Size of encryption key, in bits.
|
||||||
|
:param create_control_location: Notional service where encryption is
|
||||||
|
performed. Valid values are "front-end"
|
||||||
|
or "back-end."
|
||||||
|
:param update_provider: The class that provides encryption support. For
|
||||||
|
example, LuksEncryptor.
|
||||||
|
:param update_cipher: The encryption algorithm or mode.
|
||||||
|
:param update_key_size: Size of encryption key, in bits.
|
||||||
|
:param update_control_location: Notional service where encryption is
|
||||||
|
performed. Valid values are "front-end"
|
||||||
|
or "back-end."
|
||||||
|
"""
|
||||||
|
vt_idx = self.context["iteration"] % len(self.context["volume_types"])
|
||||||
|
volume_type = self.context["volume_types"][vt_idx]
|
||||||
|
create_specs = {
|
||||||
|
"provider": create_provider,
|
||||||
|
"cipher": create_cipher,
|
||||||
|
"key_size": create_key_size,
|
||||||
|
"control_location": create_control_location
|
||||||
|
}
|
||||||
|
update_specs = {
|
||||||
|
"provider": update_provider,
|
||||||
|
"cipher": update_cipher,
|
||||||
|
"key_size": update_key_size,
|
||||||
|
"control_location": update_control_location
|
||||||
|
}
|
||||||
|
self.admin_cinder.create_encryption_type(volume_type["id"],
|
||||||
|
specs=create_specs)
|
||||||
|
self.admin_cinder.update_encryption_type(volume_type["id"],
|
||||||
|
specs=update_specs)
|
||||||
|
@ -400,3 +400,14 @@ class BlockStorage(service.UnifiedService):
|
|||||||
must be deleted
|
must be deleted
|
||||||
"""
|
"""
|
||||||
self._impl.delete_encryption_type(volume_type)
|
self._impl.delete_encryption_type(volume_type)
|
||||||
|
|
||||||
|
@service.should_be_overridden
|
||||||
|
def update_encryption_type(self, volume_type, specs):
|
||||||
|
"""Update the encryption type information for the specified volume type.
|
||||||
|
|
||||||
|
:param volume_type: the volume type whose encryption type information
|
||||||
|
will be updated
|
||||||
|
:param specs: the encryption type specifications to update
|
||||||
|
:return: an instance of :class: VolumeEncryptionType
|
||||||
|
"""
|
||||||
|
return self._impl.update_encryption_type(volume_type, specs=specs)
|
||||||
|
@ -413,6 +413,19 @@ class CinderMixin(object):
|
|||||||
if (resp[0].status_code != 202):
|
if (resp[0].status_code != 202):
|
||||||
raise exceptions.EncryptionTypeDeleteException()
|
raise exceptions.EncryptionTypeDeleteException()
|
||||||
|
|
||||||
|
def update_encryption_type(self, volume_type, specs):
|
||||||
|
"""Update the encryption type information for the specified volume type.
|
||||||
|
|
||||||
|
:param volume_type: the volume type whose encryption type information
|
||||||
|
must be updated
|
||||||
|
:param specs: the encryption type specifications to update
|
||||||
|
:return: an instance of :class: VolumeEncryptionType
|
||||||
|
"""
|
||||||
|
aname = "cinder_v%s.update_encryption_type" % self.version
|
||||||
|
with atomic.ActionTimer(self, aname):
|
||||||
|
return self._get_client().volume_encryption_types.update(
|
||||||
|
volume_type, specs)
|
||||||
|
|
||||||
|
|
||||||
class UnifiedCinderMixin(object):
|
class UnifiedCinderMixin(object):
|
||||||
|
|
||||||
@ -633,3 +646,13 @@ class UnifiedCinderMixin(object):
|
|||||||
must be deleted
|
must be deleted
|
||||||
"""
|
"""
|
||||||
return self._impl.delete_encryption_type(volume_type)
|
return self._impl.delete_encryption_type(volume_type)
|
||||||
|
|
||||||
|
def update_encryption_type(self, volume_type, specs):
|
||||||
|
"""Update the encryption type information for the specified volume type.
|
||||||
|
|
||||||
|
:param volume_type: the volume type whose encryption type information
|
||||||
|
must be updated
|
||||||
|
:param specs: the encryption type specifications to update
|
||||||
|
:return: an instance of :class: VolumeEncryptionType
|
||||||
|
"""
|
||||||
|
return self._impl.update_encryption_type(volume_type, specs=specs)
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"CinderVolumeTypes.create_and_update_encryption_type": [
|
||||||
|
{
|
||||||
|
"args": {
|
||||||
|
"create_provider": "LuksEncryptor",
|
||||||
|
"create_cipher": "aes-xts-plain64",
|
||||||
|
"create_key_size": 512,
|
||||||
|
"create_control_location": "front-end",
|
||||||
|
"update_provider": "CryptsetupEncryptor",
|
||||||
|
"update_cipher": "aes-xts-plain",
|
||||||
|
"update_key_size": 256,
|
||||||
|
"update_control_location": "back-end"
|
||||||
|
},
|
||||||
|
"runner": {
|
||||||
|
"type": "constant",
|
||||||
|
"times": 4,
|
||||||
|
"concurrency": 1
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"users": {
|
||||||
|
"tenants": 2,
|
||||||
|
"users_per_tenant": 2
|
||||||
|
},
|
||||||
|
"volume_types": [
|
||||||
|
"test_type1",
|
||||||
|
"test_type2",
|
||||||
|
"test_type3",
|
||||||
|
"test_type4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"sla": {
|
||||||
|
"failure_rate": {
|
||||||
|
"max": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
CinderVolumeTypes.create_and_update_encryption_type:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
create_provider: "LuksEncryptor"
|
||||||
|
create_cipher: "aes-xts-plain64"
|
||||||
|
create_key_size: 512
|
||||||
|
create_control_location: "front-end"
|
||||||
|
update_provider: "CryptsetupEncryptor"
|
||||||
|
update_cipher: "aes-xts-plain"
|
||||||
|
update_key_size: 256
|
||||||
|
update_control_location: "back-end"
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 4
|
||||||
|
concurrency: 1
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 2
|
||||||
|
users_per_tenant: 2
|
||||||
|
volume_types: [
|
||||||
|
"test_type1",
|
||||||
|
"test_type2",
|
||||||
|
"test_type3",
|
||||||
|
"test_type4"
|
||||||
|
]
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
@ -224,3 +224,36 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
|
|||||||
mock_service.set_volume_type_keys.assert_called_once_with(
|
mock_service.set_volume_type_keys.assert_called_once_with(
|
||||||
mock_service.create_volume_type.return_value,
|
mock_service.create_volume_type.return_value,
|
||||||
metadata=volume_type_key)
|
metadata=volume_type_key)
|
||||||
|
|
||||||
|
def test_create_and_update_encryption_type(self):
|
||||||
|
mock_service = self.mock_cinder.return_value
|
||||||
|
context = self._get_context()
|
||||||
|
context.update({
|
||||||
|
"volume_types": [{"id": "fake_id",
|
||||||
|
"name": "fake_name"}],
|
||||||
|
"iteration": 1})
|
||||||
|
scenario = volume_types.CreateAndUpdateEncryptionType(
|
||||||
|
context)
|
||||||
|
|
||||||
|
create_specs = {
|
||||||
|
"provider": "create_prov",
|
||||||
|
"cipher": "create_cip",
|
||||||
|
"key_size": "create_ks",
|
||||||
|
"control_location": "create_cl"
|
||||||
|
}
|
||||||
|
update_specs = {
|
||||||
|
"provider": "update_prov",
|
||||||
|
"cipher": "update_cip",
|
||||||
|
"key_size": "update_ks",
|
||||||
|
"control_location": "update_cl"
|
||||||
|
}
|
||||||
|
scenario.run(create_provider="create_prov", create_cipher="create_cip",
|
||||||
|
create_key_size="create_ks",
|
||||||
|
create_control_location="create_cl",
|
||||||
|
update_provider="update_prov", update_cipher="update_cip",
|
||||||
|
update_key_size="update_ks",
|
||||||
|
update_control_location="update_cl")
|
||||||
|
mock_service.create_encryption_type.assert_called_once_with(
|
||||||
|
"fake_id", specs=create_specs)
|
||||||
|
mock_service.update_encryption_type.assert_called_once_with(
|
||||||
|
"fake_id", specs=update_specs)
|
||||||
|
@ -247,3 +247,10 @@ class BlockTestCase(test.TestCase):
|
|||||||
self.service.delete_encryption_type("type")
|
self.service.delete_encryption_type("type")
|
||||||
self.service._impl.delete_encryption_type.assert_called_once_with(
|
self.service._impl.delete_encryption_type.assert_called_once_with(
|
||||||
"type")
|
"type")
|
||||||
|
|
||||||
|
def test_update_encryption_type(self):
|
||||||
|
self.assertEqual(
|
||||||
|
self.service._impl.update_encryption_type.return_value,
|
||||||
|
self.service.update_encryption_type("type", specs=3))
|
||||||
|
self.service._impl.update_encryption_type.assert_called_once_with(
|
||||||
|
"type", specs=3)
|
||||||
|
@ -405,6 +405,21 @@ class CinderMixinTestCase(test.ScenarioTestCase):
|
|||||||
self.cinder.volume_encryption_types.delete.assert_called_once_with(
|
self.cinder.volume_encryption_types.delete.assert_called_once_with(
|
||||||
"type")
|
"type")
|
||||||
|
|
||||||
|
def test_update_encryption_type(self):
|
||||||
|
volume_type = mock.Mock()
|
||||||
|
specs = {
|
||||||
|
"provider": "foo_pro",
|
||||||
|
"cipher": "foo_cip",
|
||||||
|
"key_size": 512,
|
||||||
|
"control_location": "foo_con"
|
||||||
|
}
|
||||||
|
result = self.service.update_encryption_type(volume_type, specs)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
self.cinder.volume_encryption_types.update.return_value, result)
|
||||||
|
self.cinder.volume_encryption_types.update.assert_called_once_with(
|
||||||
|
volume_type, specs)
|
||||||
|
|
||||||
|
|
||||||
class FullUnifiedCinder(cinder_common.UnifiedCinderMixin,
|
class FullUnifiedCinder(cinder_common.UnifiedCinderMixin,
|
||||||
service.Service):
|
service.Service):
|
||||||
@ -633,3 +648,8 @@ class UnifiedCinderMixinTestCase(test.TestCase):
|
|||||||
self.service.delete_encryption_type("type")
|
self.service.delete_encryption_type("type")
|
||||||
self.service._impl.delete_encryption_type.assert_called_once_with(
|
self.service._impl.delete_encryption_type.assert_called_once_with(
|
||||||
"type")
|
"type")
|
||||||
|
|
||||||
|
def test_update_encryption_type(self):
|
||||||
|
self.service.update_encryption_type("type", specs=3)
|
||||||
|
self.service._impl.update_encryption_type.assert_called_once_with(
|
||||||
|
"type", specs=3)
|
||||||
|
Loading…
Reference in New Issue
Block a user