From 3c44bdaf0bd2ca26253c77e0280cd4dc77add19f Mon Sep 17 00:00:00 2001 From: MatthewLi Date: Wed, 7 Jun 2017 21:21:48 -0400 Subject: https + no credential support JIRA: DOVETAIL-440 Change-Id: I2bb430de040127dea493e8bb5423ad8204f799e2 Signed-off-by: MatthewLi --- dovetail/utils/dovetail_utils.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'dovetail/utils') diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py index e6a775f1..ae969408 100644 --- a/dovetail/utils/dovetail_utils.py +++ b/dovetail/utils/dovetail_utils.py @@ -111,21 +111,29 @@ def source_env(env_file): with open(env_file, 'r') as f: lines = f.readlines() for line in lines: - for match in re.findall(r"export (.*)=(.*)", line): - match = (match[0].strip('\"'), match[1].strip('\"')) - match = (match[0].strip('\''), match[1].strip('\'')) - os.environ.update({match[0]: match[1]}) + if line.lstrip().startswith('export'): + for match in re.findall(r"export (.*)=(.*)", line): + match = (match[0].strip('\"'), match[1].strip('\"')) + match = (match[0].strip('\''), match[1].strip('\'')) + os.environ.update({match[0]: match[1]}) def get_ext_net_name(env_file, logger=None): - source_env(env_file) - cmd_check = "openstack network list" + insecure_option = '' + insecure = os.getenv('OS_INSECURE',) + if insecure == "true": + insecure_option = ' --insecure ' + else: + print "Warn: env variable OS_INSECUE is %s, if https+no credential \ + used, it should be set as true" % insecure + + cmd_check = "openstack %s network list" % insecure_option ret, msg = exec_cmd(cmd_check, logger) if ret: logger.error("The credentials info in %s is invalid." % env_file) return None - cmd = "openstack network list --long | grep 'External' | head -1 | \ - awk '{print $4}'" + 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 -- cgit 1.2.3-korg