From: Linda Wang Date: Fri, 17 Nov 2017 02:00:21 +0000 (+0000) Subject: Support to specify the valid external network name X-Git-Tag: opnfv-6.0.0~315^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=aa7109d038a86f6a19a9fb4af96bd1199cd81330;p=functest.git Support to specify the valid external network name In some deployments, the retrieved external network by the def get_external_networks in Snaps checked by "router:external" is not available. So it is necessary to specify the available external network as an env by user. Change-Id: I333e91dd106ed307541a9a197280199fde86bd30 Signed-off-by: Linda Wang --- diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py index c3cd6245e..284e88b51 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py @@ -5,17 +5,25 @@ # # http://www.apache.org/licenses/LICENSE-2.0 +from functest.utils.constants import CONST + from snaps.openstack.utils import neutron_utils, nova_utils def get_ext_net_name(os_creds): """ - Returns the first external network name + Returns the configured external network name or + the first retrieved external network name :param: os_creds: an instance of snaps OSCreds object :return: """ neutron = neutron_utils.neutron_client(os_creds) ext_nets = neutron_utils.get_external_networks(neutron) + if (hasattr(CONST, 'EXTERNAL_NETWORK')): + extnet_config = CONST.__getattribute__('EXTERNAL_NETWORK') + for ext_net in ext_nets: + if ext_net.name == extnet_config: + return extnet_config return ext_nets[0].name if ext_nets else ""