summaryrefslogtreecommitdiffstats
path: root/dovetail/conf
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2016-12-02 08:58:16 +0000
committerxudan <xudan16@huawei.com>2016-12-14 02:43:19 +0000
commit05d995655dd07dfb72191c66e2c1c5177925dd5c (patch)
tree58eb529aae0ea084e983ebb293898b17ce0658e9 /dovetail/conf
parent4cc82a8477e7b842e83281c72127a73da73edf1d (diff)
dovetail tool: improve cli to update non-envs automatically
1. modify cmd_config.yml a. change 'env' and 'non-env' into 'config' and 'control' b. add subsection 'path' for each block in 'config' c. delete 'DEPLOY_SCENARIO' and 'DEPLOY_TYPE' d. use 'func_tag' and 'yard_tag' to control container's tag 2. if cmd in config a. if its path is envs, it will be used to update envs in dovetail_config b. if its path is non_envs, it will be used to update other value in the dict JIRA: DOVETAIL-70 Change-Id: I1cf9bfcd1a19294a390a85bce6e458ce50672b7f Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/conf')
-rw-r--r--dovetail/conf/cmd_config.yml49
-rw-r--r--dovetail/conf/dovetail_config.py52
-rw-r--r--dovetail/conf/dovetail_config.yml14
3 files changed, 88 insertions, 27 deletions
diff --git a/dovetail/conf/cmd_config.yml b/dovetail/conf/cmd_config.yml
index 35c000ef..e2159ca7 100644
--- a/dovetail/conf/cmd_config.yml
+++ b/dovetail/conf/cmd_config.yml
@@ -1,42 +1,58 @@
cli:
arguments:
- envs:
+ config:
# 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:
+ # path:
+ # - 'functest/docker_tag'
+ # - 'yardstick/docker_tag'
+ control:
options:
- envs:
+ config:
SUT_TYPE:
flags:
- '--SUT_TYPE'
- '-t'
+ path:
+ - 'functest/envs'
+ - 'yardstick/envs'
help: 'Installer type of the system under test (SUT).'
SUT_IP:
flags:
- '--SUT_IP'
- '-i'
+ path:
+ - 'functest/envs'
+ - 'yardstick/envs'
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).'
CON_DEBUG:
flags:
- '--CON_DEBUG'
- '-c'
+ path:
+ - 'functest/envs'
+ - 'yardstick/envs'
help: 'True for showing debug log in functest/yardstick container.'
- non-envs:
+ yard_tag:
+ flags:
+ - '--yard_tag'
+ - '-y'
+ path:
+ - 'yardstick/docker_tag'
+ help: 'Overwrite tag for yardstick docker container (e.g. stable or latest)'
+ func_tag:
+ flags:
+ - '--func_tag'
+ - '-f'
+ path:
+ - 'functest/docker_tag'
+ help: 'Overwrite tag for functest docker container (e.g. stable or latest)'
+ control:
testsuite:
flags:
- '--testsuite'
@@ -47,11 +63,6 @@ cli:
- '--testarea'
default: 'full'
help: 'compliance testarea within testsuite'
- tag:
- flags:
- - '--tag'
- - '-o'
- help: 'Overwrite tags for each docker container (e.g. "functest:stable,yardstick:latest")'
debug:
flags:
- '--debug'
diff --git a/dovetail/conf/dovetail_config.py b/dovetail/conf/dovetail_config.py
index 6cf3f7af..1087bdc5 100644
--- a/dovetail/conf/dovetail_config.py
+++ b/dovetail/conf/dovetail_config.py
@@ -43,15 +43,40 @@ class DovetailConfig:
key = cmd_name.upper()
return cls.CMD_NAME_TRANS.get(key, key)
+ # Analyze the kind of the giving path,
+ # return true for env path,
+ # return false for non_env path.
@classmethod
- def update_envs(cls, options):
- for item in options:
- key = cls.cmd_name_trans(item)
- if not options[item] and key in os.environ:
- options[item] = os.environ[key]
- if options[item]:
- cls.update_config_envs('functest', key, options[item])
- cls.update_config_envs('yardstick', key, options[item])
+ def is_env_path(cls, path):
+ if len(path) == 2:
+ test_project = cls.dovetail_config['test_project']
+ if path[0] in test_project and path[1] == 'envs':
+ return True
+ else:
+ return False
+
+ # update dovetail_config dict with the giving path.
+ # if path is in the dovetail_config dict, its value will be replaced.
+ # if path is not in the dict, it will be added as a new item of the dict.
+ @classmethod
+ def update_config(cls, config_dict):
+ for key, value in config_dict.items():
+ path_list = []
+ for item in value['path']:
+ path_list.append([(k.strip()) for k in item.split('/')])
+ for path in path_list:
+ if cls.is_env_path(path):
+ cls.update_envs(key, path, value['value'])
+ else:
+ cls.update_non_envs(path, value['value'])
+
+ @classmethod
+ def update_envs(cls, key, path, value):
+ key = cls.cmd_name_trans(key)
+ if not value and key in os.environ:
+ value = os.environ[key]
+ if value:
+ cls.update_config_envs(path[0], key, value)
@classmethod
def update_config_envs(cls, validate_type, key, value):
@@ -63,3 +88,14 @@ class DovetailConfig:
envs = envs.replace(old_value[0][0], value)
cls.dovetail_config[validate_type]['envs'] = envs
return envs
+
+ @staticmethod
+ def set_leaf_dict(dic, path, value):
+ for key in path[:-1]:
+ dic = dic.setdefault(key, {})
+ dic[path[-1]] = value
+
+ @classmethod
+ def update_non_envs(cls, path, value):
+ if value:
+ cls.set_leaf_dict(cls.dovetail_config, path, value)
diff --git a/dovetail/conf/dovetail_config.yml b/dovetail/conf/dovetail_config.yml
index 5264f140..86ac6cf6 100644
--- a/dovetail/conf/dovetail_config.yml
+++ b/dovetail/conf/dovetail_config.yml
@@ -32,4 +32,18 @@ include_config:
- functest_config.yml
- yardstick_config.yml
+test_project:
+ - 'yardstick'
+ - 'functest'
+
+validate_input:
+ valid_sut_type:
+ - 'compass'
+ - 'fuel'
+ - 'joid'
+ - 'apex'
+
+ valid_docker_tag:
+ - 'stable'
+ - 'latest'