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


Python base.PhysicalNetwork类代码示例

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


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

示例1: test_extendPhysicalNetworkVlan

    def test_extendPhysicalNetworkVlan(self):
        """
        Test to update a physical network and extend its vlan
        """
        phy_networks = PhysicalNetwork.list(self.apiClient)
        self.assertNotEqual(len(phy_networks), 0,
            msg="There are no physical networks in the zone")

        self.network = phy_networks[0]
        self.networkid = phy_networks[0].id
        self.existing_vlan = phy_networks[0].vlan
        vlan1 = self.existing_vlan+","+self.vlan["part"][0]
        updatePhysicalNetworkResponse = self.network.update(self.apiClient, id = self.networkid, vlan = vlan1)
        self.assert_(updatePhysicalNetworkResponse is not None,
            msg="couldn't extend the physical network with vlan %s"%vlan1)
        self.assert_(isinstance(self.network, PhysicalNetwork))

        vlan2 = vlan1+","+self.vlan["part"][1]
        updatePhysicalNetworkResponse2 = self.network.update(self.apiClient, id = self.networkid, vlan = vlan2)
        self.assert_(updatePhysicalNetworkResponse2 is not None,
            msg="couldn't extend the physical network with vlan %s"%vlan2)
        self.assert_(isinstance(self.network, PhysicalNetwork))

        vlanranges= updatePhysicalNetworkResponse2.vlan
        self.assert_(vlanranges is not None,
            "No VLAN ranges found on the deployment")
        self.assert_(vlanranges.find(self.vlan["full"]) > 0, "vlan ranges are not extended")
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:27,代码来源:test_non_contigiousvlan.py

示例2: test_04_remove_unused_range

    def test_04_remove_unused_range(self):
        """
        Test removing unused vlan range
        """
        # 1. Add new non contiguous range to existing vlan range
        # 2. Remove unused vlan range
        # 3. Unused vlan range should gte removed successfully

        vlan1 = self.existingvlan+","+self.vlan["partial_range"][0]
        self.physicalnetwork.update(self.apiClient, id = self.physicalnetworkid, vlan = vlan1)

        self.debug("Removing vlan : %s" % self.vlan["partial_range"][0])

        self.physicalnetwork.update(self.apiClient, id = self.physicalnetworkid, vlan = self.existingvlan)

        physicalnetworks = PhysicalNetwork.list(self.apiclient, id=self.physicalnetworkid)

        self.assertTrue(isinstance(physicalnetworks, list), "PhysicalNetwork.list should return a \
                        valid list object")

        self.assertTrue(len(physicalnetworks) > 0, "physical networks list should not be empty")

        vlanranges= physicalnetworks[0].vlan

        self.assert_(vlanranges.find(self.vlan["partial_range"][0]) == -1, "vlan range is not removed")

        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:27,代码来源:test_non_contiguous_vlan.py

示例3: test_extendPhysicalNetworkVlan

    def test_extendPhysicalNetworkVlan(self):
        """
        Test to update a physical network and extend its vlan
        """
        phy_networks = PhysicalNetwork.list(self.apiClient)
        self.assertNotEqual(len(phy_networks), 0,
            msg="There are no physical networks in the zone")

        phy_network = None
        for network in phy_networks:
            if hasattr(network, 'vlan'):
                phy_network = network
                break

        self.assert_(phy_network is not None, msg="No network with vlan found")

        self.network = phy_network
        self.networkid = phy_network.id
        self.existing_vlan = phy_network.vlan
        vlan1 = self.existing_vlan+","+self.vlan["partial_range"][0]
        updatePhysicalNetworkResponse = self.network.update(self.apiClient, id = self.networkid, vlan = vlan1)
        self.assert_(updatePhysicalNetworkResponse is not None,
            msg="couldn't extend the physical network with vlan %s"%vlan1)
        self.assert_(isinstance(self.network, PhysicalNetwork))

        vlan2 = vlan1+","+self.vlan["partial_range"][1]
        updatePhysicalNetworkResponse2 = self.network.update(self.apiClient, id = self.networkid, vlan = vlan2)
        self.assert_(updatePhysicalNetworkResponse2 is not None,
            msg="couldn't extend the physical network with vlan %s"%vlan2)
        self.assert_(isinstance(self.network, PhysicalNetwork))

        vlanranges= updatePhysicalNetworkResponse2.vlan
        self.assert_(vlanranges is not None,
            "No VLAN ranges found on the deployment")
