当前位置: 首页>>代码示例>>Python>>正文


Python VirtualSwitch.set_id方法代码示例

本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch.set_id方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualSwitch.set_id方法的具体用法?Python VirtualSwitch.set_id怎么用?Python VirtualSwitch.set_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch的用法示例。


在下文中一共展示了VirtualSwitch.set_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_switch

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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
开发者ID:rakrup,项目名称:healthnmon,代码行数:9,代码来源:test_vm_host_db_api.py

示例2: test_PortGroup_Reconfigured_Event

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_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())
开发者ID:emonty,项目名称:healthnmon,代码行数:30,代码来源:test_network_events.py

示例3: test_portGroup_deleted_event

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_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())
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:28,代码来源:test_network_events.py

示例4: test_network_enabled_event

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_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')
开发者ID:emonty,项目名称:healthnmon,代码行数:27,代码来源:test_network_events.py

示例5: test_vm_host_save_update_with_new_vSwitch

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_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)
开发者ID:rakrup,项目名称:healthnmon,代码行数:60,代码来源:test_vm_host_db_api.py

示例6: get_single_virtual_switch

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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
开发者ID:rakrup,项目名称:healthnmon,代码行数:12,代码来源:test_virtualswitch.py

示例7: test_subnet_delete

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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')
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:57,代码来源:test_subnet_db_api.py

示例8: test_timestamp_columns

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_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()))
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:50,代码来源:test_virtual_switch_db_api.py

示例9: get_virtual_switch_list

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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
开发者ID:rakrup,项目名称:healthnmon,代码行数:18,代码来源:test_virtualswitch.py

示例10: test_network_added_event

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_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())
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:20,代码来源:test_network_events.py

示例11: setUp

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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'])
开发者ID:rakrup,项目名称:healthnmon,代码行数:21,代码来源:test_Inventory.py

示例12: test_network_deleted_event

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_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())
开发者ID:emonty,项目名称:healthnmon,代码行数:23,代码来源:test_network_events.py

示例13: test_diff_test_diff_resourcemodel_virtualSwitch_withdelete

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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')
开发者ID:rakrup,项目名称:healthnmon,代码行数:25,代码来源:test_resourcemodel_diff.py

示例14: test_virtual_switch_save_with_subnet

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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')
开发者ID:rakrup,项目名称:healthnmon,代码行数:86,代码来源:test_virtual_switch_db_api.py

示例15: test_virtual_switch_save_with_subnet

# 需要导入模块: from healthnmon.resourcemodel.healthnmonResourceModel import VirtualSwitch [as 别名]
# 或者: from healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch import set_id [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"
     )
开发者ID:emonty,项目名称:healthnmon,代码行数:71,代码来源:test_virtual_switch_db_api.py


注:本文中的healthnmon.resourcemodel.healthnmonResourceModel.VirtualSwitch.set_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。