本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch.set_name方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualSwitch.set_name方法的具体用法?Python VirtualSwitch.set_name怎么用?Python VirtualSwitch.set_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch
的用法示例。
在下文中一共展示了VirtualSwitch.set_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_portGroup_deleted_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [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())
示例2: test_network_enabled_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [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')
示例3: test_PortGroup_Reconfigured_Event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [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())
示例4: _create_switch
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def _create_switch(self, switch_id):
vSwitch = VirtualSwitch()
vSwitch.set_id(switch_id)
vSwitch.set_name(switch_id)
vSwitch.set_resourceManagerId('rmId')
vSwitch.set_switchType('vSwitch')
return vSwitch
示例5: test_vm_host_save_update_with_new_vSwitch
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [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)
示例6: get_single_virtual_switch
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def get_single_virtual_switch(self):
virtual_switch_list = []
virtual_switch = VirtualSwitch()
virtual_switch.set_id("virtual-switch-01")
virtual_switch.set_name("virtual-switch-01")
virtual_switch.set_switchType("dvSwitch")
virtual_switch.add_subnetIds("subnet-3883")
virtual_switch.add_subnetIds("subnet-323")
virtual_switch_list.append(virtual_switch)
return virtual_switch_list
示例7: test_subnet_delete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def test_subnet_delete(self):
subnet = Subnet()
subnet.set_id('subnet-01')
subnet.set_name('subnet-01')
subnet.set_networkAddress('1.1.1.1')
subnet.set_networkMask('255.255.255.0')
subnet.add_networkSources('VS_NETWORK')
subnet.set_ipType('IPV4')
subnet.set_isPublic(True)
subnet.set_isShareable(True)
subnet.add_dnsServers('test-dns01')
subnet.set_dnsDomain('test_Domain')
subnet.add_dnsSearchSuffixes('dnsSearchSuffixes')
subnet.add_defaultGateways('defaultGateways')
subnet.set_msDomainName('msDomainName')
subnet.set_msDomainType('WORKGROUP')
subnet.add_winsServers('winsServers')
subnet.add_ntpDateServers('ntpDateServers')
subnet.set_vlanId(1)
subnet.set_isBootNetwork(True)
subnet.add_deploymentServices('deploymentServices')
subnet.add_parentIds('parentIds')
subnet.add_childIds('childIds')
subnet.set_isTrunk(True)
subnet.add_redundancyPeerIds('redundancyPeerIds')
subnet.set_redundancyMasterId('redundancyMasterId')
subnet.set_isNativeVlan(False)
userIp = IpAddress()
userIp.set_id('10.10.20.1')
userIp.set_address('10.10.20.1')
subnet.add_usedIpAddresses(userIp)
ipRange = self._create_ip_range_from_xml(subnet.get_id(
), 'network1', '10.10.10.1', '10.10.10.1', '10.10.10.2')
subnet.add_ipAddressRanges(ipRange)
healthnmon_db_api.subnet_save(self.admin_context, subnet)
subnet2 = Subnet()
subnet2.set_id('subnet-02')
subnet2.set_name('subnet-02')
healthnmon_db_api.subnet_save(self.admin_context, subnet2)
vSwitch = VirtualSwitch()
vSwitch.set_id('vs-01')
vSwitch.set_name('vs-01')
vSwitch.add_subnetIds('subnet-01')
vSwitch.add_subnetIds('subnet-02')
healthnmon_db_api.virtual_switch_save(self.admin_context,
vSwitch)
healthnmon_db_api.subnet_delete_by_ids(self.admin_context,
[subnet.id])
subnets = healthnmon_db_api.subnet_get_by_ids(self.admin_context,
[subnet.id])
self.assertTrue(subnets is None or len(subnets) == 0,
'subnet deleted')
示例8: get_virtual_switch_list
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def get_virtual_switch_list(self):
virtual_switch_list = []
virtual_switch = VirtualSwitch()
virtual_switch.set_id("virtual-switch-01")
virtual_switch.set_name("virtual-switch-01")
virtual_switch.set_switchType("type-01")
virtual_switch.add_subnetIds("subnet-233")
virtual_switch.add_subnetIds("subnet-03")
virtual_switch_list.append(virtual_switch)
virtual_switch = VirtualSwitch()
virtual_switch.set_id("virtual-switch-02")
virtual_switch.set_name("virtual-switch-02")
virtual_switch.set_switchType("type-02")
virtual_switch.add_subnetIds("subnet-392")
virtual_switch_list.append(virtual_switch)
return virtual_switch_list
示例9: test_network_added_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [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 VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def setUp(self):
self.connection = LibvirtConnection(False)
vmHost = VmHost()
vSwitch = VirtualSwitch()
vSwitch.set_id('52:54:00:34:14:AE')
vSwitch.set_name('default')
vSwitch.set_switchType('nat')
vmHost.set_virtualSwitches([vSwitch])
InventoryCacheManager.update_object_in_cache('1', vmHost)
#self.connection.setUuid('34353438-3934-434e-3738-313630323543')
self.connection._wrapped_conn = libvirt.open('qemu:///system')
self.connection.compute_rmcontext = \
ComputeRMContext(rmType='KVM', rmIpAddress='10.10.155.165',
rmUserName='openstack',
rmPassword='password')
self.LibvirtNetwork = LibvirtNetwork(self.connection, '1')
self.mock = mox.Mox()
cfg.CONF.set_override('healthnmon_notification_drivers',
['healthnmon.notifier.log_notifier'])
示例11: test_network_deleted_event
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [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())
示例12: test_diff_test_diff_resourcemodel_virtualSwitch_withdelete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def test_diff_test_diff_resourcemodel_virtualSwitch_withdelete(self):
cachedHost = VmHost()
cachedHost.id = '1'
vswitch = VirtualSwitch()
vswitch.set_id("11")
vswitch.set_name("vs1")
cachedHost.set_virtualSwitches([vswitch])
vmhost = copy.deepcopy(cachedHost)
vmhost.get_virtualSwitches().pop()
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.delete in diff_res[self.update][virtualSwitches])
key = diff_res[self.update][virtualSwitches][self.delete].keys()[0]
self.assertTrue(isinstance(diff_res[self.update][virtualSwitches][
self.delete][key], VirtualSwitch))
delVirSwitch = diff_res[self.update][virtualSwitches][self.delete][key]
self.assertEquals(delVirSwitch.id, '11')
self.assertEquals(delVirSwitch.name, 'vs1')
示例13: test_vm_host_delete
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def test_vm_host_delete(self):
vmhost_id = 'VH1'
vmhost = VmHost()
vmhost.id = vmhost_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)
vmhost2 = VmHost()
vmhost2.set_id('VH2')
healthnmon_db_api.vm_host_save(get_admin_context(), vmhost2)
storage = StorageVolume()
storage.set_id('sv-01')
storage.set_name('storage-01')
storage.set_resourceManagerId('rmId')
storage.set_size(1234)
storage.set_free(2345)
storage.set_vmfsVolume(True)
storage.set_shared(True)
storage.set_assignedServerCount(1)
storage.set_volumeType('VMFS')
storage.set_volumeId('101')
hostMount1 = HostMountPoint()
hostMount1.set_path('test_path1')
hostMount1.set_vmHostId('VH1')
storage.add_mountPoints(hostMount1)
hostMount2 = HostMountPoint()
hostMount2.set_path('test_path2')
hostMount2.set_vmHostId('VH2')
storage.add_mountPoints(hostMount2)
healthnmon_db_api.storage_volume_save(get_admin_context(),
storage)
vm = Vm()
vm.set_id('vm-01')
vm.set_name('vm-01')
vm.set_vmHostId('VH1')
healthnmon_db_api.vm_save(get_admin_context(), vm)
vmhosts = \
healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
[vmhost_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'
)
healthnmon_db_api.vm_host_delete_by_ids(get_admin_context(),
[vmhost_id])
vmhosts = \
healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
[vmhost_id])
self.assertTrue(vmhosts is None or len(vmhosts) == 0,
'host not deleted')
示例14: test_virtual_switch_save_with_subnet
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def test_virtual_switch_save_with_subnet(self):
# Save virtual switch with a port group
vSwitch = VirtualSwitch()
vSwitch.set_id("vSwitch-11")
vSwitch.set_name("vSwitch-11")
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)
api.virtual_switch_save(self.admin_context, vSwitch)
# Update after adding a port group and subnet
vSwitch = api.virtual_switch_get_by_ids(self.admin_context, [vSwitch.id])[0]
portGroup2 = PortGroup()
portGroup2.set_id("pg-02")
portGroup2.set_name("pg-02")
portGroup2.set_resourceManagerId("rmId")
portGroup2.set_type("portgroup_type")
vSwitch.add_portGroups(portGroup2)
subnet = Subnet()
subnet.set_id("subnet-02")
subnet.set_name("subnet-02")
subnet.set_networkAddress("1.1.1.1")
api.subnet_save(self.admin_context, subnet)
vSwitch.add_subnetIds(subnet.id)
vSwitch.add_networkInterfaces("1")
api.virtual_switch_save(self.admin_context, vSwitch)
virtualswitches = api.virtual_switch_get_by_ids(self.admin_context, [vSwitch.id])
# Assert the values
self.assertTrue(len(virtualswitches) == 1, "Unexpected number of Virtual Switch returned")
self.assertTrue(virtualswitches[0].get_id() == "vSwitch-11", "Virtual Switch id mismatch")
self.assertTrue(virtualswitches[0].get_name() == "vSwitch-11", "Virtual Switch name mismatch")
self.assertTrue(
virtualswitches[0].get_resourceManagerId() == "rmId", "Virtual Switch Resource Manager id mismatch"
)
self.assertTrue(virtualswitches[0].get_switchType() == "vSwitch", "Virtual Switch type mismatch")
cost1 = virtualswitches[0].get_cost()
self.assertTrue(cost1.get_value() == 100, "VSwitch Cost Value mismatch")
self.assertTrue(cost1.get_units() == "USD", "VSwitch Cost units mismatch")
portGroups = virtualswitches[0].get_portGroups()
self.assertTrue(len(portGroups) == 2, "All the portgroups have not been saved")
self.assertTrue(portGroups[0].get_id() == "pg-01", "VSwitch Port Group id mismatch")
self.assertTrue(portGroups[0].get_name() == "pg-01", "VSwitch Port Group Name mismatch")
self.assertTrue(
portGroups[0].get_resourceManagerId() == "rmId", "VSwitch portgroup Resource Manager id mismatch"
)
self.assertTrue(portGroups[0].get_type() == "portgroup_type", "VSwitch port group type mismatched")
cost2 = portGroups[0].get_cost()
self.assertTrue(cost2.get_value() == 100, "PortGroup Cost Value mismatch")
self.assertTrue(cost2.get_units() == "USD", "PortGroup Cost units mismatch")
self.assertTrue(portGroups[1].get_id() == "pg-02", "VSwitch Port Group id mismatch")
self.assertTrue(portGroups[1].get_name() == "pg-02", "VSwitch Port Group Name mismatch")
self.assertTrue(
portGroups[1].get_resourceManagerId() == "rmId", "VSwitch portgroup Resource Manager id mismatch"
)
self.assertTrue(portGroups[1].get_type() == "portgroup_type", "VSwitch port group type mismatched")
subnetId = virtualswitches[0].get_subnetIds()
self.assertTrue(subnetId[0] == "subnet-02", "Virtual Switch subnet id mismatch")
self.assertTrue(
virtualswitches[0].get_networkInterfaces()[0] == "1", "Virtual Switch network INterfaces mismatch"
)
示例15: test_virtual_switch_save_with_subnet
# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_name [as 别名]
def test_virtual_switch_save_with_subnet(self):
# Save virtual switch with a port group
vSwitch = VirtualSwitch()
vSwitch.set_id('vSwitch-11')
vSwitch.set_name('vSwitch-11')
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)
api.virtual_switch_save(self.admin_context, vSwitch)
# Update after adding a port group and subnet
vSwitch = api.virtual_switch_get_by_ids(self.admin_context,
[vSwitch.id])[0]
portGroup2 = PortGroup()
portGroup2.set_id('pg-02')
portGroup2.set_name('pg-02')
portGroup2.set_resourceManagerId('rmId')
portGroup2.set_type('portgroup_type')
vSwitch.add_portGroups(portGroup2)
subnet = Subnet()
subnet.set_id('subnet-02')
subnet.set_name('subnet-02')
subnet.set_networkAddress('1.1.1.1')
api.subnet_save(self.admin_context, subnet)
vSwitch.add_subnetIds(subnet.id)
vSwitch.add_networkInterfaces('1')
api.virtual_switch_save(self.admin_context, vSwitch)
virtualswitches = \
api.virtual_switch_get_by_ids(self.admin_context,
[vSwitch.id])
# Assert the values
self.assertTrue(len(virtualswitches) == 1,
'Unexpected number of Virtual Switch returned')
self.assertTrue(virtualswitches[0].get_id(
) == 'vSwitch-11', 'Virtual Switch id mismatch')
self.assertTrue(virtualswitches[0].get_name(
) == 'vSwitch-11', 'Virtual Switch name mismatch')
self.assertTrue(virtualswitches[0].get_resourceManagerId(
) == 'rmId', 'Virtual Switch Resource Manager id mismatch')
self.assertTrue(virtualswitches[0].get_switchType(
) == 'vSwitch', 'Virtual Switch type mismatch')
cost1 = virtualswitches[0].get_cost()
self.assertTrue(
cost1.get_value() == 100, 'VSwitch Cost Value mismatch')
self.assertTrue(
cost1.get_units() == 'USD', 'VSwitch Cost units mismatch')
portGroups = virtualswitches[0].get_portGroups()
self.assertTrue(
len(portGroups) == 2, 'All the portgroups have not been saved')
self.assertTrue(portGroups[0].get_id(
) == 'pg-01', 'VSwitch Port Group id mismatch')
self.assertTrue(portGroups[0].get_name(
) == 'pg-01', 'VSwitch Port Group Name mismatch')
self.assertTrue(portGroups[0].get_resourceManagerId(
) == 'rmId', 'VSwitch portgroup Resource Manager id mismatch')
self.assertTrue(portGroups[0].get_type(
) == 'portgroup_type', 'VSwitch port group type mismatched')
cost2 = portGroups[0].get_cost()
self.assertTrue(
cost2.get_value() == 100, 'PortGroup Cost Value mismatch')
self.assertTrue(
cost2.get_units() == 'USD', 'PortGroup Cost units mismatch')
self.assertTrue(portGroups[1].get_id(
) == 'pg-02', 'VSwitch Port Group id mismatch')
self.assertTrue(portGroups[1].get_name(
) == 'pg-02', 'VSwitch Port Group Name mismatch')
self.assertTrue(portGroups[1].get_resourceManagerId(
) == 'rmId', 'VSwitch portgroup Resource Manager id mismatch')
self.assertTrue(portGroups[1].get_type(
) == 'portgroup_type', 'VSwitch port group type mismatched')
subnetId = virtualswitches[0].get_subnetIds()
self.assertTrue(
subnetId[0] == 'subnet-02', 'Virtual Switch subnet id mismatch')
self.assertTrue(virtualswitches[0].get_networkInterfaces(
)[0] == '1', 'Virtual Switch network INterfaces mismatch')