Support to specify the valid external network name 13/47513/2
authorLinda Wang <wangwulin@huawei.com>
Fri, 17 Nov 2017 02:00:21 +0000 (02:00 +0000)
committerCédric Ollivier <cedric.ollivier@orange.com>
Mon, 20 Nov 2017 14:14:25 +0000 (15:14 +0100)
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 <wangwulin@huawei.com>
(cherry picked from commit aa7109d038a86f6a19a9fb4af96bd1199cd81330)

functest/opnfv_tests/openstack/snaps/snaps_utils.py

index c3cd624..284e88b 100644 (file)
@@ -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 ""