开发者ID:Accelerite,项目名称:cloudstack,代码行数:34,代码来源:test_non_contigiousvlan.py

示例4: validatePhysicalNetworkVlan

    def validatePhysicalNetworkVlan(self, physicalNetworkId, vlan):
        """Validate whether the physical network has the updated vlan

        params:

        @physicalNetworkId: The id of physical network which needs to be validated
        @vlan: vlan with which physical network was updated. This should match with the vlan of listed
               physical network

        Raise Exception if not matched
        """

        self.debug("Listing physical networks with id: %s" % physicalNetworkId)

        physicalnetworks = PhysicalNetwork.list(self.apiclient, id=physicalNetworkId)

        self.assertTrue(isinstance(physicalnetworks, list), "PhysicalNetwork.list should return a \
                        valid list object")

        self.assertTrue(len(physicalnetworks) > 0, "physical networks list should not be empty")

        self.debug("Checking if physical network vlan matches with the passed vlan")

        vlans = xsplit(vlan,[','])

        for virtualLan in vlans:
            self.assert_(physicalnetworks[0].vlan.find(virtualLan) != -1, "vlan range %s \
                        is not present in physical network: %s" % (virtualLan, physicalNetworkId))

        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:30,代码来源:test_non_contiguous_vlan.py

示例5: get_nicira_enabled_physical_network_id

 def get_nicira_enabled_physical_network_id(cls, physical_networks):
     nicira_physical_network_name = None
     for physical_network in physical_networks:
         for provider in physical_network.providers:
             if provider.name == 'NiciraNvp':
                 nicira_physical_network_name = physical_network.name
     if nicira_physical_network_name is None:
         raise Exception('Did not find a Nicira enabled physical network in configuration')
     return PhysicalNetwork.list(cls.api_client, name=nicira_physical_network_name)[0].id
开发者ID:sven-schubert,项目名称:cloudstack,代码行数:9,代码来源:test_nicira_controller.py

示例6: get_free_vlan

def get_free_vlan(apiclient, zoneid):
    """
    Find an unallocated VLAN outside the range allocated to the physical network.

    @note: This does not guarantee that the VLAN is available for use in
    the deployment's network gear
    @return: physical_network, shared_vlan_tag
    """
    list_physical_networks_response = PhysicalNetwork.list(apiclient, zoneid=zoneid)
    assert isinstance(list_physical_networks_response, list)
    assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid

    physical_network = list_physical_networks_response[0]

    networks = list_networks(apiclient, zoneid=zoneid, type="Shared")
    usedVlanIds = []

    if isinstance(networks, list) and len(networks) > 0:
        usedVlanIds = [int(nw.vlan) for nw in networks if nw.vlan != "untagged"]

    if hasattr(physical_network, "vlan") is False:
        while True:
            shared_ntwk_vlan = random.randrange(1, 4095)
            if shared_ntwk_vlan in usedVlanIds:
                continue
            else:
                break
    else:
        vlans = xsplit(physical_network.vlan, ["-", ","])

        assert len(vlans) > 0
        assert int(vlans[0]) < int(vlans[-1]), "VLAN range  %s was improperly split" % physical_network.vlan

        # Assuming random function will give different integer each time
        retriesCount = 20

        shared_ntwk_vlan = None

        while True:

            if retriesCount == 0:
                break

            free_vlan = int(vlans[-1]) + random.randrange(1, 20)

            if free_vlan > 4095:
                free_vlan = int(vlans[0]) - random.randrange(1, 20)
            if free_vlan < 0 or (free_vlan in usedVlanIds):
                retriesCount -= 1
                continue
            else:
                shared_ntwk_vlan = free_vlan
                break

    return physical_network, shared_ntwk_vlan
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:55,代码来源:common.py

示例7: setUp

    def setUp(self):
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()

        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.physicalnetworks = PhysicalNetwork.list(self.apiclient, zoneid=self.zone.id)
        self.assertNotEqual(len(self.physicalnetworks), 0, "Check if the list physical network API returns a non-empty response")
        self.clusters = Cluster.list(self.apiclient, hypervisor='VMware')
        self.assertNotEqual(len(self.clusters), 0, "Check if the list cluster API returns a non-empty response")

        self.cleanup = []
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:12,代码来源:test_asa1000v_fw.py

