3 # pylint: disable=missing-docstring
15 with open(pkg_resources.resource_filename(
16 'functest', 'ci/config_functest.yaml')) as yfile:
17 self.functest_yaml = yaml.safe_load(yfile)
18 except Exception as error:
19 raise Exception('Parse config failed: {}'.format(str(error)))
22 def _merge_dicts(dict1, dict2):
23 for k in set(dict1.keys()).union(dict2.keys()):
24 if k in dict1 and k in dict2:
25 if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
26 yield (k, dict(Config._merge_dicts(dict1[k], dict2[k])))
34 def patch_file(self, patch_file_path):
35 with open(patch_file_path) as yfile:
36 patch_file = yaml.safe_load(yfile)
38 for key in patch_file:
39 if key in os.environ.get('DEPLOY_SCENARIO', ""):
40 self.functest_yaml = dict(Config._merge_dicts(
41 self.functest_yaml, patch_file[key]))
43 def _parse(self, attr_now, left_parametes):
44 for param_n, param_v in six.iteritems(left_parametes):
45 attr_further = self._get_attr_further(attr_now, param_n)
47 self.__setattr__(attr_further, param_v)
48 if isinstance(param_v, dict):
49 self._parse(attr_further, param_v)
52 def _get_attr_further(attr_now, next): # pylint: disable=redefined-builtin
53 return attr_now if next == 'general' else (
54 '{}_{}'.format(attr_now, next) if attr_now else next)
58 self._parse(None, self.functest_yaml)
59 except Exception as error:
60 raise Exception('Parse config failed: {}'.format(str(error)))
64 CONF.patch_file(pkg_resources.resource_filename(
65 'functest', 'ci/config_patch.yaml'))
66 if os.getenv("POD_ARCH", None) and os.getenv("POD_ARCH", None) in ['aarch64']:
67 CONF.patch_file(pkg_resources.resource_filename(
68 'functest', 'ci/config_aarch64_patch.yaml'))