Start instances using fixed network when possible
Uses the fixed_network_name option to select which network
to boot test instances on. This allows Tempest to be run
in environments where there are multiple networks available.
This problem does not apply to nova-network environments because
it will happily start instances with multiple networks attached,
so the behavior is left as before in that case.
Co-Authored-By: Ben Nemec <bnemec@redhat.com>
Co-Authored-By: Vincent Untz <vuntz@suse.com>
Co-Authored-By: git-harry <git-harry@live.co.uk>
Change-Id: Ib5b84b59e3d182d8b9cc83954537c32f3eb9e388
Closes-Bug: #1250866
diff --git a/tempest/test.py b/tempest/test.py
index 19bae74..da936b4 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -32,6 +32,7 @@
from tempest import clients
from tempest.common import credentials
+from tempest.common import fixed_network
import tempest.common.generator.valid_generator as valid
from tempest import config
from tempest import exceptions
@@ -435,6 +436,21 @@
'subnet': subnet,
'dhcp': dhcp}
+ @classmethod
+ def get_tenant_network(cls):
+ """Get the network to be used in testing
+
+ :return: network dict including 'id' and 'name'
+ """
+ # Make sure isolated_creds exists and get a network client
+ networks_client = cls.get_client_manager().networks_client
+ isolated_creds = getattr(cls, 'isolated_creds', None)
+ if credentials.is_admin_available():
+ admin_creds = isolated_creds.get_admin_creds()
+ networks_client = clients.Manager(admin_creds).networks_client
+ return fixed_network.get_tenant_network(isolated_creds,
+ networks_client)
+
def assertEmpty(self, list, msg=None):
self.assertTrue(len(list) == 0, msg)