本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.Vm.set_vmGlobalSettings方法的典型用法代码示例。如果您正苦于以下问题:Python Vm.set_vmGlobalSettings方法的具体用法?Python Vm.set_vmGlobalSettings怎么用?Python Vm.set_vmGlobalSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.resourcemodel.healthnmonResourceModel.Vm
的用法示例。
在下文中一共展示了Vm.set_vmGlobalSettings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_vm_save_update
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import set_vmGlobalSettings [as 别名]
def test_vm_save_update(self):
'''
Update an existing object in db
'''
vm = Vm()
vm.id = 'VM1-id'
healthnmon_db_api.vm_save(get_admin_context(), vm)
vmGlobalSettings = VmGlobalSettings()
vmGlobalSettings.set_id(vm.id)
vmGlobalSettings.set_autoStartAction('autoStartAction')
vmGlobalSettings.set_autoStopAction('autoStopAction')
vm.set_vmGlobalSettings(vmGlobalSettings)
healthnmon_db_api.vm_save(get_admin_context(), vm)
vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), [vm.id])
self.assertTrue(vms is not None)
self.assertTrue(len(vms) == 1)
vm = vms[0]
self.assertEqual(vm.get_id(), 'VM1-id', "VM id is not same")
vmGlobalSets = vm.get_vmGlobalSettings()
self.assertTrue(vmGlobalSets is not None)
self.assertEqual(vmGlobalSets.get_id(), 'VM1-id', "VM id is not same")
self.assertEqual(vmGlobalSets.get_autoStartAction(),
'autoStartAction', "autoStartAction is not same")
self.assertEqual(vmGlobalSets.get_autoStopAction(),
'autoStopAction', "autoStopAction is not same")
示例2: test_vm_delete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import set_vmGlobalSettings [as 别名]
def test_vm_delete(self):
vm = Vm()
vm_id = 'VM1'
vm.id = vm_id
vmGlobalSettings = VmGlobalSettings()
vmGlobalSettings.set_id(vm_id)
vm.set_vmGlobalSettings(vmGlobalSettings)
healthnmon_db_api.vm_save(get_admin_context(), vm)
vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(),
[vm_id])
self.assertFalse(vms is None,
'VM get by id returned a none list')
self.assertTrue(len(vms) > 0,
'VM get by id returned invalid number of list')
healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm_id])
vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(),
[vm_id])
self.assertTrue(vms is None or len(vms) == 0, 'VM not deleted')
示例3: test_storagevolume_delete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import set_vmGlobalSettings [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')
示例4: test_vm_host_get_all
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import Vm [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.Vm import set_vmGlobalSettings [as 别名]
def test_vm_host_get_all(self):
'''
Inserts more than one host with vms and storage volumes.
Also validates the data retrieved from the vmhost, vm, storage volumes.
'''
vmhost = VmHost()
vmhost.id = 'VH1-id'
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
vmhost = VmHost()
vmhost.id = 'VH2-id'
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
vm = Vm()
vm.id = 'VM1-id'
vm.set_vmHostId('VH1-id')
vmGlobalSettings = VmGlobalSettings()
vmGlobalSettings.set_id(vm.id)
vmGlobalSettings.set_autoStartAction('autoStartAction')
vmGlobalSettings.set_autoStopAction('autoStopAction')
vm.set_vmGlobalSettings(vmGlobalSettings)
healthnmon_db_api.vm_save(get_admin_context(), vm)
mntPnt = HostMountPoint()
mntPnt.set_vmHostId('VH1-id')
mntPnt.set_path('/path')
volume = StorageVolume()
sv_id = 'SV1-id'
volume.set_id(sv_id)
volume.add_mountPoints(mntPnt)
healthnmon_db_api.storage_volume_save(get_admin_context(), volume)
vmhosts = healthnmon_db_api.vm_host_get_all(get_admin_context())
self.assertFalse(vmhosts is None,
'vm_host_get_all returned a None')
self.assertTrue(
len(vmhosts) == 2,
'vm_host_get_all does not returned expected number of hosts')
self.assertEqual(vmhosts[0].get_id(),
'VH1-id', "VMHost id is not same")
self.assertEqual(vmhosts[1].get_id(),
'VH2-id', "VMHost id is not same")
vmlist = vmhosts[0].get_virtualMachineIds()
self.assertFalse(vmlist is None,
"virtual machines from the host returned None")
self.assertTrue(
len(vmlist) == 1,
"length of virtual machines list is not returned as expected")
self.assertTrue(vm.id in vmlist,
"VmId is not in host")
vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), ['VM1-id'])
self.assertTrue(vms is not None)
self.assertTrue(len(vms) == 1)
vm = vms[0]
self.assertEqual(vm.get_id(), 'VM1-id', "VM id is not same")
vmGlobalSets = vm.get_vmGlobalSettings()
self.assertTrue(vmGlobalSets is not None)
self.assertEqual(vmGlobalSets.get_id(), 'VM1-id', "VM id is not same")
self.assertEqual(vmGlobalSets.get_autoStartAction(),
'autoStartAction', "autoStartAction is not same")
self.assertEqual(vmGlobalSets.get_autoStopAction(),
'autoStopAction', "autoStopAction is not same")
svlist = vmhosts[0].get_storageVolumeIds()
self.assertFalse(svlist is None,
"Storage Volumes from the host returned None")
self.assertTrue(
len(svlist) >= 1,
"length of storage volumes list is not returned as expected")
self.assertTrue(sv_id in svlist,
"Storage Volume Id is not host")
storagevolumes = \
healthnmon_db_api.storage_volume_get_by_ids(get_admin_context(),
['SV1-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.assertEquals(storagevolumes[0].id,
'SV1-id', "Storage volume id is not same")
hostMountPoints = storagevolumes[0].get_mountPoints()
self.assertEquals(hostMountPoints[0].get_path(),
'/path', "Host mount point path is not same")
self.assertEquals(
hostMountPoints[0].get_vmHostId(),
'VH1-id', "VmHost id is not same for storage volumes")