3 # pylint: disable=missing-docstring
10 from functest.utils import env
16 with open(pkg_resources.resource_filename(
17 'functest', 'ci/config_functest.yaml')) as yfile:
18 self.functest_yaml = yaml.safe_load(yfile)
19 except Exception as error:
21 'Parse config failed: {}'.format(str(error))) from 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:
63 'Parse config failed: {}'.format(str(error))) from error
67 CONF.patch_file(pkg_resources.resource_filename(
68 'functest', 'ci/config_patch.yaml'))
69 if env.get("POD_ARCH") in ['aarch64']:
70 CONF.patch_file(pkg_resources.resource_filename(
71 'functest', 'ci/config_aarch64_patch.yaml'))