def test_update_inventory(self):
        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
        self.mox.StubOutWithMock(api, 'vm_save')
        self.mox.StubOutWithMock(api, 'vm_host_save')
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(mox.IgnoreArg(),
                                mox.IgnoreArg()).MultipleTimes().AndReturn(None)

        api.vm_host_save(mox.IgnoreArg(),
                         mox.IgnoreArg()).MultipleTimes().AndReturn(None)

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.ReplayAll()
        conn = connection.get_connection(True)
        compute_rmcontext = ComputeRMContext(rmType='QEMU',
                                             rmIpAddress='10.10.155.165', rmUserName='******',
                                             rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory()['1'] = \
            ComputeInventory(compute_rmcontext)

        conn.init_rmcontext(compute_rmcontext)
        conn._wrapped_conn = self.fakeConn

        conn.update_inventory('1')
Example #2
0
    def test_update_inventory(self):
        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
        self.mox.StubOutWithMock(api, 'vm_save')
        self.mox.StubOutWithMock(api, 'vm_host_save')
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(
            mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None)

        api.vm_host_save(mox.IgnoreArg(),
                         mox.IgnoreArg()).MultipleTimes().AndReturn(None)

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.ReplayAll()
        conn = connection.get_connection(True)
        compute_rmcontext = ComputeRMContext(rmType='QEMU',
                                             rmIpAddress='10.10.155.165',
                                             rmUserName='******',
                                             rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory()['1'] = \
            ComputeInventory(compute_rmcontext)

        conn.init_rmcontext(compute_rmcontext)
        conn._wrapped_conn = self.fakeConn

        conn.update_inventory('1')
Example #3
0
    def test_get_connection_with_conn_static_exception(self):

        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndRaise(libvirt.libvirtError)
        self.mox.ReplayAll()
        try:
            self.libvirt_connection_cls._connect('uri', True)
        except Exception as e:
            self.assertTrue(isinstance(e, libvirt.libvirtError))
    def test_get_connection_with_conn_static(self):

        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
        self.mox.ReplayAll()
        con = self.libvirt_connection_cls._connect('uri', True)
        self.assertEquals("ubuntu164.vmm.hp.com", con.getHostname())
        self.assertTrue("ReleaseBDevEnv" in con.listDefinedDomains())
        self.assertTrue("1" in str(con.listDomainsID()))
    def test_get_connection_with_conn_static_exception(self):

        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndRaise(libvirt.libvirtError)
        self.mox.ReplayAll()
        try:
            self.libvirt_connection_cls._connect('uri', True)
        except Exception as e:
            self.assertTrue(isinstance(e, libvirt.libvirtError))
Example #6
0
    def test_get_connection_with_conn_static(self):

        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
        self.mox.ReplayAll()
        con = self.libvirt_connection_cls._connect('uri', True)
        self.assertEquals("ubuntu164.vmm.hp.com", con.getHostname())
        self.assertTrue("ReleaseBDevEnv" in con.listDefinedDomains())
        self.assertTrue("1" in str(con.listDomainsID()))
    def test__get_connection_with_invalid_conn(self):
        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
        self.mox.ReplayAll()
        conn = connection.get_connection(True)
        compute_rmcontext = ComputeRMContext(
            rmType='QEMU',
            rmIpAddress='10.10.155.165', rmUserName='******',
            rmPassword='******')
        conn.init_rmcontext(compute_rmcontext)
        conn._wrapped_conn = 'Invalid'
        self.assertRaises(Exception, conn._get_connection)

        self.mox.UnsetStubs()
    def test_update_perfdata(self):
        conn = connection.get_connection(True)

        self.mox.StubOutWithMock(connection.LibvirtConnection, 'uri')
        conn.uri().AndReturn(None)

        self.mox.StubOutWithMock(libvirt, 'openReadOnly')
        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)

        self.mox.ReplayAll()
        conn.update_perfdata('uuid', 'perfmon_type')
        self.assertTrue(conn.libvirt_perfmon.perfDataCache is not None)

        conn.update_perfdata('uuid', 'perfmon_type1')
        self.assertTrue(conn.libvirt_perfmon.perfDataCache is not None)
Example #9
0
    def test_processVmForIPAddress(self):
        self.mock.StubOutWithMock(api, 'vm_save')

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(mox.IgnoreArg(),
                                         mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(
            InventoryCacheManager, 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            self.libvirtVM.compute_id,
            Constants.VmHost).AndReturn(fake.get_connection())
        self.mock.ReplayAll()
        self.assertEquals(self.libvirtVM._processVm(libvirt.virDomain()),
                          None)
        self.libvirtVM.processUpdates()
        vm = InventoryCacheManager.get_object_from_cache(
            "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm)
        ipProfileList = vm.get_ipAddresses()
        self.assertTrue(ipProfileList is not None)
        self.assertTrue(ipProfileList[0].get_ipAddress() == '10.1.1.19')
        self.assertTrue(ipProfileList[1].get_ipAddress() == '10.2.1.20')
Example #10
0
 def test_process_updates_for_updated_VM_exception(self):
     domainObj = libvirt.virDomain()
     self.libvirtVM.vmHost = None
     self.libvirtVM.process_updates_for_updated_VM(domainObj)
     self.assertRaises(Exception, LibvirtVM)
     self.mock.stubs.UnsetAll()
     self.mock.VerifyAll()
Example #11
0
    def test_storage_added_event(self):
        storagePool = libvirt.virStoragePool()
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(
            mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.StubOutWithMock(InventoryCacheManager,
                                 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            storagePool.UUIDString(), Constants.StorageVolume).AndReturn(None)

        self.mox.ReplayAll()
        self.LibvirtStorageVolume._processStorage(storagePool)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_STORAGE_ADDED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'StorageVolume')
        self.assertEquals(payload['entity_id'], storagePool.UUIDString())
Example #12
0
    def setUp(self):
        super(StorageVolumeEventsTest, self).setUp()
        self.connection = LibvirtConnection(False)
        vmHost = VmHost()
        vmHost.set_storageVolumeIds([])
        InventoryCacheManager.update_object_in_cache('1', vmHost)
        self.connection._wrapped_conn = libvirt.open('qemu:///system')
        self.LibvirtStorageVolume = \
            LibvirtStorageVolume(self.connection._wrapped_conn, '1')
        self.LibvirtStorageVolume.vmHost = vmHost
        self.LibvirtStorageVolume.cur_total_storage_size = 0
        self.LibvirtStorageVolume.curr_storage_free = 0
        self.LibvirtStorageVolume.old_total_storage_size = 0
        self.LibvirtStorageVolume.old_storage_free = 0
        self.LibvirtStorageVolume.vmHost.set_id('1')
        self.connection.compute_rmcontext = \
            ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
                             rmUserName='******',
                             rmPassword='******')
        self.flags(
            healthnmon_notification_drivers=['nova.notifier.test_notifier'])
        test_notifier.NOTIFICATIONS = []
        self.mox.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(
            mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None)
    def test_broken_connection_cover(self):
        global libvirt
        libvirt = libvirt = __import__('libvirt')
        error = 38
        domain = 13
        conn = connection.get_connection(False)

#        self.mox.StubOutWithMock(libvirt,'openReadOnly')
#        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
#        conn._wrapped_conn=self.fakeConn

        self.mox.StubOutWithMock(conn, '_wrapped_conn')
        self.mox.StubOutWithMock(conn._wrapped_conn, 'getCapabilities')
        self.mox.StubOutWithMock(libvirt.libvirtError, 'get_error_code')
        self.mox.StubOutWithMock(libvirt.libvirtError,
                                 'get_error_domain')

        conn._wrapped_conn.getCapabilities().AndRaise(
            FakeLibvirt.libvirtError('fake failure'
                                     ))

        libvirt.libvirtError.get_error_code().MultipleTimes(). \
            AndReturn(error)
        libvirt.libvirtError.get_error_domain().MultipleTimes(). \
            AndReturn(domain)

        self.mox.ReplayAll()
        try:
            self.assertFalse(conn._test_connection())
        except:
            print 'error'
Example #14
0
    def test_process_updates_for_updated_VM(self):
        self.mock.StubOutWithMock(api, 'vm_save')

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(api, 'vm_delete_by_ids')

        api.vm_delete_by_ids(mox.IgnoreArg(),
                             mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(mox.IgnoreArg(),
                                         mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(
            InventoryCacheManager, 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            self.libvirtVM.compute_id,
            Constants.VmHost).AndReturn(fake.get_connection())
        self.mock.ReplayAll()
        domainObj = libvirt.virDomain()
        self.assertEquals(
            self.libvirtVM.process_updates_for_updated_VM(domainObj), None)
        vm = InventoryCacheManager.get_object_from_cache(
            "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm)
#        self.assertEquals("TestVirtMgrVM7", vm.get_name())
        self.assertEquals("1048576", str(vm.get_memorySize()))
        self.assertEquals("hd", str(vm.get_bootOrder()).strip())
        self.mock.stubs.UnsetAll()
Example #15
0
    def test_broken_connection_remote(self):

        libvirtError = libvirt.libvirtError('fake failure')

        #        libError = self.mox.CreateMockAnything()
        #        self.stubs.Set(libvirt.libvirtError, '__init__', libError)
        #        libError('fake failure').AndReturn(libvirtError)

        capability = self.mox.CreateMockAnything()
        self.stubs.Set(libvirt.virConnect, 'getCapabilities', capability)
        capability().AndRaise(libvirtError)

        #        self.mox.StubOutWithMock(libvirt.libvirtError, "get_error_domain")
        #
        #        libvirt.libvirtError.get_error_code().AndReturn(error)
        #        libvirt.libvirtError.get_error_domain().AndReturn(domain)

        self.mox.ReplayAll()
        conn = connection.get_connection(False)
        conn._wrapped_conn = self.fakeConn

        try:
            self.assertFalse(conn._test_connection())
        except:
            print 'over'
Example #16
0
    def test_process_updates_for_updated_VM(self):
        self.mock.StubOutWithMock(api, 'vm_save')

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(api, 'vm_delete_by_ids')

        api.vm_delete_by_ids(mox.IgnoreArg(),
                             mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(
            InventoryCacheManager, 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            self.libvirtVM.compute_id,
            Constants.VmHost).AndReturn(fake.get_connection())
        self.mock.ReplayAll()
        domainObj = libvirt.virDomain()
        self.assertEquals(
            self.libvirtVM.process_updates_for_updated_VM(domainObj), None)
        vm = InventoryCacheManager.get_object_from_cache(
            "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm)
#        self.assertEquals("TestVirtMgrVM7", vm.get_name())
        self.assertEquals("1048576", str(vm.get_memorySize()))
        self.assertEquals("hd", str(vm.get_bootOrder()).strip())
        self.mock.stubs.UnsetAll()
Example #17
0
 def test_deregister_libvirt_events(self):
     libvirtEvents = libvirt_event_monitor.LibvirtEvents()
     libvirtEvents.registered = True
     libvirtEvents.call_back_ids['domain_events'] = [1]
     libvirtEvents.libvirt_con = libvirt.open("fake:///system")
     libvirtEvents.deregister_libvirt_events()
     self.mock.VerifyAll()
 def setUpClass(cls):
     cls.connection = LibvirtConnection(False)
     cls.mox = mox.Mox()
     cls.connection._wrapped_conn = libvirt.open('qemu:///system')
     cls.connection.libvirt = libvirt
     cls.vm_id = '25f04dd3-e924-02b2-9eac-876e3c943262'
     cls.vmhost_id = '1'
Example #19
0
    def test_storage_no_state_change(self):
        storagePool = libvirt.virStoragePool()
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(
            mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        cachedStorageVolume = StorageVolume()
        cachedStorageVolume.id = storagePool.UUIDString()
        cachedStorageVolume.size = 0
        cachedStorageVolume.free = 0
        cachedStorageVolume.connectionState = \
            Constants.STORAGE_STATE_ACTIVE
        self.mox.StubOutWithMock(InventoryCacheManager,
                                 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            storagePool.UUIDString(),
            Constants.StorageVolume).AndReturn(cachedStorageVolume)
        #        self.mox.StubOutWithMock(InventoryCacheManager, 'get_compute_conn_driver')
        #
        #        InventoryCacheManager.get_compute_conn_driver(self.LibvirtStorageVolume.compute_id,
        #                Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()
        nova_db.service_get_all_by_topic(None, None)
        self.LibvirtStorageVolume._processStorage(storagePool)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 0)
Example #20
0
    def test_storage_added_event(self):
        storagePool = libvirt.virStoragePool()
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            storagePool.UUIDString(),
            Constants.StorageVolume).AndReturn(None)

        self.mox.ReplayAll()
        self.LibvirtStorageVolume._processStorage(storagePool)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_STORAGE_ADDED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'StorageVolume')
        self.assertEquals(payload['entity_id'],
                          storagePool.UUIDString())
    def test_processVm_disk_exception_next_retry(self):
        self.mock.StubOutWithMock(api, 'vm_save')
        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)

        self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic')
        nova_db.service_get_all_by_topic(mox.IgnoreArg(),
                                         mox.IgnoreArg()).MultipleTimes().\
            AndReturn(None)

        self.mock.StubOutWithMock(novadb, 'instance_get_by_uuid')
        novadb.instance_get_by_uuid(mox.IgnoreArg(),
                                    mox.IgnoreArg())\
            .AndReturn({'display_name': 'test_vm'})

        self.mock.StubOutWithMock(
            self.libvirtVM.libvirtconn, 'storageVolLookupByPath')
        self.libvirtVM.libvirtconn.storageVolLookupByPath(
            mox.IgnoreArg()).AndRaise(Exception)

        self.mock.ReplayAll()
        InventoryCacheManager.delete_object_in_cache(
            '25f04dd3-e924-02b2-9eac-876e3c943262', Constants.Vm)
        libvirt_inventorymonitor.incomplete_vms = {
            self.libvirtVM.compute_id: {}}
        self.assertEquals(self.libvirtVM._processVm(libvirt.virDomain()), None)
        vm = InventoryCacheManager.get_object_from_cache(
            "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm)
        self.assertEqual(len(
            vm.get_vmDisks()), 0, "Instance disk should not exist when there \
            is an exception")
        self.mock.VerifyAll()
        self.mock.stubs.UnsetAll()
Example #22
0
    def setUp(self):
        super(StorageVolumeEventsTest, self).setUp()
        self.connection = LibvirtConnection(False)
        vmHost = VmHost()
        vmHost.set_storageVolumeIds([])
        InventoryCacheManager.update_object_in_cache('1', vmHost)
        self.connection._wrapped_conn = libvirt.open('qemu:///system')
        self.LibvirtStorageVolume = \
            LibvirtStorageVolume(self.connection._wrapped_conn, '1')
        self.LibvirtStorageVolume.vmHost = vmHost
        self.LibvirtStorageVolume.cur_total_storage_size = 0
        self.LibvirtStorageVolume.curr_storage_free = 0
        self.LibvirtStorageVolume.old_total_storage_size = 0
        self.LibvirtStorageVolume.old_storage_free = 0
        self.LibvirtStorageVolume.vmHost.set_id('1')
        self.connection.compute_rmcontext = \
            ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
                             rmUserName='******',
                             rmPassword='******')
        self.flags(healthnmon_notification_drivers=[
            'nova.notifier.test_notifier'])
        test_notifier.NOTIFICATIONS = []
        self.mox.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
    def test_broken_connection_remote(self):

        libvirtError = libvirt.libvirtError('fake failure')

#        libError = self.mox.CreateMockAnything()
#        self.stubs.Set(libvirt.libvirtError, '__init__', libError)
#        libError('fake failure').AndReturn(libvirtError)

        capability = self.mox.CreateMockAnything()
        self.stubs.Set(libvirt.virConnect, 'getCapabilities',
                       capability)
        capability().AndRaise(libvirtError)

#        self.mox.StubOutWithMock(libvirt.libvirtError, "get_error_domain")
#
#        libvirt.libvirtError.get_error_code().AndReturn(error)
#        libvirt.libvirtError.get_error_domain().AndReturn(domain)

        self.mox.ReplayAll()
        conn = connection.get_connection(False)
        conn._wrapped_conn = self.fakeConn

        try:
            self.assertFalse(conn._test_connection())
        except:
            print 'over'
Example #24
0
 def test_process_updates_for_updated_VM_exception(self):
     domainObj = libvirt.virDomain()
     self.libvirtVM.vmHost = None
     self.libvirtVM.process_updates_for_updated_VM(domainObj)
     self.assertRaises(Exception, LibvirtVM)
     self.mock.stubs.UnsetAll()
     self.mock.VerifyAll()
    def test_broken_connection_cover(self):
        global libvirt
        libvirt = libvirt = __import__('libvirt')
        error = 38
        domain = 13
        conn = connection.get_connection(False)

        #        self.mox.StubOutWithMock(libvirt,'openReadOnly')
        #        libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
        #        conn._wrapped_conn=self.fakeConn

        self.mox.StubOutWithMock(conn, '_wrapped_conn')
        self.mox.StubOutWithMock(conn._wrapped_conn, 'getCapabilities')
        self.mox.StubOutWithMock(libvirt.libvirtError, 'get_error_code')
        self.mox.StubOutWithMock(libvirt.libvirtError, 'get_error_domain')

        conn._wrapped_conn.getCapabilities().AndRaise(
            FakeLibvirt.libvirtError('fake failure'))

        libvirt.libvirtError.get_error_code().MultipleTimes(). \
            AndReturn(error)
        libvirt.libvirtError.get_error_domain().MultipleTimes(). \
            AndReturn(domain)

        self.mox.ReplayAll()
        try:
            self.assertFalse(conn._test_connection())
        except:
            print 'error'
Example #26
0
    def test_processVmForIPAddress(self):
        self.mock.StubOutWithMock(api, 'vm_save')

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(
            InventoryCacheManager, 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(
            self.libvirtVM.compute_id,
            Constants.VmHost).AndReturn(fake.get_connection())
        self.mock.ReplayAll()
        self.assertEquals(self.libvirtVM._processVm(libvirt.virDomain()),
                          None)
        self.libvirtVM.processUpdates()
        vm = InventoryCacheManager.get_object_from_cache(
            "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm)
        ipProfileList = vm.get_ipAddresses()
        self.assertTrue(ipProfileList is not None)
        self.assertTrue(ipProfileList[0].get_ipAddress() == '10.1.1.19')
        self.assertTrue(ipProfileList[1].get_ipAddress() == '10.2.1.20')
Example #27
0
    def test_vm_created_event(self):
        domainObj = libvirt.virDomain()
        self.mox.StubOutWithMock(api, 'vm_save')

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            domainObj.UUIDString(),
            Constants.Vm).AndReturn(None)
        self.mox.ReplayAll()
        self.libvirtVM._processVm(domainObj)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_VM_CREATED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'Vm')
        self.assertEquals(payload['entity_id'], domainObj.UUIDString())
 def setUp(self):
     self.fakeConn = libvirt.open('qemu:///system')
     self.libvirt_connection_cls = connection.LibvirtConnection
     super(Test_virt_connection, self).setUp()
     self.flags(
         healthnmon_notification_drivers=['healthnmon.notifier.log_notifier']
     )
Example #29
0
 def setUpClass(cls):
     cls.connection = LibvirtConnection(False)
     cls.mox = mox.Mox()
     cls.connection._wrapped_conn = libvirt.open('qemu:///system')
     cls.connection.libvirt = libvirt
     cls.vm_id = '25f04dd3-e924-02b2-9eac-876e3c943262'
     cls.vmhost_id = '1'
Example #30
0
    def test_storage_no_state_change(self):
        storagePool = libvirt.virStoragePool()
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(mox.IgnoreArg(),
                                mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        cachedStorageVolume = StorageVolume()
        cachedStorageVolume.id = storagePool.UUIDString()
        cachedStorageVolume.size = 0
        cachedStorageVolume.free = 0
        cachedStorageVolume.connectionState = \
            Constants.STORAGE_STATE_ACTIVE
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(storagePool.UUIDString(),
                                                    Constants.StorageVolume).AndReturn(cachedStorageVolume)
#        self.mox.StubOutWithMock(InventoryCacheManager, 'get_compute_conn_driver')
#
#        InventoryCacheManager.get_compute_conn_driver(self.LibvirtStorageVolume.compute_id,
#                Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()
        nova_db.service_get_all_by_topic(None, None)
        self.LibvirtStorageVolume._processStorage(storagePool)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 0)
Example #31
0
 def setUp(self):
     self.fakeConn = libvirt.open('qemu:///system')
     self.libvirt_connection_cls = connection.LibvirtConnection
     super(Test_virt_connection, self).setUp()
     self.flags(healthnmon_notification_drivers=[
         'healthnmon.notifier.log_notifier'
     ])
 def test_test_connection_exception(self):
     self.mox.StubOutWithMock(self.fakeConn, 'getCapabilities')
     self.fakeConn.getCapabilities().AndRaise(libvirt.libvirtError())
     self.mox.ReplayAll()
     conn1 = connection.get_connection(True)
     conn1._wrapped_conn = self.fakeConn
     libvirt.VIR_ERR_SYSTEM_ERROR = 500
     self.assertRaises(libvirt.libvirtError, conn1._test_connection)
     self.mox.UnsetStubs()
Example #33
0
    def _mapLibvirtvmToVm(self):
        '''Create a libvirt Domain object and map it to a healthmon
           Vm object for it
        '''

        domainObj = libvirt.virDomain()
        self.libvirtVM.domainObj = domainObj
        self.libvirtVM.domainUuid = domainObj.UUIDString()
        self.libvirtVM.Vm = Vm()
        self.libvirtVM._mapVmProperties()
        return (domainObj, self.libvirtVM.Vm)
 def setUp(self):
     super(NetworkEventsTest, self).setUp()
     self.connection = LibvirtConnection(False)
     self.connection._wrapped_conn = libvirt.open("qemu:///system")
     rm_context = ComputeRMContext(
         rmType="QEMU", rmIpAddress="10.10.155.165", rmUserName="******", rmPassword="******"
     )
     InventoryCacheManager.get_all_compute_inventory()["1"] = ComputeInventory(rm_context)
     self.libvirtNetwork = LibvirtNetwork(self.connection._wrapped_conn, "1")
     self.flags(healthnmon_notification_drivers=["nova.notifier.test_notifier"])
     test_notifier.NOTIFICATIONS = []
Example #35
0
    def _mapLibvirtvmToVm(self):
        '''Create a libvirt Domain object and map it to a healthmon
           Vm object for it
        '''

        domainObj = libvirt.virDomain()
        self.libvirtVM.domainObj = domainObj
        self.libvirtVM.domainUuid = domainObj.UUIDString()
        self.libvirtVM.Vm = Vm()
        self.libvirtVM._mapVmProperties()
        return (domainObj, self.libvirtVM.Vm)
 def setUpClass(cls):
     cls.connection = LibvirtConnection(False)
     cls.mox = mox.Mox()
     cls.connection._wrapped_conn = libvirt.open('qemu:///system')
     rm_context = ComputeRMContext(
         rmType='fake', rmIpAddress='host', rmUserName='******',
         rmPassword='******')
     cls.connection.init_rmcontext(rm_context)
     cls.connection.libvirt = libvirt
     cls.vm_id = '25f04dd3-e924-02b2-9eac-876e3c943262'
     cls.vmhost_id = '1'
 def setUp(self):
     self.fakeConn = libvirt.open('qemu:///system')
     self.libvirt_connection_cls = connection.LibvirtConnection
     super(Test_virt_connection, self).setUp()
     self.flags(
         healthnmon_notification_drivers=[
             'healthnmon.notifier.log_notifier']
     )
     vmHost = VmHost()
     vmHost.id = '1'
     vmHost.uuid = '1'
     InventoryCacheManager.update_object_in_cache('1', vmHost)
Example #38
0
 def setUpClass(cls):
     cls.connection = LibvirtConnection(False)
     cls.mox = mox.Mox()
     cls.connection._wrapped_conn = libvirt.open('qemu:///system')
     rm_context = ComputeRMContext(rmType='fake',
                                   rmIpAddress='host',
                                   rmUserName='******',
                                   rmPassword='******')
     cls.connection.init_rmcontext(rm_context)
     cls.connection.libvirt = libvirt
     cls.vm_id = '25f04dd3-e924-02b2-9eac-876e3c943262'
     cls.vmhost_id = '1'
Example #39
0
    def testProcessNetworkInterface(self):
        self.mock.StubOutWithMock(api, 'subnet_delete_by_ids')

        api.subnet_delete_by_ids(mox.IgnoreArg(),
                                 mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.ReplayAll()
        self.assertEquals(self.LibvirtNetwork._processNetworkInterface(
            libvirt.virLibvirtInterfaceEth0()),
            None)
        host = InventoryCacheManager.get_object_from_cache(
            '1', Constants.VmHost)
        self.assertTrue(host.get_ipAddresses is not None)
        self.mock.stubs.UnsetAll()
Example #40
0
 def setUp(self):
     self.connection = LibvirtConnection(False)
     vmHost = VmHost()
     vmHost.set_storageVolumeIds([])
     InventoryCacheManager.update_object_in_cache('1', vmHost)
     self.connection._wrapped_conn = libvirt.open('qemu:///system')
     self.LibvirtStorageVolume = \
         LibvirtStorageVolume(self.connection._wrapped_conn, '1')
     self.connection.compute_rmcontext = \
         ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
                          rmUserName='******',
                          rmPassword='******')
     self.mock = mox.Mox()
Example #41
0
 def setUp(self):
     self.connection = LibvirtConnection(False)
     vmHost = VmHost()
     vmHost.set_storageVolumeIds([])
     InventoryCacheManager.update_object_in_cache('1', vmHost)
     self.connection._wrapped_conn = libvirt.open('qemu:///system')
     self.LibvirtStorageVolume = \
         LibvirtStorageVolume(self.connection._wrapped_conn, '1')
     self.connection.compute_rmcontext = \
         ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
                          rmUserName='******',
                          rmPassword='******')
     self.mock = mox.Mox()
Example #42
0
    def testProcessNetwork(self):
        self.mock.StubOutWithMock(api, 'subnet_save')

        api.subnet_save(mox.IgnoreArg(),
                        mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.ReplayAll()
        self.assertEquals(self.LibvirtNetwork._processVirtualNetwork(
            libvirt.virLibvirtNetwork()),
            None)
        subnet = InventoryCacheManager.get_object_from_cache(
            'Subnet_52:54:00:34:14:AE', Constants.Network)
        self.assertTrue(subnet is not None)
        self.assertFalse(subnet.get_isBootNetwork())
        self.assertEquals('default', subnet.get_name())
        self.mock.stubs.UnsetAll()
Example #43
0
 def setUp(self):
     super(NetworkEventsTest, self).setUp()
     self.connection = LibvirtConnection(False)
     self.connection._wrapped_conn = libvirt.open("qemu:///system")
     rm_context = ComputeRMContext(rmType='QEMU',
                                   rmIpAddress='10.10.155.165',
                                   rmUserName='******',
                                   rmPassword='******')
     InventoryCacheManager.get_all_compute_inventory()['1'] = \
         ComputeInventory(rm_context)
     self.libvirtNetwork = LibvirtNetwork(self.connection._wrapped_conn,
                                          '1')
     self.flags(
         healthnmon_notification_drivers=['nova.notifier.test_notifier'])
     test_notifier.NOTIFICATIONS = []
Example #44
0
    def testProcessNetwork(self):
        self.mock.StubOutWithMock(api, 'subnet_save')

        api.subnet_save(mox.IgnoreArg(),
                        mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.ReplayAll()
        self.assertEquals(self.LibvirtNetwork._processVirtualNetwork(
            libvirt.virLibvirtNetwork()),
            None)
        subnet = InventoryCacheManager.get_object_from_cache(
            'Subnet_52:54:00:34:14:AE', Constants.Network)
        self.assertTrue(subnet is not None)
        self.assertFalse(subnet.get_isBootNetwork())
        self.assertEquals('default', subnet.get_name())
        self.mock.stubs.UnsetAll()
Example #45
0
 def setUp(self):
     super(NetworkEventsTest, self).setUp()
     self.connection = LibvirtConnection(False)
     self.connection._wrapped_conn = libvirt.open("qemu:///system")
     rm_context = ComputeRMContext(
         rmType='QEMU', rmIpAddress='10.10.155.165',
         rmUserName='******',
         rmPassword='******')
     InventoryCacheManager.get_all_compute_inventory()['1'] = \
         ComputeInventory(rm_context)
     self.libvirtNetwork = LibvirtNetwork(
         self.connection._wrapped_conn, '1')
     self.flags(
         healthnmon_notification_drivers=['nova.notifier.test_notifier'])
     test_notifier.NOTIFICATIONS = []
 def setUp(self):
     super(test_LibvirtStorage, self).setUp()
     self.connection = LibvirtConnection(False)
     vmHost = VmHost()
     vmHost.set_storageVolumeIds([])
     InventoryCacheManager.update_object_in_cache('1', vmHost)
     self.connection._wrapped_conn = libvirt.open('qemu:///system')
     self.LibvirtStorageVolume = \
         LibvirtStorageVolume(self.connection._wrapped_conn, '1')
     self.connection.compute_rmcontext = \
         ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
                          rmUserName='******',
                          rmPassword='******')
     cfg.CONF.set_override('healthnmon_notification_drivers',
                           ['healthnmon.notifier.log_notifier'])
     self.mock = mox.Mox()
Example #47
0
    def setUp(self):
        self.connection = LibvirtConnection(False)
        self.vmHost = VmHost()
        self.vmHost.set_virtualMachineIds([])
        InventoryCacheManager.update_object_in_cache('1', self.vmHost)

        #self.connection.setUuid('34353438-3934-434e-3738-313630323543')
        self.connection._wrapped_conn = libvirt.open('qemu:///system')
        self.libvirtVM = LibvirtVM(self.connection._wrapped_conn,
                                   '1')
        self.libvirtVM.vmHost.set_id('1')
        self.connection.compute_rmcontext = \
            ComputeRMContext(rmType='QEMU', rmIpAddress='10.10.155.165',
                             rmUserName='******',
                             rmPassword='******')
        self.mock = mox.Mox()
        cfg.CONF.set_override('healthnmon_notification_drivers',
                              ['healthnmon.notifier.log_notifier'])
Example #48
0
    def setUp(self):
        self.connection = LibvirtConnection(False)
        self.vmHost = VmHost()
        self.vmHost.set_virtualMachineIds([])
        InventoryCacheManager.update_object_in_cache('1', self.vmHost)

        #self.connection.setUuid('34353438-3934-434e-3738-313630323543')
        self.connection._wrapped_conn = libvirt.open('qemu:///system')
        self.libvirtVM = LibvirtVM(self.connection._wrapped_conn,
                                   '1')
        self.libvirtVM.vmHost.set_id('1')
        self.connection.compute_rmcontext = \
            ComputeRMContext(rmType='QEMU', rmIpAddress='10.10.155.165',
                             rmUserName='******',
                             rmPassword='******')
        self.mock = mox.Mox()
        cfg.CONF.set_override('healthnmon_notification_drivers',
                              ['healthnmon.notifier.log_notifier'])
Example #49
0
 def setUp(self):
     self.connection = LibvirtConnection(False)
     vmHost = VmHost()
     vSwitch = VirtualSwitch()
     vSwitch.set_id('52:54:00:34:14:AE')
     vSwitch.set_name('default')
     vSwitch.set_switchType('nat')
     vmHost.set_virtualSwitches([vSwitch])
     InventoryCacheManager.update_object_in_cache('1', vmHost)
     #self.connection.setUuid('34353438-3934-434e-3738-313630323543')
     self.connection._wrapped_conn = libvirt.open('qemu:///system')
     self.connection.compute_rmcontext = \
         ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
                          rmUserName='******',
                          rmPassword='******')
     self.LibvirtNetwork = LibvirtNetwork(self.connection, '1')
     self.mock = mox.Mox()
     cfg.CONF.set_override('healthnmon_notification_drivers',
                           ['healthnmon.notifier.log_notifier'])
Example #50
0
 def setUp(self):
     self.connection = LibvirtConnection(False)
     vmHost = VmHost()
     vSwitch = VirtualSwitch()
     vSwitch.set_id('52:54:00:34:14:AE')
     vSwitch.set_name('default')
     vSwitch.set_switchType('nat')
     vmHost.set_virtualSwitches([vSwitch])
     InventoryCacheManager.update_object_in_cache('1', vmHost)
     #self.connection.setUuid('34353438-3934-434e-3738-313630323543')
     self.connection._wrapped_conn = libvirt.open('qemu:///system')
     self.connection.compute_rmcontext = \
         ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
                          rmUserName='******',
                          rmPassword='******')
     self.LibvirtNetwork = LibvirtNetwork(self.connection, '1')
     self.mock = mox.Mox()
     cfg.CONF.set_override('healthnmon_notification_drivers',
                           ['healthnmon.notifier.log_notifier'])
Example #51
0
    def test_processVm(self):
        self.mock.StubOutWithMock(api, 'vm_save')

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(mox.IgnoreArg(),
                                         mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.ReplayAll()
        self.assertEquals(self.libvirtVM._processVm(libvirt.virDomain()),
                          None)
        vm = InventoryCacheManager.get_object_from_cache(
            "25f04dd3-e924-02b2-9eac-876e3c943262", Constants.Vm)
        #self.assertEquals('Disconnected', vm.get_connectionState())
#        self.assertEquals('TestVirtMgrVM7', str(vm.get_name()))
        self.assertEquals("1048576", str(vm.get_memorySize()))
        #self.assertEquals("hd", str(vm.get_bootOrder()).strip())

        self.mock.stubs.UnsetAll()
Example #52
0
    def test_processStorage(self):
        self.mock.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(mox.IgnoreArg(),
                                mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.ReplayAll()
        self.assertEquals(
            self.LibvirtStorageVolume._processStorage(
                libvirt.virStoragePool()),
            None)
        host = InventoryCacheManager.get_object_from_cache(
            '1', Constants.VmHost)
        storage = InventoryCacheManager.get_object_from_cache(
            '95f7101b-892c-c388-867a-8340e5fea27a', Constants.StorageVolume)
        self.assertTrue('95f7101b-892c-c388-867a-8340e5fea27a',
                        host.get_storageVolumeIds())
        self.assertTrue(storage is not None)
        self.assertEquals('default', storage.get_name())
        self.assertEquals('34353438-3934-434e-3738-313630323543',
                          storage.get_resourceManagerId())
        self.mock.stubs.UnsetAll()
Example #53
0
    def test_storage_disabled_event(self):
        storagePool = libvirt.virStoragePool()
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(
            mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        cachedStorageVolume = StorageVolume()
        cachedStorageVolume.id = storagePool.UUIDString()
        cachedStorageVolume.size = 0
        cachedStorageVolume.free = 0
        cachedStorageVolume.connectionState = \
            Constants.STORAGE_STATE_ACTIVE
        self.mox.StubOutWithMock(InventoryCacheManager,
                                 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            storagePool.UUIDString(),
            Constants.StorageVolume).AndReturn(cachedStorageVolume)
        self.mox.StubOutWithMock(storagePool, 'isActive')
        storagePool.isActive().AndReturn(0)

        #        self.mox.StubOutWithMock(InventoryCacheManager, 'get_compute_conn_driver')
        #
        #        InventoryCacheManager.get_compute_conn_driver(self.LibvirtStorageVolume.compute_id,
        #                Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()
        self.LibvirtStorageVolume._processStorage(storagePool)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.WARN)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_STORAGE_DISABLED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'StorageVolume')
        self.assertEquals(payload['entity_id'], storagePool.UUIDString())
        self.assertEquals(payload['state'], Constants.STORAGE_STATE_INACTIVE)
Example #54
0
    def setUp(self):
        self.connection = LibvirtConnection(False)
        vmHost = VmHost()
        vmHost.set_virtualMachineIds([])

        rm_context = ComputeRMContext(
            rmType='QEMU', rmIpAddress='10.10.155.165',
            rmUserName='******',
            rmPassword='******')

        InventoryCacheManager.update_object_in_cache('1', vmHost)
        InventoryCacheManager.get_all_compute_inventory()['1'] = \
            ComputeInventory(rm_context)

        self.connection._wrapped_conn = libvirt.open('qemu:///system')
        libvirtEvents = LibvirtEvents()
        self.libvirtVmHost = LibvirtVmHost(
            self.connection._wrapped_conn, '1', libvirtEvents)
        self.connection.compute_rmcontext = rm_context
        self.mock = mox.Mox()
        cfg.CONF.set_override('healthnmon_notification_drivers',
                              ['healthnmon.notifier.log_notifier'])
Example #55
0
    def setUp(self):
        self.mock = mox.Mox()
        self.connection = LibvirtConnection(False)
        self.connection._wrapped_conn = libvirt.open('qemu:///system')
        vmHost = VmHost()
        InventoryCacheManager.update_object_in_cache('1', vmHost)
        self.connection.compute_rmcontext = \
            ComputeRMContext(rmType='fake', rmIpAddress='10.10.155.165',
                             rmUserName='******',
                             rmPassword='******')
        InventoryCacheManager.get_all_compute_inventory()['1'] = \
            ComputeInventory(self.connection.compute_rmcontext)
        self.mock.StubOutWithMock(LibvirtConnection, '_connect')

        self.connection._connect(mox.IgnoreArg(),
                                 mox.IgnoreArg()).AndRaise(libvirt.libvirtError)
        self.mock.ReplayAll()
        self.inventoryMonitor = LibvirtInventoryMonitor()
#        self.libvirtVmHost = LibvirtVmHost(self.connection, '1')
        cfg.CONF.set_override('healthnmon_notification_drivers',
                              ['healthnmon.notifier.log_notifier'])
        self.libvirtInventoryMonitor = LibvirtInventoryMonitor()
Example #56
0
    def setUp(self):
        super(VmHostEventsTest, self).setUp()
        self.connection = LibvirtConnection(False)
        vmHost = VmHost()
        vmHost.set_virtualMachineIds([])
        InventoryCacheManager.update_object_in_cache('1', vmHost)

        rm_context = ComputeRMContext(rmType='QEMU',
                                      rmIpAddress='10.10.155.165',
                                      rmUserName='******',
                                      rmPassword='******')

        InventoryCacheManager.update_object_in_cache('1', vmHost)
        InventoryCacheManager.get_all_compute_inventory()['1'] = \
            ComputeInventory(rm_context)

        self.connection._wrapped_conn = libvirt.open('qemu:///system')
        libvirtEvents = LibvirtEvents()
        self.libvirtVmHost = LibvirtVmHost(self.connection._wrapped_conn, '1',
                                           libvirtEvents)
        self.connection.compute_rmcontext = rm_context
        self.flags(
            healthnmon_notification_drivers=['nova.notifier.test_notifier'])
        test_notifier.NOTIFICATIONS = []
Example #57
0
    def test_vm_created_event(self):
        domainObj = libvirt.virDomain()
        self.mox.StubOutWithMock(api, 'vm_save')

        api.vm_save(mox.IgnoreArg(),
                    mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.StubOutWithMock(InventoryCacheManager,
                                 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            domainObj.UUIDString(), Constants.Vm).AndReturn(None)
        self.mox.ReplayAll()
        self.libvirtVM._processVm(domainObj)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_VM_CREATED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'Vm')
        self.assertEquals(payload['entity_id'], domainObj.UUIDString())
Example #58
0
 def test_deregister_libvirt_domain_events(self):
     libvirtEvents = libvirt_event_monitor.LibvirtEvents()
     libvirtEvents.call_back_ids['domain_events'] = [1]
     libvirtEvents.libvirt_con = libvirt.open("fake:///system")
     libvirtEvents._deregister_libvirt_domain_events()