def _configure_config_file(): """ Configure sanlock.conf for vdsm. If a previous configuration exists, return the path to the backup file. """ conf = sanlockconf.load() conf.update(_config_for_vdsm()) return sanlockconf.dump(conf)
def test_load(tmpconf): with open(tmpconf, "w") as f: f.write(EXAMPLE) assert sanlockconf.load() == { "key1": "1", "key2": "2", "key3": "=3=", "key4": "4 4", }
def _config_file_issues(): """ Return dict of options that need to be configured for vdsm. """ conf = sanlockconf.load() return { option: value for option, value in _config_for_vdsm().items() if conf.get(option) != value }
def test_dump_replace(tmpconf): sanlockconf.dump({"key1": "1", "key2": "2"}) with open(sanlockconf.SANLOCK_CONF) as f: old_text = f.read() conf = {"key1": "new1", "key2": "2", "key3": "new2"} backup = sanlockconf.dump(conf) assert backup.startswith(sanlockconf.SANLOCK_CONF + ".") with open(backup) as f: assert f.read() == old_text assert sanlockconf.load() == conf
def test_dump_create(tmpconf): conf = {"key1": "1", "key2": "2"} backup = sanlockconf.dump(conf) assert backup is None assert sanlockconf.load() == conf
def test_empty_sanlock_conf(tmpconf): with open(tmpconf, "w") as f: f.write("") assert sanlockconf.load() == {}
def test_no_sanlock_conf(tmpconf): assert sanlockconf.load() == {}