summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/dovetail_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2017-03-17 09:23:45 +0000
committerxudan <xudan16@huawei.com>2017-03-21 01:34:24 +0000
commitf7d0d72958b41ea6685457abea6dc4d83f4370c3 (patch)
treeff367071b3f2223724ccbc6e34a4174c9a7d233c /dovetail/utils/dovetail_utils.py
parent3cf37c9ac7b40a388f81fed13cfb0ad606dcd9a1 (diff)
dovetail tool: remove installer and CI related variables
JIRA: DOVETAIL-371 1. remove all the envs in functest_config.yml and yardstick_config.yml 2. remove all relative cmds in cmd_config.yml 3. remove all the envs when running a new functest/yardstick container 4. add some variables just for functest pushing results to db 5. get the external network name for yardstick 6. make --debug/-d just control the log level shown on the screen 7. set requests=2.10.0 since python-openstackclient needs 'requests!=2.12.2,!=2.13.0,>=2.10.0' Change-Id: I9f941e09d067fc95a14c3c9be1374f41df4a9a16 Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/utils/dovetail_utils.py')
-rw-r--r--dovetail/utils/dovetail_utils.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index a54081f5..32d334e8 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -10,6 +10,8 @@
#
import sys
+import os
+import re
import subprocess
from collections import Mapping, Set, Sequence
@@ -96,6 +98,31 @@ def get_obj_by_path(obj, dst_path):
return obj
+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]})
+
+
+def get_ext_net_name(env_file, logger=None):
+ source_env(env_file)
+ cmd_check = "openstack network list"
+ 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}'"
+ ret, msg = exec_cmd(cmd, logger)
+ if not ret:
+ return msg
+ return None
+
+
def show_progress_bar(length):
max_len = 50
length %= max_len