本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch.get_id方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualSwitch.get_id方法的具体用法?Python VirtualSwitch.get_id怎么用?Python VirtualSwitch.get_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch
的用法示例。
在下文中一共展示了VirtualSwitch.get_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_PortGroup_Reconfigured_Event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import get_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())
示例2: test_portGroup_deleted_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import get_id [as 别名]
def test_portGroup_deleted_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().pop()
vmhost.get_virtualSwitches().pop()
self.assertEquals(vmhost.get_virtualSwitches(), [])
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_DELETED)
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())
示例3: test_timestamp_columns
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import get_id [as 别名]
def test_timestamp_columns(self):
"""
Test the time stamp columns createEpoch,
modifiedEpoch and deletedEpoch
"""
virSw1 = VirtualSwitch()
virSw1.set_id("VS1_VH1")
portGrp1 = PortGroup()
portGrp1.set_id("PG1_VH1")
virSw1.add_portGroups(portGrp1)
# Check for createEpoch
epoch_before = utils.get_current_epoch_ms()
api.virtual_switch_save(self.admin_context, virSw1)
epoch_after = utils.get_current_epoch_ms()
virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_createEpoch()))
for pg in virsw_queried.get_portGroups():
self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_createEpoch()))
# Check for lastModifiedEpoch after modifying switch
virsw_modified = virsw_queried
test_utils.unset_timestamp_fields(virsw_modified)
virsw_modified.set_name("changed_name")
epoch_before = utils.get_current_epoch_ms()
api.virtual_switch_save(self.admin_context, virsw_modified)
epoch_after = utils.get_current_epoch_ms()
virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
self.assert_(virsw_modified.get_createEpoch() == virsw_queried.get_createEpoch())
self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_lastModifiedEpoch()))
for pg in virsw_queried.get_portGroups():
self.assert_(virsw_modified.get_portGroups()[0].get_createEpoch() == pg.get_createEpoch())
self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
# Check for createdEpoch after adding portgroup to switch
virsw_modified = virsw_queried
test_utils.unset_timestamp_fields(virsw_modified)
portGrp2 = PortGroup()
portGrp2.set_id("PG2_VH1")
virsw_modified.add_portGroups(portGrp2)
epoch_before = utils.get_current_epoch_ms()
api.virtual_switch_save(self.admin_context, virsw_modified)
epoch_after = utils.get_current_epoch_ms()
virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
self.assert_(virsw_modified.get_createEpoch() == virsw_queried.get_createEpoch())
self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_lastModifiedEpoch()))
for pg in virsw_queried.get_portGroups():
if pg.get_id() == portGrp2.get_id():
self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_createEpoch()))
else:
self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
示例4: test_network_enabled_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import get_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')
示例5: test_network_added_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import get_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())
示例6: test_network_deleted_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import get_id [as 别名]
def test_network_deleted_event(self):
cachedHost = VmHost()
cachedHost.id = self.libvirtNetwork.compute_id
vswitch = VirtualSwitch()
vswitch.set_id("11")
vswitch.set_name("vs1")
cachedHost.set_virtualSwitches([vswitch])
vmhost = copy.deepcopy(cachedHost)
vmhost.get_virtualSwitches().pop()
self.assertEquals(vmhost.get_virtualSwitches(), [])
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_DELETED)
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())
示例7: test_timestamp_columns
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import get_id [as 别名]
def test_timestamp_columns(self):
"""
Test the time stamp columns createEpoch,
modifiedEpoch and deletedEpoch
"""
vmhost = VmHost()
vmhost.set_id('VH1')
virSw1 = VirtualSwitch()
virSw1.set_id('VS1_VH1')
portGrp1 = PortGroup()
portGrp1.set_id('PG1_VH1')
virSw1.add_portGroups(portGrp1)
vmhost.add_virtualSwitches(virSw1)
vmhost.add_portGroups(portGrp1)
# Check for createEpoch
epoch_before = utils.get_current_epoch_ms()
healthnmon_db_api.vm_host_save(self.admin_context, vmhost)
epoch_after = utils.get_current_epoch_ms()
vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
self.admin_context, [vmhost.get_id()])[0]
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, vmhost_queried.get_createEpoch()))
for virSw in vmhost_queried.get_virtualSwitches():
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, virSw.get_createEpoch()))
for pg in virSw.get_portGroups():
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, pg.get_createEpoch()))
# Check for lastModifiedEpoch after modifying host
vmhost_modified = vmhost_queried
test_utils.unset_timestamp_fields(vmhost_modified)
vmhost_modified.set_name('changed_name')
epoch_before = utils.get_current_epoch_ms()
healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
epoch_after = utils.get_current_epoch_ms()
vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
self.admin_context, [vmhost.get_id()])[0]
self.assert_(vmhost_modified.get_createEpoch(
) == vmhost_queried.get_createEpoch())
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, vmhost_queried.get_lastModifiedEpoch()))
for virSw in vmhost_queried.get_virtualSwitches():
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, virSw.get_lastModifiedEpoch()))
for pg in virSw.get_portGroups():
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
# Check for createdEpoch after adding switch and portgroup to host
vmhost_modified = vmhost_queried
test_utils.unset_timestamp_fields(vmhost_modified)
virSw2 = VirtualSwitch()
virSw2.set_id('VS2_VH1')
portGrp2 = PortGroup()
portGrp2.set_id('PG2_VH1')
virSw2.add_portGroups(portGrp2)
vmhost_modified.add_virtualSwitches(virSw2)
vmhost_modified.add_portGroups(portGrp2)
epoch_before = utils.get_current_epoch_ms()
healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
epoch_after = utils.get_current_epoch_ms()
vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
self.admin_context, [vmhost.get_id()])[0]
self.assert_(vmhost_modified.get_createEpoch(
) == vmhost_queried.get_createEpoch())
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, vmhost_queried.get_lastModifiedEpoch()))
for virSw in vmhost_queried.get_virtualSwitches():
if virSw.get_id() == virSw2.get_id():
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, virSw.get_createEpoch()))
else:
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, virSw.get_lastModifiedEpoch()))
for pg in virSw.get_portGroups():
if pg.get_id() == portGrp2.get_id():
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, pg.get_createEpoch()))
else:
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
# Check for deletedEpoch
epoch_before = utils.get_current_epoch_ms()
healthnmon_db_api.vm_host_delete_by_ids(
self.admin_context, [vmhost_queried.get_id()])
epoch_after = utils.get_current_epoch_ms()
deleted_host = healthnmon_db_api.vm_host_get_all_by_filters(
self.admin_context,
{"id": vmhost_queried.get_id()}, None, None)[0]
self.assertTrue(deleted_host.get_deleted())
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, deleted_host.get_deletedEpoch()))
deleted_switches = healthnmon_db_api.\
virtual_switch_get_all_by_filters(self.admin_context,
{"id": (virSw1.get_id(),
virSw2.get_id())},
None, None)
for deleted_switch in deleted_switches:
self.assertTrue(deleted_switch.get_deleted())
self.assert_(test_utils.is_timestamp_between(
epoch_before, epoch_after, deleted_switch.get_deletedEpoch()))
#.........这里部分代码省略.........