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


Python healthnmonResourceModel.VirtualSwitch类代码示例

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


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

示例1: test_PortGroup_Reconfigured_Event

 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,代码行数:28,代码来源:test_network_events.py

示例2: test_portGroup_deleted_event

 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,代码行数:26,代码来源:test_network_events.py

示例3: test_virtual_switch_get_by_ids

 def test_virtual_switch_get_by_ids(self):
     virtualswitch = VirtualSwitch()
     virtualswitch.id = "VS1"
     virtualswitch.switchType = "switch"
     api.virtual_switch_save(self.admin_context, virtualswitch)
     virtualswitches = api.virtual_switch_get_by_ids(self.admin_context, [virtualswitch.id])
     self.assertFalse(virtualswitches is None, "VirtualSwitch  all returned a list")
     self.assertTrue(virtualswitches[0].id == "VS1", "Virtual Switch Id mismatch")
     self.assertTrue(virtualswitches[0].switchType == "switch", "Virtual Switch Type mismatch")
开发者ID:emonty,项目名称:healthnmon,代码行数:9,代码来源:test_virtual_switch_db_api.py

示例4: test_virtual_switch_get_all

 def test_virtual_switch_get_all(self):
     virtualswitch = VirtualSwitch()
     virtualswitch.id = "VS1"
     virtualswitch.switchType = "switch"
     api.virtual_switch_save(self.admin_context, virtualswitch)
     virtualswitches = api.virtual_switch_get_all(self.admin_context)
     self.assertFalse(virtualswitches is None, "virtual_switch all returned a none list")
     self.assertTrue(len(virtualswitches) == 1, "virtual_switch all returned invalid number of list")
     self.assertTrue(virtualswitches[0].id == "VS1", "Virtual Switch Id mismatch")
     self.assertTrue(virtualswitches[0].switchType == "switch", "Virtual Switch Type mismatch")
开发者ID:emonty,项目名称:healthnmon,代码行数:10,代码来源:test_virtual_switch_db_api.py

示例5: _create_switch

 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,代码行数:7,代码来源:test_vm_host_db_api.py

示例6: test_virtual_switch_get_by_ids

 def test_virtual_switch_get_by_ids(self):
     virtualswitch = VirtualSwitch()
     virtualswitch.id = 'VS1'
     virtualswitch.switchType = 'switch'
     api.virtual_switch_save(self.admin_context, virtualswitch)
     virtualswitches = \
         api.virtual_switch_get_by_ids(self.admin_context,
                                       [virtualswitch.id])
     self.assertFalse(virtualswitches is None,
                      'VirtualSwitch  all returned a list')
     self.assertTrue(
         virtualswitches[0].id == 'VS1', 'Virtual Switch Id mismatch')
     self.assertTrue(virtualswitches[0].switchType == 'switch',
                     'Virtual Switch Type mismatch')
开发者ID:rakrup,项目名称:healthnmon,代码行数:14,代码来源:test_virtual_switch_db_api.py

示例7: test_virtual_switch_get_all

 def test_virtual_switch_get_all(self):
     virtualswitch = VirtualSwitch()
     virtualswitch.id = 'VS1'
     virtualswitch.switchType = 'switch'
     api.virtual_switch_save(self.admin_context, virtualswitch)
     virtualswitches = api.virtual_switch_get_all(self.admin_context)
     self.assertFalse(virtualswitches is None,
                      'virtual_switch all returned a none list')
     self.assertTrue(len(virtualswitches) == 1,
                     'virtual_switch all returned invalid number of list')
     self.assertTrue(
         virtualswitches[0].id == 'VS1', 'Virtual Switch Id mismatch')
     self.assertTrue(virtualswitches[0].switchType == 'switch',
                     'Virtual Switch Type mismatch')
开发者ID:rakrup,项目名称:healthnmon,代码行数:14,代码来源:test_virtual_switch_db_api.py

示例8: test_network_enabled_event

 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,代码行数:25,代码来源:test_network_events.py