示例8: setUpClass

    def setUpClass(cls):
        testClient = super(TestRegionVpcOffering, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = Services().services

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype


        cls.template = get_template(
            cls.apiclient,
            cls.zone.id,
            cls.services["ostype"]
        )
        if cls.template == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]


        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
                                            cls.apiclient,
                                            cls.services["service_offering"]
                                            )
        cls._cleanup = [cls.service_offering, ]

        try:
            list_physical_networks = PhysicalNetwork.list(
                                                     cls.apiclient,
                                                     zoneid=cls.zone.id
                                                     )
            assert validateList(list_physical_networks)[0] == PASS,\
                "physical networks list validation failed"

            cls.isOvsPluginEnabled = False
            for i in range(0, len(list_physical_networks)):
                list_network_serviceprovider = NetworkServiceProvider.list(
                                                                       cls.apiclient,
                                                                       physicalnetworkid=list_physical_networks[i].id
                                                                       )
                for j in range(0, len(list_network_serviceprovider)):
                    if((str(list_network_serviceprovider[j].name).lower() == 'ovs') and
                        (str(list_network_serviceprovider[j].state).lower() == 'enabled')):
                        cls.isOvsPluginEnabled = True
                        break
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest(e)
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:52,代码来源:test_region_vpc.py

示例9: getZoneDetails

    def getZoneDetails(cls, zone=None):
        # Get Zone, Domain and templates
        cls.zone = zone if zone else get_zone(
            cls.api_client,
            zone_name=cls.test_client.getZoneForTests()
        )
        cls.domain = get_domain(cls.api_client)
        cls.template = get_template(cls.api_client,
                                    cls.zone.id,
                                    cls.test_data["ostype"]
                                    )
        cls.test_data["virtual_machine"]["zoneid"] = cls.zone.id
        cls.test_data["virtual_machine"]["template"] = cls.template.id

        # Check if the host hypervisor type is simulator
        hypervisors = Hypervisor.list(cls.api_client, zoneid=cls.zone.id)
        assert hypervisors is not None and len(hypervisors) > 0, \
            "Expected at least one hypervisor"
        cls.isSimulator = any(map(lambda h: h.name == "Simulator",
                                  hypervisors))

        # Get configured Nuage VSP device details
        try:
            physical_networks = PhysicalNetwork.list(
                cls.api_client,
                zoneid=cls.zone.id
            )

            cls.vsp_physical_network = next(pn for pn in physical_networks
                                            if pn.isolationmethods == "VSP")
            cls.nuage_vsp_device = Nuage.list(
                cls.api_client,
                physicalnetworkid=cls.vsp_physical_network.id)[0]

            # Take username and password from the datacenter config file,
            # as they are not returned by the API.
            config_nuage_device = next(device for zone in cls.config.zones
                                       if zone.name == cls.zone.name
                                       for physnet in zone.physical_networks
                                       if "VSP" in physnet.isolationmethods
                                       for provider in physnet.providers
                                       if provider.name == "NuageVsp"
                                       for device in provider.devices)

            cls.nuage_vsp_device.username = config_nuage_device.username
            cls.nuage_vsp_device.password = config_nuage_device.password
            cls.cms_id = cls.nuage_vsp_device.cmsid
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Warning: Could not get configured "
                                    "Nuage VSP device details - %s" % e)
        return
开发者ID:prashanthvarma,项目名称:cloudstack,代码行数:52,代码来源:nuageTestCase.py

示例10: tearDown

 def tearDown(self):
     """
     Teardown to update a physical network and shrink its vlan
     @return:
     """
     phy_networks = PhysicalNetwork.list(self.apiClient)
     self.assertNotEqual(len(phy_networks), 0,
         msg="There are no physical networks in the zone")
     self.network = phy_networks[0]
     self.networkid = phy_networks[0].id
     updateResponse = self.network.update(self.apiClient, id = self.networkid, vlan=self.existing_vlan)
     self.assert_(updateResponse.vlan.find(self.vlan["full"]) < 0,
         "VLAN was not removed successfully")
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:13,代码来源:test_non_contigiousvlan.py

