- with open(self.config_functest) as f:
- self.functest_yaml = yaml.safe_load(f)
- self._parse(None, self.functest_yaml)
- except:
- raise Exception('Parse {} failed'.format(self.config_functest))
- self._set_others()
+ # pylint: disable=bad-continuation
+ with open(pkg_resources.resource_filename(
+ 'functest', 'ci/config_functest.yaml')) as yfile:
+ self.functest_yaml = yaml.safe_load(yfile)
+ except Exception as error:
+ raise Exception('Parse config failed: {}'.format(str(error)))
+
+ @staticmethod
+ def _merge_dicts(dict1, dict2):
+ for k in set(dict1.keys()).union(dict2.keys()):
+ if k in dict1 and k in dict2:
+ if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
+ yield (k, dict(Config._merge_dicts(dict1[k], dict2[k])))
+ else:
+ yield (k, dict2[k])
+ elif k in dict1:
+ yield (k, dict1[k])
+ else:
+ yield (k, dict2[k])
+
+ def patch_file(self, patch_file_path):
+ with open(patch_file_path) as yfile:
+ patch_file = yaml.safe_load(yfile)
+
+ for key in patch_file:
+ if key in env.get('DEPLOY_SCENARIO'):
+ self.functest_yaml = dict(Config._merge_dicts(
+ self.functest_yaml, patch_file[key]))