Example #1
0
def test_matching_libvirt_domains_from_config(build_mock_libvirtconn_filled):
    conn = build_mock_libvirtconn_filled
    host_config = {"host": "matching", "disks": ["vda", "vdb"], "quiesce": True}

    matches = matching_libvirt_domains_from_config(host_config, conn)
    domains = tuple(sorted(matches["domains"]))

    assert domains == ("matching",)
    assert not matches["exclude"]
    assert tuple(sorted(matches["properties"]["disks"])) == ("vda", "vdb")
    assert matches["properties"]["quiesce"]
Example #2
0
def test_matching_libvirt_domains_from_config(build_mock_libvirtconn_filled):
    conn = build_mock_libvirtconn_filled
    host_config = {"host": "matching", "disks": ["vda", "vdb"]}

    matches = matching_libvirt_domains_from_config(host_config, conn)
    domains = tuple(sorted(matches["domains"]))
    exclude, disks = matches["exclude"], tuple(sorted(matches["disks"]))

    assert domains == ("matching",)
    assert not exclude
    assert disks == ("vda", "vdb")
Example #3
0
def test_matching_libvirt_domains_from_config(build_mock_libvirtconn_filled):
    conn = build_mock_libvirtconn_filled
    host_config = {"host": "matching", "disks": ["vda", "vdb"]}

    matches = matching_libvirt_domains_from_config(host_config, conn)
    domains = tuple(sorted(matches["domains"]))
    exclude, disks = matches["exclude"], tuple(sorted(matches["disks"]))

    assert domains == ("matching",)
    assert not exclude
    assert disks == ("vda", "vdb")
Example #4
0
def test_matching_libvirt_domains_from_config_str(build_mock_libvirtconn_filled):
    """
    Test match_domains_from_config with a str pattern
    """
    conn = build_mock_libvirtconn_filled
    host_config = r"r:matching\d?"

    matches = matching_libvirt_domains_from_config(host_config, conn)
    domains = tuple(sorted(matches["domains"]))
    exclude = matches["exclude"]

    assert domains == ("matching", "matching2")
    assert not exclude
Example #5
0
def test_matching_libvirt_domains_from_config_unexisting(build_mock_libvirtconn_filled):
    """
    Test match_domains_from_config with a non existing domain
    """
    conn = build_mock_libvirtconn_filled
    host_config = {"host": "nonexisting", "disks": ["vda", "vdb"]}

    matches = matching_libvirt_domains_from_config(host_config, conn)
    domains = tuple(sorted(matches["domains"]))
    exclude = matches["exclude"]

    assert domains == tuple()
    assert not exclude
Example #6
0
def test_matching_libvirt_domains_from_config_str(
    build_mock_libvirtconn_filled
):
    """
    Test match_domains_from_config with a str pattern
    """
    conn = build_mock_libvirtconn_filled
    host_config = "r:matching\d?"

    matches = matching_libvirt_domains_from_config(host_config, conn)
    domains = tuple(sorted(matches["domains"]))
    exclude = matches["exclude"]

    assert domains == ("matching", "matching2")
    assert not exclude
Example #7
0
def test_matching_libvirt_domains_from_config_unexisting(
    build_mock_libvirtconn_filled
):
    """
    Test match_domains_from_config with a non existing domain
    """
    conn = build_mock_libvirtconn_filled
    host_config = {"host": "nonexisting", "disks": ["vda", "vdb"]}

    matches = matching_libvirt_domains_from_config(host_config, conn)
    domains = tuple(sorted(matches["domains"]))
    exclude = matches["exclude"]

    assert domains == tuple()
    assert not exclude