Add create_volume_type

Change-Id: I523794931dcae14306a6db28f863fd1c34927448
This commit is contained in:
licanwei 2019-01-24 15:10:13 +08:00
parent 98c646bed5
commit 2985dba804
1 changed files with 17 additions and 0 deletions

View File

@ -222,3 +222,20 @@ class ScenarioTest(tempest.test.BaseTestCase):
volume['id'], 'available')
volume = volumes_client.show_volume(volume['id'])['volume']
return volume
def create_volume_type(self, clients=None, name=None, backend_name=None):
if clients is None:
clients = self.os_primary
if name is None:
class_name = self.__class__.__name__
name = data_utils.rand_name(class_name + '-volume-type')
volumes_client = clients.volumes_client_latest
extra_specs = {}
if backend_name:
extra_specs = {"volume_backend_name": backend_name}
volume_type = volumes_client.create_volume_type(
name=name, extra_specs=extra_specs)['volume_type']
self.addCleanup(volumes_client.delete_volume_type, volume_type['id'])
return volume_type