Add wait-for-server scenario methods to wraps waiters
This change was suggested during below code review[1]
when working on multicast test case.
[1] https://review.openstack.org/#/c/566103/12
Change-Id: Ie918e9588011ab291203e34939645c8235dfeea6
diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py
index 0a2fa14..b76a81a 100644
--- a/neutron_tempest_plugin/scenario/base.py
+++ b/neutron_tempest_plugin/scenario/base.py
@@ -218,9 +218,7 @@
key_name=self.keypair['name'],
networks=[{'uuid': self.network['id']}],
security_groups=[{'name': secgroup['security_group']['name']}])
- waiters.wait_for_server_status(self.os_primary.servers_client,
- self.server['server']['id'],
- constants.SERVER_STATUS_ACTIVE)
+ self.wait_for_server_active(self.server['server'])
self.port = self.client.list_ports(network_id=self.network['id'],
device_id=self.server[
'server']['id'])['ports'][0]
@@ -352,3 +350,25 @@
'result': 'expected' if result else 'unexpected'
})
return result
+
+ def wait_for_server_status(self, server, status, client=None, **kwargs):
+ """Waits for a server to reach a given status.
+
+ :param server: mapping having schema {'id': <server_id>}
+ :param status: string status to wait for (es: 'ACTIVE')
+ :param clien: servers client (self.os_primary.servers_client as
+ default value)
+ """
+
+ client = client or self.os_primary.servers_client
+ waiters.wait_for_server_status(client, server['id'], status, **kwargs)
+
+ def wait_for_server_active(self, server, client=None):
+ """Waits for a server to reach active status.
+
+ :param server: mapping having schema {'id': <server_id>}
+ :param clien: servers client (self.os_primary.servers_client as
+ default value)
+ """
+ self.wait_for_server_status(
+ server, constants.SERVER_STATUS_ACTIVE, client)