本文整理汇总了Python中healthnmon.tests.FakeLibvirt.virStoragePool方法的典型用法代码示例。如果您正苦于以下问题:Python FakeLibvirt.virStoragePool方法的具体用法?Python FakeLibvirt.virStoragePool怎么用?Python FakeLibvirt.virStoragePool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.tests.FakeLibvirt
的用法示例。
在下文中一共展示了FakeLibvirt.virStoragePool方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_storage_added_event
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virStoragePool [as 别名]
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())
示例2: test_storage_no_state_change
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virStoragePool [as 别名]
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)
示例3: test_processStorage
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virStoragePool [as 别名]
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.mock.stubs.UnsetAll()
示例4: test_storage_disabled_event
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virStoragePool [as 别名]
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)
示例5: test_processUpdates_hostupdate_event
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import virStoragePool [as 别名]
def test_processUpdates_hostupdate_event(self):
defaultInstancesPath = cfg.CONF.instances_path
cfg.CONF.set_override('instances_path', '/var/lib/libvirt/images')
storagePool = libvirt.virStoragePool()
self.mock.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_INACTIVE
InventoryCacheManager.update_object_in_cache(
'95f7101b-892c-c388-867a-8340e5fea27x', cachedStorageVolume)
self.mock.StubOutWithMock(api, 'storage_volume_delete_by_ids')
api.storage_volume_delete_by_ids(mox.IgnoreArg(),
mox.IgnoreArg()).MultipleTimes().\
AndReturn(None)
self.mock.StubOutWithMock(
InventoryCacheManager, 'get_compute_conn_driver')
InventoryCacheManager.get_compute_conn_driver(None,
Constants.VmHost).\
AndReturn(fake.
get_connection())
self.mock.ReplayAll()
self.assertEquals(self.LibvirtStorageVolume.processUpdates(),
None)
self.assertEquals(self.LibvirtStorageVolume._createNovaPool(),
None)
cfg.CONF.set_override('instances_path', defaultInstancesPath)
self.mock.stubs.UnsetAll()