Scenario : 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.

Change-Id: I64ad6ce6bee3fe33537ac4f8d8d913856fe46554
Partial-Bug: #1250866
This commit is contained in:
JordanP 2014-01-24 13:05:00 +00:00 committed by Ben Nemec
parent 405537895f
commit 9c052aade8
1 changed files with 21 additions and 0 deletions

View File

@ -290,6 +290,27 @@ class OfficialClientTest(tempest.test.BaseTestCase):
image = CONF.compute.image_ref
if flavor is None:
flavor = CONF.compute.flavor_ref
fixed_network_name = CONF.compute.fixed_network_name
if 'nics' not in create_kwargs and fixed_network_name:
networks = client.networks.list()
# If several networks found, set the NetID on which to connect the
# server to avoid the following error "Multiple possible networks
# found, use a Network ID to be more specific."
# See Tempest #1250866
if len(networks) > 1:
for network in networks:
if network.label == fixed_network_name:
create_kwargs['nics'] = [{'net-id': network.id}]
break
# If we didn't find the network we were looking for :
else:
msg = ("The network on which the NIC of the server must "
"be connected can not be found : "
"fixed_network_name=%s. Starting instance without "
"specifying a network.") % fixed_network_name
LOG.info(msg)
LOG.debug("Creating a server (name: %s, image: %s, flavor: %s)",
name, image, flavor)
server = client.servers.create(name, image, flavor, **create_kwargs)