diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-05-05 19:07:42 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-05-05 19:28:27 +0200 |
commit | 8cf94642d8e41af5b23892323528aaab0e087a83 (patch) | |
tree | c22943fec0aa0bf14fa2852b0d7a5f6f35fa2a6a /functest/utils | |
parent | 9fb702111ae63824a2e293d327437d0486a565d2 (diff) |
Implement get_external_network via shade
It fixes the current issues as EXTERNAL_NETWORK is mainly unset by
all Installers [1].
[1] https://build.opnfv.org/ci/view/functest/job/functest-fuel-armband-baremetal-arm-daily-fraser/31/console
Change-Id: I8ee62623701c15b9ff962d0a0e07a77934ff03ac
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/utils')
-rw-r--r-- | functest/utils/functest_utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py index b614af321..b860828f1 100644 --- a/functest/utils/functest_utils.py +++ b/functest/utils/functest_utils.py @@ -15,6 +15,8 @@ import subprocess import sys import yaml +from functest.utils import env + LOGGER = logging.getLogger(__name__) @@ -72,3 +74,20 @@ def get_parameter_from_yaml(parameter, yfile): raise ValueError("The parameter %s is not defined in" " %s" % (parameter, yfile)) return value + + +def get_external_network(cloud): + """ + Returns the configured external network name or + the first retrieved external network name + """ + assert cloud + if env.get("EXTERNAL_NETWORK"): + network = cloud.get_network( + env.get("EXTERNAL_NETWORK"), {"router:external": True}) + if network: + return network + networks = cloud.list_networks({"router:external": True}) + if networks: + return networks[0] + return None |