summaryrefslogtreecommitdiffstats
path: root/dovetail/conf
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2016-10-21 08:03:43 +0000
committerxudan <xudan16@huawei.com>2016-11-02 09:05:23 +0000
commit4def3379f3513aa92b6df2f23551082ba7aa6ad4 (patch)
tree5e3279f125bc34b32f7d71cc3a18a78cad37b8ff /dovetail/conf
parentd8c7fcfd3dd2bf331ca65ca41b593d65e4c0d97a (diff)
dovetail tool: Add cli mechanism for changing envs at run-time
JIRA: DOVETAIL-23 1. Add file cmd_config.yml for defining arguments and options. 2. Using python click module to add and parse cmds in cmd_config.yml 3. Using envs options to update envs in yardstick/functest config file Change-Id: Ie513c0f0a1ed76f29408419a4bcbbcf21334bb3f Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/conf')
-rw-r--r--dovetail/conf/cmd_config.yml45
-rw-r--r--dovetail/conf/dovetail_config.py36
-rw-r--r--dovetail/conf/dovetail_config.yml1
3 files changed, 82 insertions, 0 deletions
diff --git a/dovetail/conf/cmd_config.yml b/dovetail/conf/cmd_config.yml
new file mode 100644
index 00000000..63d51ed0
--- /dev/null
+++ b/dovetail/conf/cmd_config.yml
@@ -0,0 +1,45 @@
+cli:
+ arguments:
+ envs:
+ # This is a simple example of arguments.
+ # Dovetail has no need of this kind of parameters currently.
+ # The arguments must be given orderly at the run-time.
+ #
+ # docker_tag:
+ # flags: 'docker_tag'
+ non-envs:
+
+ options:
+ envs:
+ SUT_TYPE:
+ flags:
+ - '--SUT_TYPE'
+ - '-t'
+ help: 'Installer type of the system under test (SUT).'
+ SUT_IP:
+ flags:
+ - '--SUT_IP'
+ - '-i'
+ help: 'IP of the system under test (SUT).'
+ DEPLOY_SCENARIO:
+ flags:
+ - '--DEPLOY_SCENARIO'
+ - '-S'
+ help: 'DEPLOY_SCENARIO of the system under test (SUT).'
+ DEPLOY_TYPE:
+ flags:
+ - '--DEPLOY_TYPE'
+ - '-T'
+ help: 'DEPLOY_TYPE of the system under test (SUT).'
+ CI_DEBUG:
+ flags:
+ - '--CI_DEBUG'
+ - '-d'
+ help: 'CI_DEBUG for showing debug log.'
+ non-envs:
+ scenario:
+ flags:
+ - '--scenario'
+ - '-s'
+ default: 'basic'
+ help: 'certification scenario.'
diff --git a/dovetail/conf/dovetail_config.py b/dovetail/conf/dovetail_config.py
index 6f3eebf2..03d0bb78 100644
--- a/dovetail/conf/dovetail_config.py
+++ b/dovetail/conf/dovetail_config.py
@@ -9,6 +9,7 @@
import yaml
import os
+import re
CERT_PATH = './cert/'
TESTCASE_PATH = './testcase/'
@@ -27,3 +28,38 @@ container_config = {}
container_config['functest'] = dovetail_config['functest']
container_config['yardstick'] = dovetail_config['yardstick']
+
+
+with open(os.path.join(curr_path, dovetail_config['cli_file_name'])) as f:
+ cmd_yml = yaml.safe_load(f)
+ dovetail_config['cli'] = cmd_yml[cmd_yml.keys()[0]]
+
+
+def cmd_name_trans(cmd_name):
+ key = cmd_name.upper()
+ if key == 'SUT_TYPE':
+ key = 'INSTALLER_TYPE'
+ if key == 'SUT_IP':
+ key = 'INSTALLER_IP'
+ return key
+
+
+def update_envs(options):
+ for item in options:
+ if options[item] is not None:
+ key = cmd_name_trans(item)
+ os.environ[key] = options[item]
+ update_config_envs('functest', key)
+ update_config_envs('yardstick', key)
+
+
+def update_config_envs(script_type, key):
+ old_value = re.findall(r'\s+%s=(.*?)(\s+|$)' % key,
+ dovetail_config[script_type]['envs'])
+ if old_value == []:
+ dovetail_config[script_type]['envs'] += \
+ ' -e ' + key + '=' + os.environ[key]
+ else:
+ dovetail_config[script_type]['envs'] = \
+ dovetail_config[script_type]['envs'].replace(old_value[0][0],
+ os.environ[key])
diff --git a/dovetail/conf/dovetail_config.yml b/dovetail/conf/dovetail_config.yml
index 901988f8..1f5de672 100644
--- a/dovetail/conf/dovetail_config.yml
+++ b/dovetail/conf/dovetail_config.yml
@@ -2,6 +2,7 @@
work_dir: /home/opnfv/dovetail
result_dir: /home/opnfv/dovetail/results
report_file: 'dovetail_report.txt'
+cli_file_name: 'cmd_config.yml'
# used for testcase cmd template in jinja2 format
# we have two variables available now