示例9: test_virtual_switch_delete

    def test_virtual_switch_delete(self):
        virtualswitch = VirtualSwitch()
        virtualswitch.id = "VS1"
        virtualswitch.switchType = "switch"

        portGroup = PortGroup()
        portGroup.set_id("pg-01")
        portGroup.set_name("pg-01")
        portGroup.set_resourceManagerId("rmId")
        portGroup.set_type("portgroup_type")
        virtualswitch.add_portGroups(portGroup)
        api.virtual_switch_save(self.admin_context, virtualswitch)

        # virtualswitchs = api.virtual_switch_get_by_ids([virtualswitch.id])

        api.virtual_switch_delete_by_ids(self.admin_context, [virtualswitch.id])
        virtualswitchs = api.virtual_switch_get_by_ids(self.admin_context, [virtualswitch.id])
        self.assertTrue(virtualswitchs is None or len(virtualswitchs) == 0, "switch not deleted")
开发者ID:emonty,项目名称:healthnmon,代码行数:18,代码来源:test_virtual_switch_db_api.py

示例10: test_virtual_switch_multiple_save

    def test_virtual_switch_multiple_save(self):
        """Test case to test the modification of VirtualSwitch along with Subnet"""
        virtualswitch = VirtualSwitch()
        virtualswitch.id = "VS1"
        virtualswitch.switchType = "switch"
        subnet_id_lst = ["subnet_1", "subnet_2"]
        "Add one subnet"
        self.__create_subnet(id=subnet_id_lst[0], name=subnet_id_lst[0])
        virtualswitch.set_subnetIds(subnet_id_lst)
        api.virtual_switch_save(self.admin_context, virtualswitch)

        "Update the virtual switch"
        virtualswitch.switchType = "switchUpdated"
        "Add second subnet"
        self.__create_subnet(id=subnet_id_lst[1], name=subnet_id_lst[1])
        api.virtual_switch_save(self.admin_context, virtualswitch)
        virtualswitches = api.virtual_switch_get_by_ids(self.admin_context, [virtualswitch.id])

        self.assertFalse(virtualswitches is None, "VirtualSwitch  all returned a list")
        self.assertTrue(virtualswitches[0].id == "VS1", "Virtual Switch id mismatch")
        self.assertTrue(virtualswitches[0].switchType == "switchUpdated", "Virtual Switch type mismatch")
        self.assertTrue(len(virtualswitches[0].subnetIds) >= 0, "Virtual Switch - subnetIds does not exist")
        self.assertTrue(
            virtualswitches[0].subnetIds[0] in subnet_id_lst, "Virtual Switch - subnetIds is not api output"
        )
        self.assertTrue(
            virtualswitches[0].subnetIds[1] in subnet_id_lst, "Virtual Switch - subnetIds is not api output"
        )
开发者ID:emonty,项目名称:healthnmon,代码行数:28,代码来源:test_virtual_switch_db_api.py

示例11: test_subnet_delete

    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,代码行数:55,代码来源:test_subnet_db_api.py

示例12: test_virtual_switch_delete

    def test_virtual_switch_delete(self):
        virtualswitch = VirtualSwitch()
        virtualswitch.id = 'VS1'
        virtualswitch.switchType = 'switch'

        portGroup = PortGroup()
        portGroup.set_id('pg-01')
        portGroup.set_name('pg-01')
        portGroup.set_resourceManagerId('rmId')
        portGroup.set_type('portgroup_type')
        virtualswitch.add_portGroups(portGroup)
        api.virtual_switch_save(self.admin_context, virtualswitch)

        #virtualswitchs = api.virtual_switch_get_by_ids([virtualswitch.id])

        api.virtual_switch_delete_by_ids(self.admin_context,
                                         [virtualswitch.id])
        virtualswitchs = \
            api.virtual_switch_get_by_ids(self.admin_context,
                                          [virtualswitch.id])
        self.assertTrue(virtualswitchs is None or len(virtualswitchs)
                        == 0, 'switch not deleted')
开发者ID:rakrup,项目名称:healthnmon,代码行数:22,代码来源:test_virtual_switch_db_api.py

示例13: test_timestamp_columns

 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,代码行数:48,代码来源:test_virtual_switch_db_api.py

示例14: test_diff_test_diff_resourcemodel_virtualSwitch_withdelete

    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,代码行数:23,代码来源:test_resourcemodel_diff.py

示例15: setUp

 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,代码行数:19,代码来源:test_Inventory.py


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