コード例 #1
0
    def testGetMixedVmInstancesHistoryChange(self):
        # Setup
        self.setUpMVMock()
        run_vm_name = "TEST-VM-RUN"
        stop_vm_name = "TEST-VM-STOP"
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 1)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        vm_catalog = VMCatalog()
        history_changed = vm_catalog.refesh()

        #Assert
        self.assertEqual(True, history_changed)

        #Setup
        mox.Reset(self.virConnectMock, self.virDomainMock)
        self.addRunningVMs(run_vm_name, 0)
        self.addStoppedVMs(stop_vm_name, 2)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        history_changed = vm_catalog.refesh()

        #Assert
        self.assertEqual(True, history_changed)
コード例 #2
0
ファイル: TestVlabVmCatalog.py プロジェクト: hsavolai/vmlab
    def testGetMixedVmInstancesHistoryChange(self):
        # Setup
        self.setUpMVMock()
        run_vm_name = "TEST-VM-RUN"
        stop_vm_name = "TEST-VM-STOP"
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 1)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        vm_catalog = VMCatalog()
        history_changed = vm_catalog.refesh()

        #Assert
        self.assertEqual(True, history_changed)

        #Setup
        mox.Reset(self.virConnectMock, self.virDomainMock)
        self.addRunningVMs(run_vm_name, 0)
        self.addStoppedVMs(stop_vm_name, 2)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        history_changed = vm_catalog.refesh()

        #Assert
        self.assertEqual(True, history_changed)
コード例 #3
0
ファイル: vmlab.py プロジェクト: hsavolai/vmlab
def main(argv=None):

    model = VMCatalog()
    view = VirtLabView(model)
    VirtLabControl(view, model)
    model.set_view(view)
    view.show()
    gtk.main()
コード例 #4
0
    def testOrderPersistsOverReload(self):
        # Setup
        self.setUpMVMock()
        run_vm_name = "TEST-VM-RUN"
        stop_vm_name = "TEST-VM-STOP"
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 0)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        vm_catalog = VMCatalog()
        assert isinstance(vm_catalog, VMCatalog)
        vm_catalog.refesh()

        vm = vm_catalog.get_vm(run_vm_name + "-0")
        assert isinstance(vm, VMInstance)
        order = 1
        vm.set_order(1)

        #Setup
        mox.Reset(self.virConnectMock, self.virDomainMock)
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 0)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        vm_catalog.refesh()
        vm = vm_catalog.get_vm(run_vm_name + "-0")
        #Assert
        self.assertEqual(order, vm.get_order())
コード例 #5
0
    def testGetMixedVmInstancesOrderAttached(self):
        self.setUpMVMock()
        # Setup running instance
        self.virConnectMock.listDomainsID().AndReturn([1])
        run_vm_name = "TEST-VM-RUN"
        self.virDomainMock.name().AndReturn(run_vm_name)
        self.virConnectMock.lookupByID(1).AndReturn(self.virDomainMock)

        # Setup stopped instance
        stop_vm_name = "TEST-VM-STOP"
        self.virConnectMock.listDefinedDomains().AndReturn([stop_vm_name])

        mox.Replay(self.virConnectMock, self.virDomainMock)
        vm_catalog = VMCatalog()
        vm_catalog.refesh()
        vm_catalog.get_vm(run_vm_name).set_order(1)
        vms = vm_catalog.get_vms()

        self.assertEqual(2, len(vms), "There should be two vms! / "\
                                                        + str(len(vms)))
        self.assertEqual(stop_vm_name, vms[1].get_name(), \
                "VM name does not match! / " \
                                      + stop_vm_name + vms[1].get_name())

        self.assertEqual(c.STATE_STOPPED, vms[1].get_state().get_state_str(), \
                "VM should be stopped / " + vms[1].get_state().get_state_str())

        self.assertEqual(run_vm_name, vms[0].get_name(), \
                "VM name does not match! / " + vms[0].get_name())

        self.assertEqual(c.STATE_RUNNING, vms[0].get_state().get_state_str(), \
                "VM should be running / " + vms[0].get_state().get_state_str())

        self.assertEqual(1, vms[0].get_order(), \
                "VM should have order / " + str(vms[0].get_order()))
