summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddie Arrage <eddie.arrage@huawei.com>2018-02-08 15:10:28 -0800
committerEddie Arrage <eddie.arrage@huawei.com>2018-02-08 18:37:58 -0800
commit670362c0c12b3595591a824f633f8f3182554be9 (patch)
tree75d6864bc15fd81667ef77185c43642aaaff1278
parente57e40687c47c3a50ecaae43e153b2ca8981423c (diff)
Add ablity to config EXTERNAL_NETWORK in env_config.sh
- EXTERNAL_NETWORK env variable can be explicitly set - If set, the value will be used in Yardstack configuration - Otherwise, previous method of using output from 'openstack network list' will still be employed Change-Id: I9d8b4a69ff3f5093c034823cc95e92e151bfade6 Signed-off-by: Eddie Arrage <eddie.arrage@huawei.com>
-rw-r--r--dovetail/utils/dovetail_utils.py51
1 files changed, 28 insertions, 23 deletions
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index 87efa507..5c335679 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -133,30 +133,35 @@ def check_https_enabled(logger=None):
def get_ext_net_name(env_file, logger=None):
- https_enabled = check_https_enabled(logger)
- insecure_option = ''
- insecure = os.getenv('OS_INSECURE',)
- if https_enabled:
- logger.info("https enabled...")
- if insecure:
- if insecure.lower() == "true":
- insecure_option = ' --insecure '
- else:
- logger.warn("Env variable OS_INSECURE is {}, if https + no "
- "credential used, should be set as True."
- .format(insecure))
-
- cmd_check = "openstack %s network list" % insecure_option
- ret, msg = exec_cmd(cmd_check, logger)
- if ret:
- logger.error("The credentials info in {} is invalid.".format(env_file))
+ ext_net = os.getenv('EXTERNAL_NETWORK')
+ if ext_net:
+ return ext_net
+ else:
+ https_enabled = check_https_enabled(logger)
+ insecure_option = ''
+ insecure = os.getenv('OS_INSECURE',)
+ if https_enabled:
+ logger.info("https enabled...")
+ if insecure:
+ if insecure.lower() == "true":
+ insecure_option = ' --insecure '
+ else:
+ logger.warn("Env variable OS_INSECURE is {}, if https + "
+ "no credential used, should be set as True."
+ .format(insecure))
+
+ cmd_check = "openstack %s network list" % insecure_option
+ ret, msg = exec_cmd(cmd_check, logger)
+ if ret:
+ logger.error("The credentials info in {} is invalid."
+ .format(env_file))
+ return None
+ cmd = "openstack %s network list --long | grep 'External' | head -1 | \
+ awk '{print $4}'" % insecure_option
+ ret, msg = exec_cmd(cmd, logger)
+ if not ret:
+ return msg
return None
- cmd = "openstack %s network list --long | grep 'External' | head -1 | \
- awk '{print $4}'" % insecure_option
- ret, msg = exec_cmd(cmd, logger)
- if not ret:
- return msg
- return None
def store_db_results(db_url, build_tag, testcase, dest_file, logger):