本文整理汇总了Python中healthnmon.tests.FakeLibvirt.virDomain方法的典型用法代码示例。如果您正苦于以下问题:Python FakeLibvirt.virDomain方法的具体用法?Python FakeLibvirt.virDomain怎么用?Python FakeLibvirt.virDomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.tests.FakeLibvirt
的用法示例。
在下文中一共展示了FakeLibvirt.virDomain方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_vm_created_event
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
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())
示例2: test_process_updates_for_updated_VM
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
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()
示例3: test_processVmForIPAddress
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
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')
示例4: test_process_updates_for_updated_VM_exception
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
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()
示例5: test_processVm_disk_exception_next_retry
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
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()
示例6: _mapLibvirtvmToVm
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
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)
示例7: test_processVm
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
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()
示例8: test_processStorageException
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virDomain [as 别名]
def test_processStorageException(self):
self.assertEquals(self.LibvirtStorageVolume._processStorage(
libvirt.virDomain()),
None)
self.assertRaises(Exception, self.LibvirtStorageVolume)