コード例 #6
0
ファイル: TestVlabVmCatalog.py プロジェクト: hsavolai/vmlab
    def testOrderPersistsOverReload(self):
        # Setup
        self.setUpMVMock()
        run_vm_name = "TEST-VM-RUN"
        stop_vm_name = "TEST-VM-STOP"
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 0)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        vm_catalog = VMCatalog()
        assert isinstance(vm_catalog, VMCatalog)
        vm_catalog.refesh()

        vm = vm_catalog.get_vm(run_vm_name + "-0")
        assert isinstance(vm, VMInstance)
        order = 1
        vm.set_order(1)

        #Setup
        mox.Reset(self.virConnectMock, self.virDomainMock)
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 0)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        vm_catalog.refesh()
        vm = vm_catalog.get_vm(run_vm_name + "-0")
        #Assert
        self.assertEqual(order, vm.get_order())
コード例 #7
0
ファイル: TestVlabVmCatalog.py プロジェクト: hsavolai/vmlab
    def testGetMixedVmInstancesOrderAttached(self):
        self.setUpMVMock()
        # Setup running instance
        self.virConnectMock.listDomainsID().AndReturn([1])
        run_vm_name = "TEST-VM-RUN"
        self.virDomainMock.name().AndReturn(run_vm_name)
        self.virConnectMock.lookupByID(1).AndReturn(self.virDomainMock)

        # Setup stopped instance
        stop_vm_name = "TEST-VM-STOP"
        self.virConnectMock.listDefinedDomains().AndReturn([stop_vm_name])

        mox.Replay(self.virConnectMock, self.virDomainMock)
        vm_catalog = VMCatalog()
        vm_catalog.refesh()
        vm_catalog.get_vm(run_vm_name).set_order(1)
        vms = vm_catalog.get_vms()

        self.assertEqual(2, len(vms), "There should be two vms! / "\
                                                        + str(len(vms)))
        self.assertEqual(stop_vm_name, vms[1].get_name(), \
                "VM name does not match! / " \
                                      + stop_vm_name + vms[1].get_name())

        self.assertEqual(c.STATE_STOPPED, vms[1].get_state().get_state_str(), \
                "VM should be stopped / " + vms[1].get_state().get_state_str())

        self.assertEqual(run_vm_name, vms[0].get_name(), \
                "VM name does not match! / " + vms[0].get_name())

        self.assertEqual(c.STATE_RUNNING, vms[0].get_state().get_state_str(), \
                "VM should be running / " + vms[0].get_state().get_state_str())

        self.assertEqual(1, vms[0].get_order(), \
                "VM should have order / " + str(vms[0].get_order()))
コード例 #8
0
    def testGetSingleRunningVmInstance(self):
        # Setup
        self.setUpMVMock()
        run_vm_name = "TEST-VM-RUN"
        stop_vm_name = "TEST-VM-STOP"
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 0)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        vm_catalog = VMCatalog()
        vm_catalog.refesh()
        vms = vm_catalog.get_vms()
        vm1 = vm_catalog.get_vm(run_vm_name + "-0")
        vm2 = vm_catalog.get_vm(stop_vm_name + "-0")

        #Assert
        self.assertEqual(1, len(vms))
        self.assertFalse(vm2)
        self.assertTrue(vm1)
        self.assertEqual(c.STATE_RUNNING, vm1.get_state().get_state_str())
コード例 #9
0
ファイル: TestVlabVmCatalog.py プロジェクト: hsavolai/vmlab
    def testGetSingleRunningVmInstance(self):
        # Setup
        self.setUpMVMock()
        run_vm_name = "TEST-VM-RUN"
        stop_vm_name = "TEST-VM-STOP"
        self.addRunningVMs(run_vm_name, 1)
        self.addStoppedVMs(stop_vm_name, 0)
        mox.Replay(self.virConnectMock, self.virDomainMock)

        #Test
        vm_catalog = VMCatalog()
        vm_catalog.refesh()
        vms = vm_catalog.get_vms()
        vm1 = vm_catalog.get_vm(run_vm_name + "-0")
        vm2 = vm_catalog.get_vm(stop_vm_name + "-0")

        #Assert
        self.assertEqual(1, len(vms))
        self.assertFalse(vm2)
        self.assertTrue(vm1)
        self.assertEqual(c.STATE_RUNNING, vm1.get_state().get_state_str())
コード例 #10
0
 def testExeptionLibVirtdConnectionNotFound(self):
     static_stub = staticmethod(lambda *args, **kwargs: self.throw_ex())
     LibVirtDao.get_libvirt = static_stub
     vmcatalog = VMCatalog()
     # TODO: Add check exception should include vme_id with correct value
     self.assertRaises(VMLabException, vmcatalog.get_conn)