diff options
author | 2016-11-03 07:40:28 +0000 | |
---|---|---|
committer | 2016-11-03 07:40:28 +0000 | |
commit | 976d8e0640e478c79002f402bbe9996955c02629 (patch) | |
tree | 3e1fbd26db7ecaa48a0f07c72942f87ab0fffc26 /dovetail/conf | |
parent | f3a4e6f6d05c970f79c1d33dba5ed77eb2f64a5a (diff) | |
parent | 4def3379f3513aa92b6df2f23551082ba7aa6ad4 (diff) |
Merge "dovetail tool: Add cli mechanism for changing envs at run-time"
Diffstat (limited to 'dovetail/conf')
-rw-r--r-- | dovetail/conf/cmd_config.yml | 45 | ||||
-rw-r--r-- | dovetail/conf/dovetail_config.py | 36 | ||||
-rw-r--r-- | dovetail/conf/dovetail_config.yml | 1 |
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 |