From: Kyr Shatskyy Date: Mon, 3 Jun 2019 16:26:55 +0000 (+0200) Subject: config: add parameter for config load X-Git-Tag: 1.1.0~243^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2292b0d22432bb2214f698cd74316658081aad3e;p=teuthology.git config: add parameter for config load This patch makes it possible to load config file directly from the given path or data object, for testing purposes and allows to remove silly notification about missing teuthology.yaml file. Signed-off-by: Kyr Shatskyy --- diff --git a/teuthology/config.py b/teuthology/config.py index 16b698746..2144db0a9 100644 --- a/teuthology/config.py +++ b/teuthology/config.py @@ -29,7 +29,13 @@ class YamlConfig(collections.MutableMapping): else: self._conf = dict() - def load(self): + def load(self, conf=None): + if conf: + if isinstance(conf, dict): + self._conf = conf + else: + self._conf = yaml.safe_load(conf) + return if os.path.exists(self.yaml_path): self._conf = yaml.safe_load(file(self.yaml_path)) else: diff --git a/teuthology/provision/cloud/test/test_openstack.py b/teuthology/provision/cloud/test/test_openstack.py index cc6afd495..bd5166766 100644 --- a/teuthology/provision/cloud/test/test_openstack.py +++ b/teuthology/provision/cloud/test/test_openstack.py @@ -66,9 +66,8 @@ def get_fake_obj(mock_args=None, attributes=None): class TestOpenStackBase(object): - def setup(self): - config.load() - config.libcloud = deepcopy(test_config) + def setup(self, conf=dict(), test_config=test_config): + config.load(conf or dict(libcloud=deepcopy(test_config))) self.start_patchers() def start_patchers(self):