summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthewLi <matthew.lijun@huawei.com>2017-06-07 21:21:48 -0400
committerMatthewLi <matthew.lijun@huawei.com>2017-06-09 05:19:02 -0400
commit3c44bdaf0bd2ca26253c77e0280cd4dc77add19f (patch)
treeebb5941c23f32b9bc9325c5a05f1a7f4bcaef5fd
parent2c170360711d8307ffab3fe8070a771650e4fd47 (diff)
https + no credential support
JIRA: DOVETAIL-440 Change-Id: I2bb430de040127dea493e8bb5423ad8204f799e2 Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
-rw-r--r--dovetail/utils/dovetail_utils.py24
1 files changed, 16 insertions, 8 deletions
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