示例11: test_baremetal

 def test_baremetal(self):
     self.debug("Test create baremetal network offering")
     networkoffering = NetworkOffering.create(self.apiclient, self.services["network_offering"])
     networkoffering.update(self.apiclient, state="Enabled")
     self.cleanup.append(networkoffering)
     
     physical_network = PhysicalNetwork.list(self.apiclient, zoneid=self.zoneid)[0];
     dhcp_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalDhcpProvider", physical_network_id=physical_network.id)[0]
     NetworkServiceProvider.update(
                                       self.apiclient,
                                       id=dhcp_provider.id,
                                       state='Enabled'
                                       )
     pxe_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalPxeProvider", physical_network_id=physical_network.id)[0]
     NetworkServiceProvider.update(
                                       self.apiclient,
                                       id=pxe_provider.id,
                                       state='Enabled'
                                       )
     userdata_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalUserdataProvider", physical_network_id=physical_network.id)[0]
     NetworkServiceProvider.update(
                                       self.apiclient,
                                       id=userdata_provider.id,
                                       state='Enabled'
                                       )
     
     network = Network.create(self.apiclient, self.services["network"], zoneid=self.zoneid, networkofferingid=networkoffering.id)
     self.cleanup.insert(0, network)
     
     pod = Pod.list(self.apiclient)[0]
     cmd = createVlanIpRange.createVlanIpRangeCmd()
     cmd.podid = pod.id
     cmd.networkid = network.id
     cmd.gateway = "10.1.1.1"
     cmd.netmask = "255.255.255.0"
     cmd.startip = "10.1.1.20"
     cmd.endip = "10.1.1.40"
     cmd.forVirtualNetwork="false"
     self.apiclient.createVlanIpRange(cmd)
开发者ID:Accelerite,项目名称:cloudstack,代码行数:39,代码来源:test_baremetal.py

