3 # pylint: disable=missing-docstring
15 # pylint: disable=bad-continuation
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:
20 raise Exception('Parse config failed: {}'.format(str(error)))
23 def _merge_dicts(dict1, dict2):
24 for k in set(dict1.keys()).union(dict2.keys()):
25 if k in dict1 and k in dict2:
26 if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
27 yield (k, dict(Config._merge_dicts(dict1[k], dict2[k])))
35 def patch_file(self, patch_file_path):
36 with open(patch_file_path) as yfile:
37 patch_file = yaml.safe_load(yfile)
39 for key in patch_file:
40 if key in os.environ.get('DEPLOY_SCENARIO', ""):
41 self.functest_yaml = dict(Config._merge_dicts(
42 self.functest_yaml, patch_file[key]))
44 def _parse(self, attr_now, left_parametes):
45 for param_n, param_v in six.iteritems(left_parametes):
46 attr_further = self._get_attr_further(attr_now, param_n)
48 setattr(self, attr_further, param_v)
49 if isinstance(param_v, dict):
50 self._parse(attr_further, param_v)
53 def _get_attr_further(attr_now, next): # pylint: disable=redefined-builtin
54 return attr_now if next == 'general' else (
55 '{}_{}'.format(attr_now, next) if attr_now else next)
59 self._parse(None, self.functest_yaml)
60 except Exception as error:
61 raise Exception('Parse config failed: {}'.format(str(error)))
65 CONF.patch_file(pkg_resources.resource_filename(
66 'functest', 'ci/config_patch.yaml'))
67 if os.getenv("POD_ARCH", None) and os.getenv("POD_ARCH", None) in ['aarch64']:
68 CONF.patch_file(pkg_resources.resource_filename(
69 'functest', 'ci/config_aarch64_patch.yaml'))