From 1c3cf9de8106ab9c1e707929385ecc7bf2974387 Mon Sep 17 00:00:00 2001 From: Linda Wang Date: Thu, 17 Aug 2017 12:07:30 +0000 Subject: Specify valid external network as an env In some deployments, the retrieved external network by the def get_external_net checked by "router:external" is not available. So it is necessary to specify the available external network as an env by user for some deployments. JIRA: FUNCTEST-865 Change-Id: I561bc7d57e06214516a4cdbebd67632cd9746fba Signed-off-by: Linda Wang --- functest/utils/openstack_utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'functest/utils/openstack_utils.py') diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index 335f14cd1..8b59c9547 100644 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -22,8 +22,8 @@ from heatclient import client as heatclient from novaclient import client as novaclient from keystoneclient import client as keystoneclient from neutronclient.neutron import client as neutronclient -from functest.utils.constants import CONST +from functest.utils.constants import CONST import functest.utils.functest_utils as ft_utils logger = logging.getLogger(__name__) @@ -713,6 +713,8 @@ def get_private_net(neutron_client): def get_external_net(neutron_client): + if (hasattr(CONST, 'EXTERNAL_NETWORK')): + return CONST.__getattribute__('EXTERNAL_NETWORK') for network in neutron_client.list_networks()['networks']: if network['router:external']: return network['name'] @@ -720,6 +722,11 @@ def get_external_net(neutron_client): def get_external_net_id(neutron_client): + if (hasattr(CONST, 'EXTERNAL_NETWORK')): + networks = neutron_client.list_networks( + name=CONST.__getattribute__('EXTERNAL_NETWORK')) + net_id = networks['networks'][0]['id'] + return net_id for network in neutron_client.list_networks()['networks']: if network['router:external']: return network['id'] -- cgit 1.2.3-korg