Exemple #1
0
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)
Exemple #2
0
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",
    }
Exemple #3
0
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
    }
Exemple #4
0
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
Exemple #5
0
def test_dump_create(tmpconf):
    conf = {"key1": "1", "key2": "2"}
    backup = sanlockconf.dump(conf)

    assert backup is None
    assert sanlockconf.load() == conf
Exemple #6
0
def test_empty_sanlock_conf(tmpconf):
    with open(tmpconf, "w") as f:
        f.write("")
    assert sanlockconf.load() == {}
Exemple #7
0
def test_no_sanlock_conf(tmpconf):
    assert sanlockconf.load() == {}