示例12: test_01_list_sec_storage_vm

    def test_01_list_sec_storage_vm(self):
        """Test List secondary storage VMs
        """

        # Validate the following:
        # 1. listSystemVM (systemvmtype=secondarystoragevm)
        #    should return only ONE SSVM per zone
        # 2. The returned SSVM should be in Running state
        # 3. listSystemVM for secondarystoragevm should list publicip,
        #    privateip and link-localip
        # 4. The gateway programmed on the ssvm by listSystemVm should be
        #    the same as the gateway returned by listVlanIpRanges
        # 5. DNS entries must match those given for the zone

        list_ssvm_response = list_ssvms(
            self.apiclient,
            systemvmtype='secondarystoragevm',
            state='Running',
        )
        self.assertEqual(
            isinstance(list_ssvm_response, list),
            True,
            "Check list response returns a valid list"
        )
        # Verify SSVM response
        self.assertNotEqual(
            len(list_ssvm_response),
            0,
            "Check list System VMs response"
        )

        list_zones_response = list_zones(self.apiclient)

        self.assertEqual(
            isinstance(list_zones_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.debug("Number of zones: %s" % len(list_zones_response))
        self.debug("Number of SSVMs: %s" % len(list_ssvm_response))
        # Number of Sec storage VMs = No of Zones
        self.assertEqual(
            len(list_ssvm_response),
            len(list_zones_response),
            "Check number of SSVMs with number of zones"
        )
        # For each secondary storage VM check private IP,
        # public IP, link local IP and DNS
        for ssvm in list_ssvm_response:

            self.debug("SSVM state: %s" % ssvm.state)
            self.assertEqual(
                ssvm.state,
                'Running',
                "Check whether state of SSVM is running"
            )

            self.assertEqual(
                hasattr(ssvm, 'privateip'),
                True,
                "Check whether SSVM has private IP field"
            )

            self.assertEqual(
                hasattr(ssvm, 'linklocalip'),
                True,
                "Check whether SSVM has link local IP field"
            )

            self.assertEqual(
                hasattr(ssvm, 'publicip'),
                True,
                "Check whether SSVM has public IP field"
            )

            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(
                self.apiclient,
                zoneid=ssvm.zoneid
            )
            self.assertEqual(
                isinstance(ipranges_response, list),
                True,
                "Check list response returns a valid list"
            )
            iprange = ipranges_response[0]

            # Fetch corresponding Physical Network of SSVM's Zone
            listphyntwk = PhysicalNetwork.list(
                self.apiclient,
                zoneid=ssvm.zoneid
            )

            # Execute the following assertion in all zones except EIP-ELB Zones
            if not (
                self.zone.networktype.lower() == 'basic' and isinstance(
                    NetScaler.list(
                        self.apiclient,
                        physicalnetworkid=listphyntwk[0].id),
#.........这里部分代码省略.........
开发者ID:klurnl,项目名称:cloudstack,代码行数:101,代码来源:test_ssvm.py

示例13: Cluster

    if clusters:
      for cluster in clusters:
        print "cluster name={}, id={}".format(cluster.name, cluster.id)
        if cluster.allocationstate == 'Enabled':
          print "Delete Cluster"
          c = Cluster(tmp_dict)
          c.id = cluster.id
          c.delete(apiClient)

    ipranges = PublicIpRange.list(apiClient)
    if ipranges:
      for iprange in ipranges:
        print "ip range name={}, id={}".format(iprange.name, iprange.id)

    if clusters:
      nets = PhysicalNetwork.list(apiClient)
      if nets:
        for net in nets:
          print "net name={}, id={}".format(net.name, net.id)
          print "Delete PhysicalNetwork"
          n = PhysicalNetwork(tmp_dict)
          n.id = net.id
          n.delete(apiClient)

    pods = Pod.list(apiClient)
    if pods:
      for pod in pods:
        print "pod name={}, id={}".format(pod.name, pod.id)
        print "Delete Pod"
        p = Pod(tmp_dict)
        p.id = pod.id
开发者ID:realsystem,项目名称:my_scripts,代码行数:31,代码来源:clean.py

示例14: setUpClass

    def setUpClass(cls, zone=None):
        cls.debug("setUpClass nuageTestCase")

        # We want to fail quicker, if it's a failure
        socket.setdefaulttimeout(60)

        test_client = super(nuageTestCase, cls).getClsTestClient()
        cls.api_client = test_client.getApiClient()
        cls.db_client = test_client.getDbConnection()
        cls.test_data = test_client.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.zone = get_zone(cls.api_client,
                            zone_name=zone.name if zone else None,
                            zone_id=zone.id if zone else None
                            )
        cls.domain = get_domain(cls.api_client)
        cls.template = get_template(cls.api_client,
                                    cls.zone.id,
                                    cls.test_data["ostype"]
                                    )
        cls.test_data["virtual_machine"]["zoneid"] = cls.zone.id
        cls.test_data["virtual_machine"]["template"] = cls.template.id

        # Create service offering
        cls.service_offering = ServiceOffering.create(cls.api_client,
                                                      cls.test_data["service_offering"]
                                                      )
        cls._cleanup = [cls.service_offering]

        # Check if the host hypervisor type is simulator
        cls.isSimulator = Hypervisor.list(cls.api_client, zoneid=cls.zone.id)[0].name == "Simulator"

        # Get configured Nuage VSP device details
        try:
            physical_networks = PhysicalNetwork.list(cls.api_client, zoneid=cls.zone.id)
            for pn in physical_networks:
                if pn.isolationmethods == "VSP":
                    cls.vsp_physical_network = pn
                    break
            cls.nuage_vsp_device = Nuage.list(cls.api_client,
                                              physicalnetworkid=cls.vsp_physical_network.id
                                              )[0]
            pns = cls.config.zones[0].physical_networks
            providers = filter(lambda physical_network: "VSP" in physical_network.isolationmethods, pns)[0].providers
            devices = filter(lambda provider: provider.name == "NuageVsp", providers)[0].devices
            cls.nuage_vsp_device.username = devices[0].username
            cls.nuage_vsp_device.password = devices[0].password
            cls.cms_id = cls.nuage_vsp_device.cmsid
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Warning: Could not get configured Nuage VSP device details - %s" % e)

        # VSD is a programmable policy and analytics engine of Nuage VSP SDN platform
        # vspk is a Python SDK for Nuage VSP's VSD
        # libVSD is a library that wraps vspk package
        try:
            vspk_module = "vspk." + cls.nuage_vsp_device.apiversion if int(cls.nuage_vsp_device.apiversion[1]) >= 4 \
                else "vspk.vsdk." + cls.nuage_vsp_device.apiversion
            cls.vsdk = importlib.import_module(vspk_module)
            from libVSD import ApiClient, VSDHelpers
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Warning: vspk (and/or) libVSD package import failure - %s" % e)

        # Configure VSD session
        cls._session = cls.vsdk.NUVSDSession(username=cls.nuage_vsp_device.username,
                                             password=cls.nuage_vsp_device.password,
                                             enterprise="csp",
                                             api_url="https://%s:%d" % (cls.nuage_vsp_device.hostname,
                                                                        cls.nuage_vsp_device.port)
                                             )
        cls._session.start()

        # Configure libVSD session
        root = logging.getLogger()
        log_handler = logging.StreamHandler(sys.stdout)
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        log_handler.setFormatter(formatter)
        root.addHandler(log_handler)
        vsd_info = cls.nuage_vsp_device.__dict__
        cls.debug("Nuage VSP device (VSD) details - %s" % vsd_info)
        vsd_api_client = ApiClient(address=vsd_info["hostname"],
                                   user=vsd_info["username"],
                                   password=vsd_info["password"],
                                   version=vsd_info["apiversion"][1] + "." + vsd_info["apiversion"][3]
                                   )
        vsd_api_client.new_session()
        cls.vsd = VSDHelpers(vsd_api_client)

        cls.debug("setUpClass nuageTestCase [DONE]")
开发者ID:KamilStupak,项目名称:cloudstack,代码行数:91,代码来源:nuageTestCase.py

示例15: test_02_list_cpvm_vm

    def test_02_list_cpvm_vm(self):
        """Test List console proxy VMs
        """

        # Validate the following:
        # 1. listSystemVM (systemvmtype=consoleproxy) should return
        #    at least ONE CPVM per zone
        # 2. The returned ConsoleProxyVM should be in Running state
        # 3. listSystemVM for console proxy should list publicip, privateip
        #    and link-localip
        # 4. The gateway programmed on the console proxy should be the same
        #    as the gateway returned by listZones
        # 5. DNS entries must match those given for the zone

        list_cpvm_response = list_ssvms(
            self.apiclient,
            systemvmtype='consoleproxy',
            state='Running',
        )
        self.assertEqual(
            isinstance(list_cpvm_response, list),
            True,
            "Check list response returns a valid list"
        )
        # Verify CPVM response
        self.assertNotEqual(
            len(list_cpvm_response),
            0,
            "Check list System VMs response"
        )
        list_zones_response = list_zones(self.apiclient)
        # Number of Console Proxy VMs = No of Zones

        self.assertEqual(
            isinstance(list_zones_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.debug("Number of zones: %s" % len(list_zones_response))
        self.debug("Number of CPVMs: %s" % len(list_cpvm_response))

        self.assertEqual(
            len(list_cpvm_response),
            len(list_zones_response),
            "Check number of CPVMs with number of zones"
        )
        # For each CPVM check private IP, public IP, link local IP and DNS
        for cpvm in list_cpvm_response:

            self.debug("CPVM state: %s" % cpvm.state)
            self.assertEqual(
                cpvm.state,
                'Running',
                "Check whether state of CPVM is running"
            )

            self.assertEqual(
                hasattr(cpvm, 'privateip'),
                True,
                "Check whether CPVM has private IP field"
            )

            self.assertEqual(
                hasattr(cpvm, 'linklocalip'),
                True,
                "Check whether CPVM has link local IP field"
            )

            self.assertEqual(
                hasattr(cpvm, 'publicip'),
                True,
                "Check whether CPVM has public IP field"
            )
            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(
                self.apiclient,
                zoneid=cpvm.zoneid
            )
            self.assertEqual(
                isinstance(ipranges_response, list),
                True,
                "Check list response returns a valid list"
            )

            # Fetch corresponding Physical Network of SSVM's Zone
            listphyntwk = PhysicalNetwork.list(
                self.apiclient,
                zoneid=cpvm.zoneid
            )

            # Execute the following assertion in all zones except EIP-ELB Zones
            if not (
                self.zone.networktype.lower() == 'basic' and isinstance(
                    NetScaler.list(
                        self.apiclient,
                        physicalnetworkid=listphyntwk[0].id),
                    list) is True):
                gatewayFound = False
                for iprange in ipranges_response:
#.........这里部分代码省略.........
开发者ID:PCextreme,项目名称:cloudstack,代码行数:101,代码来源:test_ssvm.py


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