diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-12-09 16:00:45 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-12-15 17:04:39 +0800 |
commit | 5721693e13fe1495541fdd14d9d5e3aed28ef042 (patch) | |
tree | 4fc6fa462065ac121d9758e156c54eb15fdb3df6 /functest/utils/env.py | |
parent | ed96a8b6e3440a85d9047b37207b161d3ea37f2b (diff) |
Unified way to provide configurations and env variables(proposal 1)
In this proposal, everything in os.environ can be accessed directly using const,
and with the exact name os.environ defined.
The name of a configuration is totally decided by config_functest.yaml,
which is the joint name of each level with '_'.
This version requires us to naming each level in yaml in a little cleancode way,
or else the configuration name would become ugly. Let me take the current
defination of general.directories as instance, the configuration name will be
'directories_dir_repo_functest', looks not very good. But if we make some adaption:
general:
dir:
repo_functest:
it will become 'dir_repo_functest', looks a little better.
For vIMs is well defined, let me take it for example, the configuration names will look like:
vIMS_clearwater_blueprint_url
vIMS_clearwater_blueprint_file_name
vIMS_clearwater_blueprint_name
vIMS_clearwater_blueprint_branch
vIMS_clearwater_blueprint_destination_folder
vIMS_clearwater_deployment-name
Change-Id: I18ec8686d9cfb2b80a370d422c6ad81a8800585c
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'functest/utils/env.py')
-rw-r--r-- | functest/utils/env.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/functest/utils/env.py b/functest/utils/env.py new file mode 100644 index 00000000..b6af767d --- /dev/null +++ b/functest/utils/env.py @@ -0,0 +1,18 @@ +import os + +default_envs = { + 'NODE_NAME': 'unknown_pod', + 'CI_DEBUG': 'true' +} + + +class Environment(object): + def __init__(self): + for k, v in os.environ.iteritems(): + self.__setattr__(k, v) + for k, v in default_envs.iteritems(): + if k not in os.environ: + self.__setattr__(k, v) + + +ENV = Environment() |