3 # pylint: disable=missing-docstring
10 from functest.utils import env
16 # pylint: disable=bad-continuation
17 with open(pkg_resources.resource_filename(
18 'functest', 'ci/config_functest.yaml')) as yfile:
19 self.functest_yaml = yaml.safe_load(yfile)
20 except Exception as error:
21 raise Exception('Parse config failed: {}'.format(str(error)))
24 def _merge_dicts(dict1, dict2):
25 for k in set(dict1.keys()).union(dict2.keys()):
26 if k in dict1 and k in dict2:
27 if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
28 yield (k, dict(Config._merge_dicts(dict1[k], dict2[k])))
36 def patch_file(self, patch_file_path):
37 with open(patch_file_path) as yfile:
38 patch_file = yaml.safe_load(yfile)
40 for key in patch_file:
41 if key in env.get('DEPLOY_SCENARIO'):
42 self.functest_yaml = dict(Config._merge_dicts(
43 self.functest_yaml, patch_file[key]))
45 def _parse(self, attr_now, left_parametes):
46 for param_n, param_v in six.iteritems(left_parametes):
47 attr_further = self._get_attr_further(attr_now, param_n)
49 setattr(self, attr_further, param_v)
50 if isinstance(param_v, dict):
51 self._parse(attr_further, param_v)
54 def _get_attr_further(attr_now, next): # pylint: disable=redefined-builtin
55 return attr_now if next == 'general' else (
56 '{}_{}'.format(attr_now, next) if attr_now else next)
60 self._parse(None, self.functest_yaml)
61 except Exception as error:
62 raise Exception('Parse config failed: {}'.format(str(error)))
66 CONF.patch_file(pkg_resources.resource_filename(
67 'functest', 'ci/config_patch.yaml'))
68 if env.get("POD_ARCH") in ['aarch64']:
69 CONF.patch_file(pkg_resources.resource_filename(
70 'functest', 'ci/config_aarch64_patch.yaml'))