Ejemplo n.º 1
0
    def test_start_vm(self):
        vmname = "test1.home.net"

        node = self.mocker.mock()
        node.metrics.get_free_ram()
        self.mocker.result(1024)
        node.is_vm_started(vmname)
        self.mocker.result(False)
        node.deactivate_lv(vmname)
        node.activate_lv(vmname)
        node.start(vmname)
        self.mocker.replay()

        self.cluster.nodes = {socket.gethostname(): node}

        self.cluster.start_vm(node, vmname, False)
Ejemplo n.º 2
0
    def test_start_vm__error(self):
        vmname = "test1.home.net"

        node = self.mocker.mock()
        node.metrics.get_free_ram()
        self.mocker.result(1024)
        node.is_vm_started(vmname)
        self.mocker.result(False)
        node.deactivate_lv(vmname)
        node.activate_lv(vmname)
        node.start(vmname)
        self.mocker.throw(Exception)
        node.deactivate_lv(vmname)
        self.mocker.replay()

        self.cluster.nodes = {socket.gethostname(): node}

        self.assertRaises(Exception, self.cluster.start_vm, node, vmname, False)