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


Python Network.list方法代码示例

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


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

示例1: test_03_supported_policies_by_network

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_03_supported_policies_by_network(self):
        """Test listnetworks response to check supported stickiness policies"""

        # Validate the following
        # 1. List networks for the account in advance network mode
        # 2. List of supported sticky methods should be present under
        #    SupportedStickinessMethods tag

        self.debug("List networks for account: %s" % self.account.name)
        networks = Network.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)

        self.assertIsInstance(networks, list, "List network should return a valid response")
        network = networks[0]
        self.debug("Network: %s" % network)
        self.assertEqual(
            hasattr(network, "SupportedStickinessMethods"), True, "Network should have SupportedStickinessMethods param"
        )

        self.assertEqual(hasattr(network, "LbCookie"), True, "Network should have LbCookie LB method param")

        self.assertEqual(hasattr(network, "AppCookie"), True, "Network should have AppCookie LB method param")

        self.assertEqual(hasattr(network, "SourceBased"), True, "Network should have SourceBased LB method param")

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

示例2: test_04_publicip_per_project

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_04_publicip_per_project(self):
        """Test Public IP limit per project
        """
        # Validate the following
        # 1. set max no of IPs per project to 2.
        # 2. Create an account in this domain
        # 3. Create 1 VM in this domain
        # 4. Acquire 1 IP in the domain. IP should be successfully acquired
        # 5. Try to acquire 3rd IP in this domain. It should give the user an
        #    appropriate error and an alert should be generated.

        self.debug("Updating public IP resource limits for project: %s" % self.project.id)
        # Set usage_vm=1 for Account 1
        update_resource_limit(self.apiclient, 1, max=2, projectid=self.project.id)  # Public Ip

        self.debug("Deploying VM for Project: %s" % self.project.id)
        virtual_machine_1 = VirtualMachine.create(
            self.apiclient,
            self.services["server"],
            templateid=self.template.id,
            serviceofferingid=self.service_offering.id,
            projectid=self.project.id,
        )
        self.cleanup.append(virtual_machine_1)
        # Verify VM state
        self.assertEqual(virtual_machine_1.state, "Running", "Check VM state is Running or not")
        networks = Network.list(self.apiclient, projectid=self.project.id, listall=True)
        self.assertEqual(isinstance(networks, list), True, "Check list networks response returns a valid response")
        self.assertNotEqual(len(networks), 0, "Check list networks response returns a valid network")
        network = networks[0]
        self.debug("Associating public IP for project: %s" % self.project.id)
        public_ip_1 = PublicIPAddress.create(
            self.apiclient,
            zoneid=virtual_machine_1.zoneid,
            services=self.services["server"],
            networkid=network.id,
            projectid=self.project.id,
        )
        self.cleanup.append(public_ip_1)
        # Verify Public IP state
        self.assertEqual(
            public_ip_1.ipaddress.state in ["Allocated", "Allocating"],
            True,
            "Check Public IP state is allocated or not",
        )

        # Exception should be raised for second Public IP
        with self.assertRaises(Exception):
            PublicIPAddress.create(
                self.apiclient,
                zoneid=virtual_machine_1.zoneid,
                services=self.services["server"],
                networkid=network.id,
                projectid=self.project.id,
            )
        return
开发者ID:vaddanak,项目名称:challenges,代码行数:58,代码来源:test_project_limits.py

示例3: isNetworkDeleted

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
def isNetworkDeleted(apiclient, networkid, timeout=600):
    """ List the network and check that the list is empty or not"""
    networkDeleted = False
    while timeout >= 0:
        networks = Network.list(apiclient, id=networkid)
        if networks is None:
            networkDeleted = True
            break
        timeout -= 60
        time.sleep(60)
    #end while
    return networkDeleted
开发者ID:pkoistin,项目名称:czo,代码行数:14,代码来源:common.py

示例4: get_Network

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def get_Network(self, account):
        """Returns a network for account"""

        networks = Network.list(
                                self.apiclient,
                                account=account.name,
                                domainid=account.domainid,
                                listall=True
                                )
        self.assertIsInstance(networks,
                              list,
                              "List networks should return a valid response")
        return networks[0]
