aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2017-03-01 07:34:35 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-01 07:34:35 +0000
commita0dc5207a309c11d061aa20fcdca62bf7462184c (patch)
tree9bc25c686a5df90b947f0e052ffa57ecc9a46480 /functest/utils
parent70d831aac0f77165f088bcf6385cd4ac74e7cd16 (diff)
parent1c6be9eaea0b2c13e056e2459cfba2b18c887c03 (diff)
Merge "config_functest support muiltilevel query"
Diffstat (limited to 'functest/utils')
-rwxr-xr-x[-rw-r--r--]functest/utils/config.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/functest/utils/config.py b/functest/utils/config.py
index 84166c1d..b5b84501 100644..100755
--- a/functest/utils/config.py
+++ b/functest/utils/config.py
@@ -2,26 +2,25 @@ import os
import yaml
+import env
+
class Config(object):
def __init__(self):
- if 'CONFIG_FUNCTEST_YAML' not in os.environ:
- raise Exception('CONFIG_FUNCTEST_YAML not configed')
- self.config_functest = os.environ['CONFIG_FUNCTEST_YAML']
try:
- with open(self.config_functest) as f:
+ with open(env.ENV.CONFIG_FUNCTEST_YAML) as f:
self.functest_yaml = yaml.safe_load(f)
self._parse(None, self.functest_yaml)
- except:
- raise Exception('Parse {} failed'.format(self.config_functest))
+ except Exception as error:
+ raise Exception('Parse config failed: {}'.format(str(error)))
self._set_others()
def _parse(self, attr_now, left_parametes):
for param_n, param_v in left_parametes.iteritems():
attr_further = self._get_attr_further(attr_now, param_n)
- if not isinstance(param_v, dict):
+ if attr_further:
self.__setattr__(attr_further, param_v)
- else:
+ if isinstance(param_v, dict):
self._parse(attr_further, param_v)
def _get_attr_further(self, attr_now, next):
@@ -33,3 +32,8 @@ class Config(object):
CONF = Config()
+
+if __name__ == "__main__":
+ print CONF.vnf_cloudify_ims
+ print CONF.vnf_cloudify_ims_tenant_images
+ print CONF.vnf_cloudify_ims_tenant_images_centos_7