Merge "Add CinderVolumeTypes.create_volume_type_and_encryption_type"
This commit is contained in:
commit
e77b015fe4
@ -849,6 +849,26 @@
|
|||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
|
||||||
|
CinderVolumeTypes.create_volume_type_and_encryption_type:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
specs:
|
||||||
|
provider: "LuksEncryptor"
|
||||||
|
cipher: "aes-xts-plain64"
|
||||||
|
key_size: 512
|
||||||
|
control_location: "front-end"
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 5
|
||||||
|
concurrency: 2
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 2
|
||||||
|
users_per_tenant: 2
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
|
||||||
CinderVolumes.list_transfers:
|
CinderVolumes.list_transfers:
|
||||||
-
|
-
|
||||||
args:
|
args:
|
||||||
|
@ -455,7 +455,7 @@ class CinderVolumeBackup(base.ResourceManager):
|
|||||||
|
|
||||||
|
|
||||||
@base.resource("cinder", "volume_types", order=next(_cinder_order),
|
@base.resource("cinder", "volume_types", order=next(_cinder_order),
|
||||||
admin_required=True)
|
admin_required=True, perform_for_admin_only=True)
|
||||||
class CinderVolumeType(base.ResourceManager):
|
class CinderVolumeType(base.ResourceManager):
|
||||||
def list(self):
|
def list(self):
|
||||||
return [r for r in self._manager().list()
|
return [r for r in self._manager().list()
|
||||||
|
@ -442,3 +442,14 @@ class CinderScenario(scenario.OpenStackScenario):
|
|||||||
:rtype: VolumeTransfer
|
:rtype: VolumeTransfer
|
||||||
"""
|
"""
|
||||||
return self.clients("cinder").transfers.accept(transfer_id, auth_key)
|
return self.clients("cinder").transfers.accept(transfer_id, auth_key)
|
||||||
|
|
||||||
|
@atomic.action_timer("cinder.create_encryption_type")
|
||||||
|
def _create_encryption_type(self, volume_type, specs):
|
||||||
|
"""Create encryption type for a volume type. Default: admin only.
|
||||||
|
|
||||||
|
:param volume_type: the volume type on which to add an encryption type
|
||||||
|
:param specs: the encryption type specifications to add
|
||||||
|
:return: an instance of :class: VolumeEncryptionType
|
||||||
|
"""
|
||||||
|
return self.admin_clients("cinder").volume_encryption_types.create(
|
||||||
|
volume_type, specs)
|
||||||
|
@ -35,3 +35,24 @@ class CreateAndDeleteVolumeType(cinder_utils.CinderScenario):
|
|||||||
"""
|
"""
|
||||||
volume_type = self._create_volume_type(**kwargs)
|
volume_type = self._create_volume_type(**kwargs)
|
||||||
self._delete_volume_type(volume_type)
|
self._delete_volume_type(volume_type)
|
||||||
|
|
||||||
|
|
||||||
|
@validation.required_services(consts.Service.CINDER)
|
||||||
|
@validation.required_openstack(admin=True)
|
||||||
|
@scenario.configure(context={"admin_cleanup": ["cinder"]},
|
||||||
|
name="CinderVolumeTypes.create_volume_type"
|
||||||
|
"_and_encryption_type")
|
||||||
|
class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderScenario):
|
||||||
|
|
||||||
|
def run(self, specs, **kwargs):
|
||||||
|
"""Create encryption type
|
||||||
|
|
||||||
|
This scenario first creates a volume type, then creates an encryption
|
||||||
|
type for the volume type.
|
||||||
|
|
||||||
|
:param specs: the encryption type specifications to add
|
||||||
|
:param kwargs: Optional parameters used during volume
|
||||||
|
type creation.
|
||||||
|
"""
|
||||||
|
volume_type = self._create_volume_type(**kwargs)
|
||||||
|
self._create_encryption_type(volume_type, specs)
|
||||||
|
30
samples/tasks/scenarios/cinder/create-encryption-type.json
Normal file
30
samples/tasks/scenarios/cinder/create-encryption-type.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"CinderVolumeTypes.create_volume_type_and_encryption_type": [
|
||||||
|
{
|
||||||
|
"args": {
|
||||||
|
"specs": {
|
||||||
|
"provider": "LuksEncryptor",
|
||||||
|
"cipher": "aes-xts-plain64",
|
||||||
|
"key_size": 512,
|
||||||
|
"control_location": "front-end"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runner": {
|
||||||
|
"type": "constant",
|
||||||
|
"times": 5,
|
||||||
|
"concurrency": 2
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"users": {
|
||||||
|
"tenants": 2,
|
||||||
|
"users_per_tenant": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sla": {
|
||||||
|
"failure_rate": {
|
||||||
|
"max": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
20
samples/tasks/scenarios/cinder/create-encryption-type.yaml
Normal file
20
samples/tasks/scenarios/cinder/create-encryption-type.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
CinderVolumeTypes.create_volume_type_and_encryption_type:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
specs:
|
||||||
|
provider: "LuksEncryptor"
|
||||||
|
cipher: "aes-xts-plain64"
|
||||||
|
key_size: 512
|
||||||
|
control_location: "front-end"
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 5
|
||||||
|
concurrency: 2
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 2
|
||||||
|
users_per_tenant: 2
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
@ -259,6 +259,9 @@ class Cinder(ResourceManager):
|
|||||||
def list_volume_types(self):
|
def list_volume_types(self):
|
||||||
return self.client.volume_types.list()
|
return self.client.volume_types.list()
|
||||||
|
|
||||||
|
def list_encryption_types(self):
|
||||||
|
return self.client.volume_encryption_types.list()
|
||||||
|
|
||||||
def list_transfers(self):
|
def list_transfers(self):
|
||||||
return self.client.transfers.list()
|
return self.client.transfers.list()
|
||||||
|
|
||||||
|
@ -381,6 +381,25 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||||
"cinder.create_volume_type")
|
"cinder.create_volume_type")
|
||||||
|
|
||||||
|
def test__create_encryption_type(self):
|
||||||
|
volume_type = mock.Mock()
|
||||||
|
specs = {
|
||||||
|
"provider": "foo_pro",
|
||||||
|
"cipher": "foo_cip",
|
||||||
|
"key_size": 512,
|
||||||
|
"control_location": "foo_con"
|
||||||
|
}
|
||||||
|
result = self.scenario._create_encryption_type(volume_type, specs)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
self.admin_clients(
|
||||||
|
"cinder").volume_encryption_types.create.return_value, result)
|
||||||
|
self.admin_clients(
|
||||||
|
"cinder").volume_encryption_types.create.assert_called_once_with(
|
||||||
|
volume_type, specs)
|
||||||
|
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||||
|
"cinder.create_encryption_type")
|
||||||
|
|
||||||
def test__delete_volume_type(self):
|
def test__delete_volume_type(self):
|
||||||
volume_type = mock.Mock()
|
volume_type = mock.Mock()
|
||||||
self.scenario._delete_volume_type(volume_type)
|
self.scenario._delete_volume_type(volume_type)
|
||||||
|
@ -33,3 +33,13 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
|
|||||||
fakeargs="fakeargs")
|
fakeargs="fakeargs")
|
||||||
scenario._delete_volume_type.assert_called_once_with(
|
scenario._delete_volume_type.assert_called_once_with(
|
||||||
scenario._create_volume_type.return_value)
|
scenario._create_volume_type.return_value)
|
||||||
|
|
||||||
|
def test_create_volume_type_and_encryption_type(self):
|
||||||
|
scenario = volume_types.CreateVolumeTypeAndEncryptionType(self.context)
|
||||||
|
scenario._create_volume_type = mock.Mock()
|
||||||
|
scenario._create_encryption_type = mock.Mock()
|
||||||
|
scenario.run(specs="fakespecs", fakeargs="fakeargs")
|
||||||
|
scenario._create_volume_type.assert_called_once_with(
|
||||||
|
fakeargs="fakeargs")
|
||||||
|
scenario._create_encryption_type.assert_called_once_with(
|
||||||
|
scenario._create_volume_type.return_value, "fakespecs")
|
||||||
|
Loading…
Reference in New Issue
Block a user