本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.VmHost.id方法的典型用法代码示例。如果您正苦于以下问题:Python VmHost.id方法的具体用法?Python VmHost.id怎么用?Python VmHost.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.resourcemodel.healthnmonResourceModel.VmHost
的用法示例。
在下文中一共展示了VmHost.id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_portGroup_added_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_portGroup_added_event(self):
cachedHost = VmHost()
cachedHost.id = self.libvirtNetwork.compute_id
vmhost = VmHost()
vmhost.id = self.libvirtNetwork.compute_id
vswitch = VirtualSwitch()
vswitch.set_id("11")
vswitch.set_name("vs1")
portGroup = PortGroup()
portGroup.set_id("PortGroup_" + vswitch.get_id())
portGroup.set_name(vswitch.get_name())
portGroup.set_virtualSwitchId(vswitch.get_id())
vswitch.set_portGroups([portGroup])
vmhost.set_virtualSwitches([vswitch])
vmhost.set_portGroups([portGroup])
self.libvirtNetwork._processNetworkEvents(cachedHost, vmhost)
self.assertEquals(len(test_notifier.NOTIFICATIONS), 2)
msg = test_notifier.NOTIFICATIONS[1]
self.assertEquals(msg['priority'], notifier_api.INFO)
event_type = event_metadata.get_EventMetaData(
event_metadata.EVENT_TYPE_PORTGROUP_ADDED)
self.assertEquals(msg['event_type'],
event_type.get_event_fully_qal_name())
payload = msg['payload']
self.assertEquals(payload['entity_type'], 'PortGroup')
self.assertEquals(payload['entity_id'], portGroup.get_id())
示例2: test_host_disconnected_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_host_disconnected_event(self):
self.__mock_service_get_all_by_topic()
backedUp_libvirt = connection.libvirt
connection.libvirt = libvirt
try:
compute_id = '1'
virtConnection = LibvirtConnection(False)
vmHost = VmHost()
vmHost.id = compute_id
vmHost.set_virtualMachineIds([])
InventoryCacheManager.update_object_in_cache(compute_id, vmHost)
# virtConnection.setUuid('34353438-3934-434e-3738-313630323543'
# )
virtConnection._wrapped_conn = None
virtConnection.compute_rmcontext = \
ComputeRMContext(rmType='KVM',
rmIpAddress='10.10.155.165',
rmUserName='openstack',
rmPassword='password')
cachedHost = VmHost()
cachedHost.id = compute_id
cachedHost.connectionState = Constants.VMHOST_CONNECTED
self.mox.StubOutWithMock(InventoryCacheManager,
'get_object_from_cache')
self.mox.StubOutWithMock(
InventoryCacheManager, 'get_compute_conn_driver')
InventoryCacheManager.get_compute_conn_driver(
self.libvirtVmHost.compute_id,
Constants.VmHost).AndReturn(fake.get_connection())
InventoryCacheManager.get_object_from_cache(
compute_id,
Constants.VmHost).AndReturn(cachedHost)
self.mox.StubOutWithMock(api, 'vm_host_save')
api.vm_host_save(mox.IgnoreArg(),
mox.IgnoreArg()).MultipleTimes().AndReturn(None)
self.mox.ReplayAll()
libvirtEvents = LibvirtEvents()
libvirtVmHost = LibvirtVmHost(
virtConnection._wrapped_conn, compute_id, libvirtEvents)
libvirtVmHost.processUpdates()
self.assertEquals(libvirtVmHost.vmHost.get_connectionState(),
Constants.VMHOST_DISCONNECTED)
self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
msg = test_notifier.NOTIFICATIONS[0]
self.assertEquals(msg['priority'], notifier_api.CRITICAL)
event_type = \
event_metadata.get_EventMetaData(
event_metadata.EVENT_TYPE_HOST_DISCONNECTED)
self.assertEquals(msg['event_type'],
event_type.get_event_fully_qal_name())
payload = msg['payload']
self.assertEquals(payload['entity_type'], 'VmHost')
self.assertEquals(payload['entity_id'],
libvirtVmHost.compute_id)
finally:
connection.libvirt = backedUp_libvirt
示例3: test_vm_host_get_all_for_sv
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_vm_host_get_all_for_sv(self):
host_id = 'VH1'
vmhost = VmHost()
vmhost.id = host_id
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
mntPnt = HostMountPoint()
mntPnt.set_vmHostId(host_id)
mntPnt.set_path('/path')
volume = StorageVolume()
volume.set_id('SV11')
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,
'Host get by id returned a none list')
self.assertTrue(len(vmhosts) > 0,
'Host get by id returned invalid number of list'
)
self.assertTrue(vmhosts[0].id == host_id)
svlist = vmhosts[0].get_storageVolumeIds()
self.assert_(svlist is not None)
self.assert_(len(svlist) == 1)
self.assert_(volume.get_id() in svlist)
healthnmon_db_api.storage_volume_delete_by_ids(
get_admin_context(), [volume.get_id()])
vmhosts = \
healthnmon_db_api.vm_host_get_all(get_admin_context())
self.assertTrue(vmhosts[0].id == host_id)
svids = vmhosts[0].get_storageVolumeIds()
self.assert_((svids is None) or (len(svids) == 0))
示例4: test_vm_host_get_by_id
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_vm_host_get_by_id(self):
host_id = 'VH1'
vmhost = VmHost()
vmhost.id = host_id
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
vm = Vm()
vm.id = 'VM11'
vm.set_vmHostId(host_id)
healthnmon_db_api.vm_save(get_admin_context(), vm)
mntPnt = HostMountPoint()
mntPnt.set_vmHostId(host_id)
mntPnt.set_path('/path')
volume = StorageVolume()
volume.set_id('SV11')
volume.add_mountPoints(mntPnt)
healthnmon_db_api.storage_volume_save(get_admin_context(),
volume)
vmhosts = \
healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
[host_id])
self.assertFalse(vmhosts is None,
'Host get by id returned a none list')
self.assertTrue(len(vmhosts) > 0,
'Host get by id returned invalid number of list'
)
self.assertTrue(vmhosts[0].id == host_id)
示例5: test_vm_host_get_all_for_vm
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_vm_host_get_all_for_vm(self):
host_id = 'VH1'
vmhost = VmHost()
vmhost.id = host_id
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
vm = Vm()
vm.id = 'VM11'
vm.set_vmHostId(host_id)
healthnmon_db_api.vm_save(get_admin_context(), vm)
vmhosts = \
healthnmon_db_api.vm_host_get_all(get_admin_context())
self.assertFalse(vmhosts is None,
'Host get by id returned a none list')
self.assertTrue(len(vmhosts) > 0,
'Host get by id returned invalid number of list'
)
self.assertTrue(vmhosts[0].id == host_id)
vmids = vmhosts[0].get_virtualMachineIds()
self.assert_(vmids is not None)
self.assert_(len(vmids) == 1)
self.assert_(vm.id in vmids)
healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm.id])
vmhosts = \
healthnmon_db_api.vm_host_get_all(get_admin_context())
self.assertTrue(vmhosts[0].id == host_id)
vmids = vmhosts[0].get_virtualMachineIds()
self.assert_((vmids is None) or (len(vmids) == 0))
示例6: test_network_enabled_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_network_enabled_event(self):
cachedHost = VmHost()
cachedHost.id = self.libvirtNetwork.compute_id
vswitch = VirtualSwitch()
vswitch.set_id("11")
vswitch.set_name("vs1")
vswitch.set_connectionState("Inactive")
cachedHost.set_virtualSwitches([vswitch])
vmhost = copy.deepcopy(cachedHost)
vmhost.get_virtualSwitches()[0].set_connectionState("Active")
self.libvirtNetwork._processNetworkEvents(cachedHost, vmhost)
self.assertEquals(vmhost.get_virtualSwitches()[0].
get_connectionState(),
Constants.VIRSWITCH_STATE_ACTIVE)
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_NETWORK_ENABLED)
self.assertEquals(msg['event_type'],
event_type.get_event_fully_qal_name())
payload = msg['payload']
self.assertEquals(payload['entity_type'], 'VirtualSwitch')
self.assertEquals(payload['entity_id'], vswitch.get_id())
self.assertEquals(payload["state"], 'Active')
示例7: test_PortGroup_Reconfigured_Event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_PortGroup_Reconfigured_Event(self):
cachedHost = VmHost()
cachedHost.id = self.libvirtNetwork.compute_id
vswitch = VirtualSwitch()
vswitch.set_id("11")
vswitch.set_name("vs1")
portGroup = PortGroup()
portGroup.set_id("PortGroup_" + vswitch.get_id())
portGroup.set_name(vswitch.get_name())
portGroup.set_virtualSwitchId(vswitch.get_id())
vswitch.set_portGroups([portGroup])
cachedHost.set_virtualSwitches([vswitch])
cachedHost.set_portGroups([portGroup])
vmhost = copy.deepcopy(cachedHost)
vmhost.get_portGroups()[0].set_name("vs11")
vmhost.get_virtualSwitches()[0].set_name("vs11")
vmhost.get_virtualSwitches()[0].get_portGroups()[0].set_name("vs11")
self.libvirtNetwork._processNetworkEvents(cachedHost, vmhost)
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_PORTGROUP_RECONFIGURED)
self.assertEquals(msg["event_type"], event_type.get_event_fully_qal_name())
payload = msg["payload"]
self.assertEquals(payload["entity_type"], "PortGroup")
self.assertEquals(payload["entity_id"], portGroup.get_id())
示例8: test_vm_host_save_update_with_new_vSwitch
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_vm_host_save_update_with_new_vSwitch(self):
host_id = 'VH1'
vmhost = VmHost()
vmhost.id = host_id
vSwitch = VirtualSwitch()
vSwitch.set_id('vSwitch-01')
vSwitch.set_name('vSwitch-01')
vSwitch.set_resourceManagerId('rmId')
vSwitch.set_switchType('vSwitch')
cost1 = Cost()
cost1.set_value(100)
cost1.set_units('USD')
vSwitch.set_cost(cost1)
portGroup = PortGroup()
portGroup.set_id('pg-01')
portGroup.set_name('pg-01')
portGroup.set_resourceManagerId('rmId')
portGroup.set_type('portgroup_type')
portGroup.set_cost(cost1)
vSwitch.add_portGroups(portGroup)
vmhost.add_virtualSwitches(vSwitch)
vmhost.add_portGroups(portGroup)
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
vSwitch_new = VirtualSwitch()
vSwitch_new.set_id('vSwitch-02')
vSwitch_new.set_name('vSwitch-02')
vSwitch_new.set_resourceManagerId('rmId')
vSwitch_new.set_switchType('vSwitch')
portGroup_new = PortGroup()
portGroup_new.set_id('pg-02')
portGroup_new.set_name('pg-02')
portGroup_new.set_resourceManagerId('rmId')
portGroup_new.set_type('portgroup_type')
vSwitch.add_portGroups(portGroup_new)
vmhost.add_virtualSwitches(vSwitch_new)
vmhost.add_portGroups(portGroup_new)
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
vmhosts = \
healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
[host_id])
self.assertFalse(vmhosts is None,
'Host get by id returned a none list')
self.assertTrue(len(vmhosts) > 0,
'Host get by id returned invalid number of list'
)
self.assertTrue(
len(vmhosts[0].get_virtualSwitches()) > 0,
'Host get by virtual switch returned invalid number of list')
self.assertTrue(
len(vmhosts[0].get_portGroups()) > 0,
'Host get by port group returned invalid number of list')
self.assertTrue(vmhosts[0].id == host_id)
示例9: test_network_added_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_network_added_event(self):
cachedHost = VmHost()
cachedHost.id = self.libvirtNetwork.compute_id
vmhost = VmHost()
vmhost.id = self.libvirtNetwork.compute_id
vswitch = VirtualSwitch()
vswitch.set_id("11")
vswitch.set_name("vs1")
vmhost.set_virtualSwitches([vswitch])
self.libvirtNetwork._processNetworkEvents(cachedHost, vmhost)
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_NETWORK_ADDED)
self.assertEquals(msg["event_type"], event_type.get_event_fully_qal_name())
payload = msg["payload"]
self.assertEquals(payload["entity_type"], "VirtualSwitch")
self.assertEquals(payload["entity_id"], vswitch.get_id())
示例10: setUp
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def setUp(self):
self.fakeConn = libvirt.open('qemu:///system')
self.libvirt_connection_cls = connection.LibvirtConnection
super(Test_virt_connection, self).setUp()
self.flags(
healthnmon_notification_drivers=[
'healthnmon.notifier.log_notifier']
)
vmHost = VmHost()
vmHost.id = '1'
vmHost.uuid = '1'
InventoryCacheManager.update_object_in_cache('1', vmHost)
示例11: test_filtered_ordered_query_sort_no_field
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_filtered_ordered_query_sort_no_field(self):
# Create VmHost
vmhost = VmHost()
vmhost.id = 'VH1'
healthnmon_db_api.vm_host_save(self.admin_context, vmhost)
# Query with invalid sort key
vmhosts = healthnmon_db_api.vm_host_get_all_by_filters(
self.admin_context, None,
'invalidSortField', DbConstants.ORDER_ASC)
self.assert_(vmhosts is not None)
self.assert_(len(vmhosts) == 1)
self.assert_(vmhosts[0] is not None)
self.assert_(vmhosts[0].id == vmhost.id)
示例12: test_filtered_ordered_query_changessince_invalid_value
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_filtered_ordered_query_changessince_invalid_value(self):
# Create VmHost
vmhost = VmHost()
vmhost.id = 'VH1'
healthnmon_db_api.vm_host_save(self.admin_context, vmhost)
# Query with invalid changes-since
filters = {'changes-since': 'invalid-value'}
vmhosts = healthnmon_db_api.vm_host_get_all_by_filters(
self.admin_context, filters,
None, None)
self.assert_(vmhosts is not None)
self.assert_(len(vmhosts) == 1)
self.assert_(vmhosts[0] is not None)
self.assert_(vmhosts[0].id == vmhost.id)
示例13: test_diff_resourcemodel_virtualSwitch_withadd
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_diff_resourcemodel_virtualSwitch_withadd(self):
cachedHost = VmHost()
cachedHost.id = '1'
vmhost = VmHost()
vmhost.id = '1'
vswitch = VirtualSwitch()
vswitch.set_id("11")
vswitch.set_name("vs1")
vmhost.set_virtualSwitches([vswitch])
diff = ResourceModelDiff(cachedHost, vmhost)
diff_res = diff.diff_resourcemodel()
self.assertTrue(len(diff_res) > 0)
self.assertTrue(self.update in diff_res)
virtualSwitches = 'virtualSwitches'
self.assertTrue(virtualSwitches in diff_res[self.update])
self.assertTrue(self.add in diff_res[self.update][virtualSwitches])
key = diff_res[self.update][virtualSwitches][self.add].keys()[0]
self.assertTrue(isinstance(diff_res[self.update][virtualSwitches][
self.add][key], VirtualSwitch))
addVirSwitch = diff_res[self.update][virtualSwitches][self.add][key]
self.assertEquals(addVirSwitch.id, '11')
self.assertEquals(addVirSwitch.name, 'vs1')
示例14: test_host_connected_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_host_connected_event(self):
self.__mock_service_get_all_by_topic()
cachedHost = VmHost()
cachedHost.id = self.libvirtVmHost.compute_id
cachedHost.connectionState = 'Disconnected'
self.mox.StubOutWithMock(
InventoryCacheManager, 'get_object_from_cache')
InventoryCacheManager.get_object_from_cache(
self.libvirtVmHost.compute_id,
Constants.VmHost).AndReturn(cachedHost)
self.mox.StubOutWithMock(
InventoryCacheManager, 'get_compute_conn_driver')
InventoryCacheManager.get_compute_conn_driver(
self.libvirtVmHost.compute_id,
Constants.VmHost).AndReturn(fake.get_connection())
self.mox.StubOutWithMock(api, 'vm_host_save')
api.vm_host_save(mox.IgnoreArg(),
mox.IgnoreArg()).MultipleTimes().AndReturn(None)
self.mox.StubOutWithMock(
self.libvirtVmHost, '_get_compute_running_status')
self.libvirtVmHost._get_compute_running_status().AndReturn(
(True, 'host'))
self.mox.StubOutWithMock(
self.libvirtVmHost, '_get_network_running_status')
self.libvirtVmHost._get_network_running_status(
mox.IgnoreArg()).AndReturn(True)
self.mox.ReplayAll()
self.libvirtVmHost.processUpdates()
self.assertEquals(self.libvirtVmHost.vmHost.get_connectionState(),
Constants.VMHOST_CONNECTED)
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_HOST_CONNECTED)
self.assertEquals(msg['event_type'],
event_type.get_event_fully_qal_name())
payload = msg['payload']
self.assertEquals(payload['entity_type'], 'VmHost')
self.assertEquals(payload['entity_id'],
self.libvirtVmHost.compute_id)
示例15: test_vm_host_save_none
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VmHost [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VmHost import id [as 别名]
def test_vm_host_save_none(self):
'''
check the vm_host_save api with none object
'''
vmhost = VmHost()
vmhost.id = 'VH1-id'
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
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) == 1,
'vm_host_get_all does not returned expected number of hosts')
#Now tries to put None object in the db
healthnmon_db_api.vm_host_save(get_admin_context(), None)
#Again tries to retrieve the vmhost from db and
#check it is same as before
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) == 1,
'vm_host_get_all does not returned expected number of hosts')