本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.Vm.add_vmDisks方法的典型用法代码示例。如果您正苦于以下问题:Python Vm.add_vmDisks方法的具体用法?Python Vm.add_vmDisks怎么用?Python Vm.add_vmDisks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.resourcemodel.healthnmonResourceModel.Vm
的用法示例。
在下文中一共展示了Vm.add_vmDisks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_diff_resourcemodel_vm_with_type_changesandupdate
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import add_vmDisks [as 别名]
def test_diff_resourcemodel_vm_with_type_changesandupdate(self):
old_vm = Vm()
old_vm.set_id(unicode('vm-01'))
old_vm.set_name(unicode('vm-01'))
disk1 = VmDisk()
disk1.set_id(unicode('disk-01'))
disk1.set_storageVolumeId(unicode("datastore-939"))
old_vm.add_vmDisks(disk1)
old_vm.set_vmHostId(unicode('host-329'))
new_vm = Vm()
new_vm.set_id('vm-01')
new_vm.set_name('vm-01')
disk3 = VmDisk()
disk3.set_id('disk-01')
disk3.set_storageVolumeId("datastore-939-999")
new_vm.add_vmDisks(disk3)
new_vm.set_vmHostId('host-329')
diff = ResourceModelDiff(old_vm, new_vm)
diff_res = diff.diff_resourcemodel()
self.assertTrue(len(diff_res) > 0)
self.assertTrue(self.update in diff_res)
vmDisks = 'vmDisks'
self.assertTrue(vmDisks in diff_res[self.update])
self.assertTrue(self.update in diff_res[self.update][vmDisks])
self.assertTrue('disk-01' in diff_res[self.update][vmDisks][
self.update])
self.assertTrue(self.update in diff_res[self.update][vmDisks][
self.update]['disk-01'])
self.assertTrue('storageVolumeId' in diff_res[self.update][vmDisks][
self.update]['disk-01'][self.update])
self.assertEquals(diff_res[self.update][vmDisks][self.update][
'disk-01'][self.update]['storageVolumeId'], 'datastore-939-999')
示例2: get_vm_list
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import add_vmDisks [as 别名]
def get_vm_list(self):
vm_list = []
vm = Vm()
vm.set_id('vm-01')
vm.set_name('vm-01')
disk = VmDisk()
disk.set_storageVolumeId('datastore-999')
vm.set_vmHostId('host-1234')
vm.add_vmDisks(disk)
vm_list.append(vm)
vm = Vm()
vm.set_id('vm-02')
vm.set_name('vm-02')
vm_list.append(vm)
return vm_list
示例3: get_single_vm
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import add_vmDisks [as 别名]
def get_single_vm(self):
vm_list = []
vm = Vm()
vm.set_id('vm-01')
vm.set_name('vm-01')
disk1 = VmDisk()
disk1.set_id('disk-01')
disk1.set_storageVolumeId('datastore-939')
disk2 = VmDisk()
disk2.set_id('disk-02')
disk2.set_storageVolumeId('datastore-439')
vm.add_vmDisks(disk1)
vm.add_vmDisks(disk2)
vm.set_vmHostId('host-329')
vm_list.append(vm)
return vm_list
示例4: test_storagevolume_delete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import add_vmDisks [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')
示例5: test_diff_resourcemodel_vm_with_type_changes
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import add_vmDisks [as 别名]
def test_diff_resourcemodel_vm_with_type_changes(self):
old_vm = Vm()
old_vm.set_id(unicode('vm-01'))
old_vm.set_name(unicode('vm-01'))
disk1 = VmDisk()
disk1.set_id(unicode('disk-01'))
disk1.set_storageVolumeId(unicode("datastore-939"))
old_vm.add_vmDisks(disk1)
old_vm.set_vmHostId(unicode('host-329'))
new_vm = Vm()
new_vm.set_id('vm-01')
new_vm.set_name('vm-01')
disk3 = VmDisk()
disk3.set_id('disk-01')
disk3.set_storageVolumeId("datastore-939")
new_vm.add_vmDisks(disk3)
new_vm.set_vmHostId('host-329')
diff = ResourceModelDiff(old_vm, new_vm)
diff_res = diff.diff_resourcemodel()
self.assertTrue(len(diff_res) == 0)
示例6: test_diff_resourcemodel_vm_withaddupdtedelete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import add_vmDisks [as 别名]
def test_diff_resourcemodel_vm_withaddupdtedelete(self):
vm = Vm()
vm.set_id('vm-01')
vm.set_name('vm-01')
disk1 = VmDisk()
disk1.set_id('disk-01')
disk1.set_storageVolumeId('datastore-939')
disk2 = VmDisk()
disk2.set_id('disk-02')
disk2.set_storageVolumeId('datastore-439')
vm.add_vmDisks(disk1)
vm.add_vmDisks(disk2)
vm.set_vmHostId('host-329')
vm1 = Vm()
vm1.set_id('vm-01')
vm1.set_name('vm-01')
disk11 = VmDisk()
disk11.set_id('disk-01')
disk11.set_storageVolumeId('datastore-939-999')
disk21 = VmDisk()
disk21.set_id('disk-03')
disk21.set_storageVolumeId('datastore-439-999')
vm1.add_vmDisks(disk11)
vm1.add_vmDisks(disk21)
vm1.set_vmHostId('host-329-999')
diff = ResourceModelDiff(vm, vm1)
diff_res = diff.diff_resourcemodel()
self.assertTrue(len(diff_res) > 0)
self.assertTrue(self.update in diff_res)
vmDisks = 'vmDisks'
self.assertTrue(vmDisks in diff_res[self.update])
self.assertTrue(self.add in diff_res[self.update][vmDisks])
self.assertTrue('disk-03' in diff_res[self.update][vmDisks][self.add])
self.assertTrue(isinstance(diff_res[self.update][vmDisks][self.add][
'disk-03'], VmDisk))
addVmdisk = diff_res[self.update][vmDisks][self.add]['disk-03']
self.assertEquals(addVmdisk.get_storageVolumeId(), 'datastore-439-999')
self.assertTrue(self.delete in diff_res[self.update][vmDisks])
self.assertTrue('disk-02' in diff_res[self.update][vmDisks][
self.delete])
self.assertTrue(isinstance(diff_res[self.update][vmDisks][
self.delete]['disk-02'], VmDisk))
delVmdisk = diff_res[self.update][vmDisks][self.delete]['disk-02']
self.assertEquals(delVmdisk.get_storageVolumeId(), 'datastore-439')
self.assertTrue(self.update in diff_res[self.update][vmDisks])
self.assertTrue('disk-01' in diff_res[self.update][vmDisks][
self.update])
self.assertTrue(self.update in diff_res[self.update][vmDisks][
self.update]['disk-01'])
self.assertTrue('storageVolumeId' in diff_res[self.update][vmDisks][
self.update]['disk-01'][self.update])
self.assertEquals(diff_res[self.update][vmDisks][self.update][
'disk-01'][self.update]['storageVolumeId'],
'datastore-939-999')
self.assertTrue('vmHostId' in diff_res[self.update])
self.assertEquals(diff_res[self.update]['vmHostId'], 'host-329-999')