开发者ID:diejiazhao,项目名称:cloudstack,代码行数:15,代码来源:test_haproxy.py

示例5: validate_Network

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
 def validate_Network(self, network, state=None):
     """Validates the Network"""
     self.debug("Check if the network is created successfully ?")
     networks = Network.list(self.api_client,
                             id=network.id
                             )
     self.assertEqual(isinstance(networks, list), True,
                      "List network should return a valid list"
                      )
     self.assertEqual(network.name, networks[0].name,
                      "Name of the network should match with with the returned list data"
                      )
     if state:
         self.assertEqual(networks[0].state, state,
                          "Network state should be in state - %s" % state
                          )
     self.debug("Network creation successfully validated for %s" % network.name)
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:19,代码来源:nuageTestCase.py

示例6: validate_Network

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
 def validate_Network(self, network, state=None):
     """Validates the network"""
     self.debug("Validating the creation and state of Network - %s" % network.name)
     networks = Network.list(self.api_client,
                             id=network.id
                             )
     self.assertEqual(isinstance(networks, list), True,
                      "List network should return a valid list"
                      )
     self.assertEqual(network.name, networks[0].name,
                      "Name of the network should match with with the returned list data"
                      )
     if state:
         self.assertEqual(networks[0].state, state,
                          "Network state should be '%s'" % state
                          )
     self.debug("Successfully validated the creation and state of Network - %s" % network.name)
开发者ID:KamilStupak,项目名称:cloudstack,代码行数:19,代码来源:nuageTestCase.py

示例7: verifyNetworkState

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
def verifyNetworkState(apiclient, networkid, state):
    """List networks and check if the network state matches the given state"""
    retriesCount = 10
    isNetworkInDesiredState = False
    exceptionOccured = False
    exceptionMessage = ""
    try:
        while retriesCount >= 0:
            networks = Network.list(apiclient, id=networkid)
            assert validateList(
                networks)[0] == PASS, "Networks list validation failed"
            if str(networks[0].state).lower() == state:
                isNetworkInDesiredState = True
                break
            retriesCount -= 1
            time.sleep(60)
    except Exception as e:
        exceptionOccured = True
        exceptionMessage = e
        return [exceptionOccured, isNetworkInDesiredState, exceptionMessage]
    return [exceptionOccured, isNetworkInDesiredState, exceptionMessage]
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:23,代码来源:common.py

