summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhongbo tian <hongbo.tianhongbo@huawei.com>2017-06-09 09:29:49 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-06-09 09:29:49 +0000
commit2a41e07a0cf9585a88bf6f593ac6fba1d284c7ec (patch)
treee8b0165a30b180f286f320301fae8d46abfa85f2
parentd40ffffeb0fc4aea0dc5d1cfac2c7be1f94b8392 (diff)
parent3c44bdaf0bd2ca26253c77e0280cd4dc77add19f (diff)
Merge "https + no credential support"
-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