From 2985dba80461e280a6ddb8990b95401966dc84d4 Mon Sep 17 00:00:00 2001
From: licanwei
Date: Thu, 24 Jan 2019 15:10:13 +0800
Subject: [PATCH] Add create_volume_type
Change-Id: I523794931dcae14306a6db28f863fd1c34927448
---
.../tests/scenario/manager.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/watcher_tempest_plugin/tests/scenario/manager.py b/watcher_tempest_plugin/tests/scenario/manager.py
index 68e9332..3f5a11e 100644
--- a/watcher_tempest_plugin/tests/scenario/manager.py
+++ b/watcher_tempest_plugin/tests/scenario/manager.py
@@ -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