Esempio n. 1
0
def setup_module(module):
    ensure_vms_absent()
    ensure_vms_present()
    netvm = qmgr.HexagonQube(NETVM, provides_network=True)
    netvm.reconcile()
    clientvm = qmgr.HexagonQube(CLIENTVM, netvm=NETVM)
    clientvm.reconcile()
    netvm.vm.start()
    clientvm.vm.start()
Esempio n. 2
0
def test_reboot_netvm():
    netvm = qmgr.HexagonQube(NETVM)
    netvm_uptime_before = netvm.uptime()

    clientvm = qmgr.HexagonQube(CLIENTVM)
    clientvm_uptime_before = clientvm.uptime()

    netvm.reboot()

    netvm_uptime_after = netvm.uptime()
    assert netvm_uptime_before > netvm_uptime_after
    clientvm_uptime_after = clientvm.uptime()
    assert clientvm_uptime_after > clientvm_uptime_before
Esempio n. 3
0
def ensure_vms_present():
    for vm_name in generate_vm_names():
        q = qubesadmin.Qubes()
        if vm_name not in q.domains:
            x = qmgr.HexagonQube(vm_name)
            x.reconcile()
        q = qubesadmin.Qubes()
        assert vm_name in q.domains
Esempio n. 4
0
def test_template_change_while_halted():
    vm = qmgr.HexagonQube("hexagon-test-1", template="debian-10")
    q = qubesadmin.Qubes()
    assert vm.name in q.domains
    assert not vm.pending_changes
    assert vm.desired_config["template"] == "debian-10"
    vm.desired_config["template"] = "fedora-31"
    vm.reconcile()
    assert vm.desired_config["template"] == "fedora-31"
Esempio n. 5
0
def test_netvm_change_while_running():
    vm = qmgr.HexagonQube("hexagon-test-4",
                          template="debian-10",
                          autostart=True)
    q = qubesadmin.Qubes()
    assert vm.name in q.domains
    assert str(vm.vm.netvm) == "None"
    vm.desired_config["netvm"] = "sys-firewall"
    vm.reconcile()
    assert vm.desired_config["netvm"] == "sys-firewall"
Esempio n. 6
0
def test_default_netvm_is_none():
    vm_name = "hexagon-test-3"
    q = qubesadmin.Qubes()
    assert vm_name in q.domains
    vm = qmgr.HexagonQube(vm_name, template="debian-10")
    q = qubesadmin.Qubes()
    assert vm_name in q.domains
    vm.reconcile()
    q = qubesadmin.Qubes()
    assert vm.name in q.domains
    assert str(vm.vm.netvm) == "None"
Esempio n. 7
0
def test_template_change_while_running():
    vm_name = "hexagon-test-2"
    vm = qmgr.HexagonQube(vm_name, template="debian-10", autostart=True)
    q = qubesadmin.Qubes()
    assert vm.name in q.domains
    assert not vm.pending_changes
    assert vm.vm.start_time == ""
    assert get_pref(vm_name, "start_time") == ""
    vm.vm.start()
    assert get_pref(vm_name, "start_time") != ""
    time_before_reconcile = get_pref(vm_name, "start_time")
    assert vm.desired_config["template"] == "debian-10"
    vm.desired_config["template"] = "fedora-31"
    vm.reconcile()
    assert get_pref(vm_name, "template") == "fedora-31"
    # TODO: figure out why this reboot cycle is required
    # Maybe the reconcile isn't rebooting?
    vm.ensure_halted()
    vm.vm.start()
    time_after_reconcile = get_pref(vm_name, "start_time")
    assert time_after_reconcile > time_before_reconcile
Esempio n. 8
0
def test_reboot_clientvm():
    clientvm = qmgr.HexagonQube(CLIENTVM)
    clientvm_uptime_before = clientvm.uptime()
    clientvm.reboot()
    clientvm_uptime_after = clientvm.uptime()
    assert clientvm_uptime_before > clientvm_uptime_after