示例8: test_19_template_tag

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_19_template_tag(self):
        """ Test creation, listing and deletion tag on templates
        """

        try:
            
            noffering=NetworkOffering.list(
                     self.user_api_client,
                     name="DefaultIsolatedNetworkOfferingWithSourceNatService"
                     )
            vm4network=Network.create(
                                 self.user_api_client,
                                self.services["network"],
                                accountid=self.account.name,
                                domainid=self.account.domainid,
                                networkofferingid=noffering[0].id,
                                zoneid=self.zone.id
                                 )

            list_nw_response = Network.list(
                                            self.user_api_client,
                                            id=vm4network.id
                                            )
            self.assertEqual(
                            isinstance(list_nw_response, list),
                            True,
                            "Check list response returns a valid networks list"
                        )

            vm_1 = VirtualMachine.create(
                                    self.user_api_client,
                                    self.services["small"],
                                    templateid=self.template.id,
                                    networkids=vm4network.id,
                                    serviceofferingid=self.service_offering.id,
                                    accountid=self.account.name,
                                    domainid=self.account.domainid,
                                    mode=self.services['mode'],
                                    startvm="true"
                                    )
            time.sleep(600)
            self.debug("Stopping the virtual machine: %s" % vm_1.name)
            # Stop virtual machine
            vm_1.stop(self.user_api_client)
        except Exception as e:
            self.fail("Failed to stop VM: %s" % e)

        timeout = self.services["timeout"]
        while True:
            list_volume = Volume.list(
                self.user_api_client,
                virtualmachineid=vm_1.id,
                type='ROOT',
                listall=True
            )
            if isinstance(list_volume, list):
                break
            elif timeout == 0:
                raise Exception("List volumes failed.")

            time.sleep(5)
            timeout = timeout - 1

        self.volume = list_volume[0]

        self.debug("Creating template from ROOT disk of virtual machine: %s" %
                   vm_1.name)
        # Create template from volume
        template = Template.create(
            self.user_api_client,
            self.services["template"],
            self.volume.id
        )
        self.cleanup.append(template)
        self.debug("Created the template(%s). Now restarting the userVm: %s" %
                   (template.name, vm_1.name))
        vm_1.start(self.user_api_client)

        self.debug("Creating a tag for the template")
        tag = Tag.create(
            self.user_api_client,
            resourceIds=template.id,
            resourceType='Template',
            tags={'OS': 'windows8'}
        )
        self.debug("Tag created: %s" % tag.__dict__)

        tags = Tag.list(
            self.user_api_client,
            listall=True,
            resourceType='Template',
            key='OS',
            value='windows8'
        )
        self.assertEqual(
            isinstance(tags, list),
            True,
            "List tags should not return empty response"
        )
        self.assertEqual(
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:103,代码来源:test_interop_xd_ccp.py

示例9: test_01_restart_network_cleanup

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_01_restart_network_cleanup(self):
        """TS_BUG_008-Test restart network
        """


        # Validate the following
        # 1. When cleanup = true, router is destroyed and a new one created
        # 2. New router will have new publicIp and linkLocalIp and
        #    all it's services should resume

        # Find router associated with user account
        list_router_response = list_routers(
                                    self.apiclient,
                                    account=self.account.name,
                                    domainid=self.account.domainid
                                    )
        self.assertEqual(
                            isinstance(list_router_response, list),
                            True,
                            "Check list response returns a valid list"
                        )
        router = list_router_response[0]

        #Store old values before restart
        old_linklocalip = router.linklocalip

        timeout = 10
        # Network should be in Implemented or Setup stage before restart
        while True:
            networks = Network.list(
                                 self.apiclient,
                                 account=self.account.name,
                                 domainid=self.account.domainid
                                 )
            network = networks[0]
            if network.state in ["Implemented", "Setup"]:
                break
            elif timeout == 0:
                break
            else:
                time.sleep(60)
                timeout = timeout - 1

        self.debug("Restarting network: %s" % network.id)
        cmd = restartNetwork.restartNetworkCmd()
        cmd.id = network.id
        cmd.cleanup = True
        self.apiclient.restartNetwork(cmd)

        # Get router details after restart
        list_router_response = list_routers(
                                    self.apiclient,
                                    account=self.account.name,
                                    domainid=self.account.domainid
                                    )
        self.assertEqual(
                            isinstance(list_router_response, list),
                            True,
                            "Check list response returns a valid list"
                        )
        router = list_router_response[0]

        self.assertNotEqual(
                            router.linklocalip,
                            old_linklocalip,
                            "Check link-local IP after restart"
                        )
        return
开发者ID:MountHuang,项目名称:cloudstack,代码行数:70,代码来源:test_blocker_bugs.py

示例10: test_07_associate_public_ip

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_07_associate_public_ip(self):
        """Test associate public IP within the project
        """
        # Validate the following
        # 1. Create a project
        # 2. Add some public Ips to the project
        # 3. Verify public IP assigned can only used to create PF/LB rules
        #    inside project

        networks = Network.list(self.apiclient, projectid=self.project.id, listall=True)
        self.assertEqual(isinstance(networks, list), True, "Check list networks response returns a valid response")
        self.assertNotEqual(len(networks), 0, "Check list networks response returns a valid network")
        network = networks[0]
        self.debug("Associating public IP for project: %s" % self.project.id)
        public_ip = PublicIPAddress.create(
            self.apiclient,
            zoneid=self.virtual_machine.zoneid,
            services=self.services["server"],
            networkid=network.id,
            projectid=self.project.id,
        )
        self.cleanup.append(public_ip)

        # Create NAT rule
        self.debug("Creating a NAT rule within project, VM ID: %s" % self.virtual_machine.id)
        nat_rule = NATRule.create(
            self.apiclient,
            self.virtual_machine,
            self.services["natrule"],
            public_ip.ipaddress.id,
            projectid=self.project.id,
        )
        self.debug("created a NAT rule with ID: %s" % nat_rule.id)
        nat_rule_response = NATRule.list(self.apiclient, id=nat_rule.id)
        self.assertEqual(isinstance(nat_rule_response, list), True, "Check list response returns a valid list")
        self.assertNotEqual(len(nat_rule_response), 0, "Check Port Forwarding Rule is created")
        self.assertEqual(nat_rule_response[0].id, nat_rule.id, "Check Correct Port forwarding Rule is returned")

        # Create Load Balancer rule and assign VMs to rule
        self.debug("Created LB rule for public IP: %s" % public_ip.ipaddress)
        lb_rule = LoadBalancerRule.create(
            self.apiclient, self.services["lbrule"], public_ip.ipaddress.id, projectid=self.project.id
        )
        self.debug("Assigning VM: %s to LB rule: %s" % (self.virtual_machine.name, lb_rule.id))
        lb_rule.assign(self.apiclient, [self.virtual_machine])

        lb_rules = list_lb_rules(self.apiclient, id=lb_rule.id)
        self.assertEqual(isinstance(lb_rules, list), True, "Check list response returns a valid list")
        # verify listLoadBalancerRules lists the added load balancing rule
        self.assertNotEqual(len(lb_rules), 0, "Check Load Balancer Rule in its List")
        self.assertEqual(lb_rules[0].id, lb_rule.id, "Check List Load Balancer Rules returns valid Rule")

        # Create Firewall rule with configurations from settings file
        fw_rule = FireWallRule.create(
            self.apiclient,
            ipaddressid=public_ip.ipaddress.id,
            protocol="TCP",
            cidrlist=[self.services["fw_rule"]["cidr"]],
            startport=self.services["fw_rule"]["startport"],
            endport=self.services["fw_rule"]["endport"],
            projectid=self.project.id,
        )
        self.debug("Created firewall rule: %s" % fw_rule.id)

        # After Router start, FW rule should be in Active state
        fw_rules = FireWallRule.list(self.apiclient, id=fw_rule.id)
        self.assertEqual(isinstance(fw_rules, list), True, "Check for list FW rules response return valid data")

        self.assertEqual(fw_rules[0].state, "Active", "Check list load balancing rules")
        self.assertEqual(
            fw_rules[0].startport, str(self.services["fw_rule"]["startport"]), "Check start port of firewall rule"
        )

        self.assertEqual(
            fw_rules[0].endport, str(self.services["fw_rule"]["endport"]), "Check end port of firewall rule"
        )

        self.debug("Deploying VM for account: %s" % self.account.name)
        virtual_machine_1 = VirtualMachine.create(
            self.apiclient,
            self.services["server"],
            templateid=self.template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
        )
        self.cleanup.append(virtual_machine_1)

        self.debug("VM state after deploy: %s" % virtual_machine_1.state)
        # Verify VM state
        self.assertEqual(virtual_machine_1.state, "Running", "Check VM state is Running or not")

        self.debug("Creating NAT rule for VM (ID: %s) outside project" % virtual_machine_1.id)
        with self.assertRaises(Exception):
            NATRule.create(self.apiclient, virtual_machine_1, self.services["natrule"], public_ip.ipaddress.id)

        self.debug("Creating LB rule for public IP: %s outside project" % public_ip.ipaddress)
        with self.assertRaises(Exception):
            LoadBalancerRule.create(
                self.apiclient, self.services["lbrule"], public_ip.ipaddress.id, accountid=self.account.name
#.........这里部分代码省略.........
开发者ID:maksimov,项目名称:cloudstack,代码行数:103,代码来源:test_project_resources.py

示例11: test_03_RVR_Network_check_router_state

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_03_RVR_Network_check_router_state(self):
        """ Test redundant router internals """
        self.logger.debug("Starting test_03_RVR_Network_check_router_state...")

        hypervisor = self.testClient.getHypervisorInfo()

        self.logger.debug("Creating Network Offering with default egress FALSE")
        network_offering_egress_false = NetworkOffering.create(
                                            self.apiclient,
                                            self.services["nw_off_persistent_RVR_egress_false"],
                                            conservemode=True
                                            )
        network_offering_egress_false.update(self.apiclient, state='Enabled')

        self.logger.debug("Creating network with network offering: %s" % network_offering_egress_false.id)
        network = Network.create(
                                self.apiclient,
                                self.services["network"],
                                accountid=self.account.name,
                                domainid=self.account.domainid,
                                networkofferingid=network_offering_egress_false.id,
                                zoneid=self.zone.id
                                )
        self.logger.debug("Created network with ID: %s" % network.id)

        networks = Network.list(
                                self.apiclient,
                                id=network.id,
                                listall=True
                                )
        self.assertEqual(
            isinstance(networks, list),
            True,
            "List networks should return a valid response for created network"
             )
        nw_response = networks[0]

        self.logger.debug("Deploying VM in account: %s" % self.account.name)
        virtual_machine = VirtualMachine.create(
                                  self.apiclient,
                                  self.services["virtual_machine"],
                                  templateid=self.template.id,
                                  accountid=self.account.name,
                                  domainid=self.account.domainid,
                                  serviceofferingid=self.service_offering.id,
                                  networkids=[str(network.id)]
                                  )

        self.logger.debug("Deployed VM in network: %s" % network.id)

        self.cleanup.insert(0, network_offering_egress_false)
        self.cleanup.insert(0, network)
        self.cleanup.insert(0, virtual_machine)

        vms = VirtualMachine.list(
                                  self.apiclient,
                                  id=virtual_machine.id,
                                  listall=True
                                  )
        self.assertEqual(
                         isinstance(vms, list),
                         True,
                         "List Vms should return a valid list"
                         )
        vm = vms[0]
        self.assertEqual(
                         vm.state,
                         "Running",
                         "VM should be in running state after deployment"
                         )

        self.logger.debug("Listing routers for network: %s" % network.name)
        routers = Router.list(
                              self.apiclient,
                              networkid=network.id,
                              listall=True
                              )
        self.assertEqual(
                    isinstance(routers, list),
                    True,
                    "list router should return Master and backup routers"
                    )
        self.assertEqual(
                    len(routers),
                    2,
                    "Length of the list router should be 2 (Backup & master)"
                    )

        vals = ["MASTER", "BACKUP", "UNKNOWN"]
        cnts = [0, 0, 0]

        result = "UNKNOWN"
        for router in routers:
            if router.state == "Running":
                hosts = list_hosts(
                    self.apiclient,
                    zoneid=router.zoneid,
                    type='Routing',
                    state='Up',
                    id=router.hostid
#.........这里部分代码省略.........
开发者ID:Accelerite,项目名称:cloudstack,代码行数:103,代码来源:test_routers_network_ops.py

示例12: test_forceDeleteDomain

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_forceDeleteDomain(self):
        """ Test delete domain with force option"""

        # Steps for validations
        # 1. create a domain DOM
        # 2. create 2 users under this domain
        # 3. deploy 1 VM into each of these user accounts
        # 4. create PF / FW rules for port 22 on these VMs for their
        #    respective accounts
        # 5. delete the domain with force=true option
        # Validate the following
        # 1. listDomains should list the created domain
        # 2. listAccounts should list the created accounts
        # 3. listvirtualmachines should show the Running VMs
        # 4. PF and FW rules should be shown in listFirewallRules
        # 5. domain should delete successfully and above three list calls
        #    should show all the resources now deleted. listRouters should
        #    not return any routers in the deleted accounts/domains

        self.debug("Creating a domain for login with API domain test")
        domain = Domain.create(
                                self.apiclient,
                                self.services["domain"],
                                parentdomainid=self.domain.id
                                )
        self.debug("Domain is created succesfully.")
        self.debug(
            "Checking if the created domain is listed in list domains API")
        domains = Domain.list(self.apiclient, id=domain.id, listall=True)

        self.assertEqual(
                         isinstance(domains, list),
                         True,
                         "List domains shall return a valid response"
                         )
        self.debug("Creating 2 user accounts in domain: %s" % domain.name)
        self.account_1 = Account.create(
                                     self.apiclient,
                                     self.services["account"],
                                     domainid=domain.id
                                     )

        self.account_2 = Account.create(
                                     self.apiclient,
                                     self.services["account"],
                                     domainid=domain.id
                                     )

        try:
            self.debug("Creating a tiny service offering for VM deployment")
            self.service_offering = ServiceOffering.create(
                                    self.apiclient,
                                    self.services["service_offering"],
                                    domainid=self.domain.id
                                    )

            self.debug("Deploying virtual machine in account 1: %s" %
                                                self.account_1.name)
            vm_1 = VirtualMachine.create(
                                    self.apiclient,
                                    self.services["virtual_machine"],
                                    templateid=self.template.id,
                                    accountid=self.account_1.name,
                                    domainid=self.account_1.domainid,
                                    serviceofferingid=self.service_offering.id
                                    )

            self.debug("Deploying virtual machine in account 2: %s" %
                                                self.account_2.name)
            VirtualMachine.create(
                                    self.apiclient,
                                    self.services["virtual_machine"],
                                    templateid=self.template.id,
                                    accountid=self.account_2.name,
                                    domainid=self.account_2.domainid,
                                    serviceofferingid=self.service_offering.id
                                    )

            networks = Network.list(
                                self.apiclient,
                                account=self.account_1.name,
                                domainid=self.account_1.domainid,
                                listall=True
                                )
            self.assertEqual(
                         isinstance(networks, list),
                         True,
                         "List networks should return a valid response"
                         )
            network_1 = networks[0]
            self.debug("Default network in account 1: %s is %s" % (
                                                self.account_1.name,
                                                network_1.name))
            src_nat_list = PublicIPAddress.list(
                                    self.apiclient,
                                    associatednetworkid=network_1.id,
                                    account=self.account_1.name,
                                    domainid=self.account_1.domainid,
                                    listall=True,
                                    issourcenat=True,
#.........这里部分代码省略.........
开发者ID:wilderrodrigues,项目名称:cloudstack_integration_tests,代码行数:103,代码来源:test_accounts.py

示例13: test_03_network_create

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_03_network_create(self):
        """ Test create network in project
        """
        # Validate the following
        # 1. Create a project.
        # 2. Add virtual/direct network resource to the project. User shared
        #    network resource for the project
        # 3. Verify any number of Project level Virtual/Direct networks can be
        #    created and used for vm deployment within the project.
        # 4. Verify shared networks (zone and domain wide) from outside the
        #    project can also be used in a project.

        # Create project as a domain admin
        project = Project.create(
            self.apiclient, self.services["project"], account=self.account.name, domainid=self.account.domainid
        )
        # Cleanup created project at end of test
        self.cleanup.append(project)
        self.debug("Created project with domain admin with ID: %s" % project.id)

        network_offerings = list_network_offerings(
            self.apiclient, projectid=project.id, supportedServices="SourceNat", type="isolated", state="Enabled"
        )
        self.assertEqual(isinstance(network_offerings, list), True, "Check for the valid network offerings")
        network_offering = network_offerings[0]

        self.debug("creating a network with network offering ID: %s" % network_offering.id)
        self.services["network"]["zoneid"] = self.zone.id
        network = Network.create(
            self.apiclient, self.services["network"], networkofferingid=network_offering.id, projectid=project.id
        )
        self.debug("Created network with ID: %s" % network.id)
        networks = Network.list(self.apiclient, projectid=project.id, listall=True)
        self.assertEqual(isinstance(networks, list), True, "Check for the valid network list response")

        self.debug("Deploying VM with network: %s" % network.id)

        virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["server"],
            templateid=self.template.id,
            networkids=[str(network.id)],
            serviceofferingid=self.service_offering.id,
            projectid=project.id,
        )
        self.debug("Deployed VM with ID: %s" % virtual_machine.id)
        # Verify VM state
        self.assertEqual(virtual_machine.state, "Running", "Check VM state is Running or not")

        network_offerings = list_network_offerings(
            self.apiclient,
            state="Enabled",
            guestiptype="Shared",
            name="DefaultSharedNetworkOffering",
            displaytext="Offering for Shared networks",
        )
        self.assertEqual(isinstance(network_offerings, list), True, "Check for the valid network offerings")
        network_offering = network_offerings[0]

        self.debug("creating a shared network in domain: %s" % self.domain.id)

        # Getting physical network and free vlan in it
        physical_network, vlan = get_free_vlan(self.apiclient, self.zone.id)

        self.services["domain_network"]["vlan"] = vlan
        self.services["domain_network"]["physicalnetworkid"] = physical_network.id

        # Generating random subnet number for shared network creation
        shared_network_subnet_number = random.randrange(1, 254)

        self.services["domain_network"]["gateway"] = "172.16." + str(shared_network_subnet_number) + ".1"
        self.services["domain_network"]["startip"] = "172.16." + str(shared_network_subnet_number) + ".2"
        self.services["domain_network"]["endip"] = "172.16." + str(shared_network_subnet_number) + ".20"

        domain_network = Network.create(
            self.apiclient,
            self.services["domain_network"],
            domainid=self.domain.id,
            networkofferingid=network_offering.id,
            zoneid=self.zone.id,
        )
        self.cleanup.append(domain_network)
        self.debug("Created network with ID: %s" % domain_network.id)

        virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["server"],
            templateid=self.template.id,
            networkids=[str(domain_network.id)],
            serviceofferingid=self.service_offering.id,
            projectid=project.id,
        )
        self.debug("Deployed VM with ID: %s" % virtual_machine.id)
        # Verify VM state
        self.assertEqual(virtual_machine.state, "Running", "Check VM state is Running or not")

        # Delete VM before network gets deleted in cleanup
        virtual_machine.delete(self.apiclient, expunge=True)
        return
开发者ID:maksimov,项目名称:cloudstack,代码行数:101,代码来源:test_project_resources.py

示例14: test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false(self):
        """ Test redundant router internals """
        self.logger.debug("Starting test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false...")

        self.logger.debug("Creating Network Offering with default egress FALSE")
        network_offering_egress_false = NetworkOffering.create(
                                            self.apiclient,
                                            self.services["nw_off_persistent_RVR_egress_false"],
                                            conservemode=True
                                            )
        network_offering_egress_false.update(self.api_client, state='Enabled')

        self.logger.debug("Creating network with network offering: %s" % network_offering_egress_false.id)
        network = Network.create(
                                self.apiclient,
                                self.services["network"],
                                accountid=self.account.name,
                                domainid=self.account.domainid,
                                networkofferingid=network_offering_egress_false.id,
                                zoneid=self.zone.id
                                )
        self.logger.debug("Created network with ID: %s" % network.id)

        networks = Network.list(
                                self.apiclient,
                                id=network.id,
                                listall=True
                                )
        self.assertEqual(
            isinstance(networks, list),
            True,
            "List networks should return a valid response for created network"
             )
        nw_response = networks[0]

        self.logger.debug("Deploying VM in account: %s" % self.account.name)
        virtual_machine = VirtualMachine.create(
                                  self.apiclient,
                                  self.services["virtual_machine"],
                                  templateid=self.template.id,
                                  accountid=self.account.name,
                                  domainid=self.account.domainid,
                                  serviceofferingid=self.service_offering.id,
                                  networkids=[str(network.id)]
                                  )

        self.logger.debug("Deployed VM in network: %s" % network.id)

        self.cleanup.insert(0, network_offering_egress_false)
        self.cleanup.insert(0, network)
        self.cleanup.insert(0, virtual_machine)

        vms = VirtualMachine.list(
                                  self.apiclient,
                                  id=virtual_machine.id,
                                  listall=True
                                  )
        self.assertEqual(
                         isinstance(vms, list),
                         True,
                         "List Vms should return a valid list"
                         )
        vm = vms[0]
        self.assertEqual(
                         vm.state,
                         "Running",
                         "VM should be in running state after deployment"
                         )

        self.logger.debug("Listing routers for network: %s" % network.name)
        routers = Router.list(
                              self.apiclient,
                              networkid=network.id,
                              listall=True
                              )
        self.assertEqual(
                    isinstance(routers, list),
                    True,
                    "list router should return Master and backup routers"
                    )
        self.assertEqual(
                    len(routers),
                    2,
                    "Length of the list router should be 2 (Backup & master)"
                    )

        public_ips = list_publicIP(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid,
            zoneid=self.zone.id
        )

        self.assertEqual(
            isinstance(public_ips, list),
            True,
            "Check for list public IPs response return valid data"
        )

        public_ip = public_ips[0]
#.........这里部分代码省略.........
开发者ID:Accelerite,项目名称:cloudstack,代码行数:103,代码来源:test_routers_network_ops.py

示例15: test_network_gc

# 需要导入模块: from marvin.lib.base import Network [as 别名]
# 或者: from marvin.lib.base.Network import list [as 别名]
    def test_network_gc(self):
        """Test network garbage collection with RVR
        """

        # Steps to validate
        # 1. createNetwork using network offering for redundant virtual router
        # 2. listRouters in above network
        # 3. deployVM in above user account in the created network
        # 4. stop the running user VM
        # 5. wait for network.gc time
        # 6. listRouters
        # 7. start the routers MASTER and BACK
        # 8. wait for network.gc time and listRouters
        # 9. delete the account

        # Creating network using the network offering created
        self.debug("Creating network with network offering: %s" %
                                                    self.network_offering.id)
        network = Network.create(
                                self.apiclient,
                                self.services["network"],
                                accountid=self.account.name,
                                domainid=self.account.domainid,
                                networkofferingid=self.network_offering.id,
                                zoneid=self.zone.id
                                )
        self.debug("Created network with ID: %s" % network.id)

        networks = Network.list(
                                self.apiclient,
                                id=network.id,
                                listall=True
                                )
        self.assertEqual(
            isinstance(networks, list),
            True,
            "List networks should return a valid response for created network"
             )
        nw_response = networks[0]

        self.debug("Network state: %s" % nw_response.state)
        self.assertEqual(
                    nw_response.state,
                    "Allocated",
                    "The network should be in allocated state after creation"
                    )

        self.debug("Listing routers for network: %s" % network.name)
        routers = Router.list(
                              self.apiclient,
                              networkid=network.id,
                              listall=True
                              )
        self.assertEqual(
            routers,
            None,
            "Routers should not be spawned when network is in allocated state"
            )

        self.debug("Deploying VM in account: %s" % self.account.name)

        # Spawn an instance in that network
        virtual_machine = VirtualMachine.create(
                                  self.apiclient,
                                  self.services["virtual_machine"],
                                  accountid=self.account.name,
                                  domainid=self.account.domainid,
                                  serviceofferingid=self.service_offering.id,
                                  networkids=[str(network.id)]
                                  )
        self.debug("Deployed VM in network: %s" % network.id)

        vms = VirtualMachine.list(
                                  self.apiclient,
                                  id=virtual_machine.id,
                                  listall=True
                                  )
        self.assertEqual(
                         isinstance(vms, list),
                         True,
                         "List Vms should return a valid list"
                         )
        vm = vms[0]
        self.assertEqual(
                         vm.state,
                         "Running",
                         "Vm should be in running state after deployment"
                         )

        self.debug("Listing routers for network: %s" % network.name)
        routers = Router.list(
                              self.apiclient,
                              networkid=network.id,
                              listall=True
                              )
        self.assertEqual(
                    isinstance(routers, list),
                    True,
                    "list router should return Master and backup routers"
                    )
#.........这里部分代码省略.........
开发者ID:Accelerite,项目名称:cloudstack,代码行数:103,代码来源:test_redundant_router_cleanups.py


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