Use an instance method instead of class method
There is an advantage to use an instance method, it allows using
addCleanup method, therefore, 'create_server' method will be responsible
for cleaning the server resource in the end of the test.
Change-Id: I59b8b52bb542741bbba779bac5c7ee01515211c1
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index ef28add..07b1a3f 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -169,14 +169,21 @@
except Exception:
pass
- @classmethod
- def create_server(cls, name, **kwargs):
- tenant_network = cls.get_tenant_network()
+ def create_server(self, name, wait_for_deletion=False, **kwargs):
+ tenant_network = self.get_tenant_network()
body, _ = compute.create_test_server(
- cls.os,
+ self.os,
tenant_network=tenant_network,
name=name,
**kwargs)
+
+ if wait_for_deletion:
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ waiters.wait_for_server_termination,
+ self.servers_client, body['id'])
+
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.servers_client.delete_server, body['id'])
return body