本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume.id方法的典型用法代码示例。如果您正苦于以下问题:Python StorageVolume.id方法的具体用法?Python StorageVolume.id怎么用?Python StorageVolume.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume
的用法示例。
在下文中一共展示了StorageVolume.id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_storagevolume_save
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [as 别名]
def test_storagevolume_save(self):
storagevolume = StorageVolume()
storagevolume.id = 'SV1'
healthnmon_db_api.storage_volume_save(self.admin_context,
storagevolume)
healthnmon_db_api.storage_volume_save(self.admin_context,
storagevolume)
示例2: test_storage_deleted_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [as 别名]
def test_storage_deleted_event(self):
self.mox.StubOutWithMock(api, 'storage_volume_delete_by_ids')
api.storage_volume_delete_by_ids(
mox.IgnoreArg(),
mox.IgnoreArg()).MultipleTimes().AndReturn(None)
self.mox.StubOutWithMock(
InventoryCacheManager, 'get_object_from_cache')
deleted_storage_id = '3fbfbefb-17dd-07aa-2dac-13afbedf3be3'
deleted_storage = StorageVolume()
deleted_storage.id = deleted_storage_id
InventoryCacheManager.get_object_from_cache(
deleted_storage_id,
Constants.StorageVolume).AndReturn(deleted_storage)
self.mox.ReplayAll()
cachedList = [deleted_storage_id,
'3fbfbefb-17dd-07aa-2dac-13afbedf1234']
updatedList = ['3fbfbefb-17dd-07aa-2dac-13afbedf1234']
self.mox.ReplayAll()
self.LibvirtStorageVolume.processStorageDeletes(cachedList,
updatedList)
self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
msg = test_notifier.NOTIFICATIONS[0]
self.assertEquals(msg['priority'], notifier_api.INFO)
eventMetaData = \
event_metadata.get_EventMetaData(
event_metadata.EVENT_TYPE_STORAGE_DELETED)
event_type = eventMetaData.get_event_fully_qal_name()
self.assertEquals(msg['event_type'], event_type)
payload = msg['payload']
self.assertEquals(payload['entity_type'], 'StorageVolume')
self.assertEquals(payload['entity_id'], deleted_storage_id)
示例3: test_storage_enabled_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [as 别名]
def test_storage_enabled_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_INACTIVE
self.mox.StubOutWithMock(
InventoryCacheManager, 'get_object_from_cache')
InventoryCacheManager.get_object_from_cache(
storagePool.UUIDString(),
Constants.StorageVolume).AndReturn(cachedStorageVolume)
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_ENABLED)
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_ACTIVE)
示例4: test_storage_no_state_change
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [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)
示例5: test_storagevolume_get_all
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [as 别名]
def test_storagevolume_get_all(self):
storagevolume = StorageVolume()
storagevolume.id = 'SV1'
healthnmon_db_api.storage_volume_save(self.admin_context,
storagevolume)
storagevolume = StorageVolume()
storagevolume.id = 'SV2'
healthnmon_db_api.storage_volume_save(self.admin_context,
storagevolume)
storagevolumes = \
healthnmon_db_api.storage_volume_get_all(self.admin_context)
self.assertFalse(storagevolumes is None,
'storage volume all returned a none list')
self.assertTrue(len(storagevolumes) == 2,
'storage volume all returned invalid number of list'
)
self.assertTrue(
storagevolumes[0].id == 'SV1', 'Storage volume id mismatch')
self.assertTrue(
storagevolumes[1].id == 'SV2', 'Storage volume id mismatch')
示例6: test_storagevolume_get_by_id
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [as 别名]
def test_storagevolume_get_by_id(self):
storagevolume_id = 'SV1'
storagevolume = StorageVolume()
storagevolume.id = storagevolume_id
healthnmon_db_api.storage_volume_save(self.admin_context,
storagevolume)
storagevolumes = \
healthnmon_db_api.storage_volume_get_by_ids(self.admin_context,
[storagevolume_id])
self.assertFalse(storagevolumes is None,
'storage volume get by id returned a none list'
)
self.assertTrue(
len(storagevolumes) > 0,
'storage volume get by id returned invalid number of list')
self.assertTrue(storagevolumes[0].id == 'SV1')
示例7: testVmHostPayload_with_storage_size
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [as 别名]
def testVmHostPayload_with_storage_size(self):
self.flags(instances_path="/var/lib/nova/instances")
metadata = \
event_metadata.get_EventMetaData(
event_metadata.EVENT_TYPE_HOST_ADDED)
obj = VmHost()
obj.name = 'TestVmHost'
ipProfile = IpProfile()
ipProfile.ipAddress = '10.10.10.1'
obj.add_ipAddresses(ipProfile)
storage_obj = StorageVolume()
storage_obj.id = "storage_id"
storage_obj.name = 'TestStorageVolume'
storage_obj.connectionState = 'ACTIVE'
storage_obj.size = 200
storage_obj.free = 100
storage_obj.volumeType = 'DIR'
storage_obj.volumeId = 'TestVolumeId'
storage_obj.createEpoch = long(time.time() * 1000)
storage_obj.lastModifiedEpoch = long(time.time() * 1000)
mount_point = HostMountPoint()
mount_point.set_path('/var/lib/nova/instances')
mount_point.set_vmHostId('TestVmHost')
storage_obj.add_mountPoints(mount_point)
obj.add_storageVolumeIds("storage_id")
self.mox.StubOutWithMock(
InventoryCacheManager, 'get_object_from_cache')
InventoryCacheManager.get_object_from_cache(
storage_obj.id,
Constants.StorageVolume).AndReturn(storage_obj)
self.mox.ReplayAll()
payload = payload_generator.generate_payload(metadata, obj)
self.assertEquals(payload['entity_type'],
obj.__class__.__name__)
self.assertEquals(payload['name'], obj.name)
self.assertEquals(payload['ipAddresses'],
ipProfile.ipAddress)
self.assertEquals(payload['totalStorageSize'],
storage_obj.size)
self.assertEquals(payload['storageUsed'],
storage_obj.free)
示例8: test_storagevolume_delete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [as 别名]
def test_storagevolume_delete(self):
storagevolume = StorageVolume()
storagevolume_id = 'SV1'
storagevolume.id = storagevolume_id
vm = Vm()
vm.set_id('vm-01')
vmGlobalSettings = VmGlobalSettings()
vmGlobalSettings.set_id('vm_01')
vm.set_vmGlobalSettings(vmGlobalSettings)
vmDisk = VmDisk()
vmDisk.set_id('disk-01')
vmDisk.set_storageVolumeId(storagevolume_id)
vm.add_vmDisks(vmDisk)
vmDisk = VmDisk()
vmDisk.set_id('disk-02')
vmDisk.set_storageVolumeId('SV2')
vm.add_vmDisks(vmDisk)
healthnmon_db_api.vm_save(self.admin_context, vm)
healthnmon_db_api.storage_volume_save(self.admin_context,
storagevolume)
storagevolumes = \
healthnmon_db_api.storage_volume_get_by_ids(self.admin_context,
[storagevolume_id])
self.assertFalse(storagevolumes is None,
'storage volume get by id returned a none list'
)
self.assertTrue(
len(storagevolumes) > 0,
'storage volume get by id returned invalid number of list')
healthnmon_db_api.storage_volume_delete_by_ids(self.admin_context,
[storagevolume_id])
storagevolumes = \
healthnmon_db_api.storage_volume_get_by_ids(self.admin_context,
[storagevolume_id])
self.assertTrue(storagevolumes is None or len(storagevolumes)
== 0, 'Storage volume not deleted')
示例9: test_processUpdates_hostupdate_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import StorageVolume [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.StorageVolume import id [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()