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


Python PublicIPAddress.list方法代码示例

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


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

示例1: isIpInDesiredState

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
def isIpInDesiredState(apiclient, ipaddressid, state):
    """ Check if the given IP is in the correct state (given)
    and return True/False accordingly"""
    retriesCount = 10
    ipInDesiredState = False
    exceptionOccured = False
    exceptionMessage = ""
    try:
        while retriesCount >= 0:
            portableips = PublicIPAddress.list(apiclient, id=ipaddressid)
            assert validateList(
                portableips)[0] == PASS, "IPs list validation failed"
            if str(portableips[0].state).lower() == state:
                ipInDesiredState = True
                break
            retriesCount -= 1
            time.sleep(60)
    except Exception as e:
        exceptionOccured = True
        exceptionMessage = e
        return [exceptionOccured, ipInDesiredState, e]
    if not ipInDesiredState:
        exceptionMessage = "Ip should be in %s state, it is in %s" %\
                            (state, portableips[0].state)
    return [False, ipInDesiredState, exceptionMessage]
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:27,代码来源:common.py

示例2: validate_PublicIPAddress

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
 def validate_PublicIPAddress(self, public_ip, network, static_nat=False,
                              vm=None):
     """Validates the Public IP Address"""
     self.debug("Validating the assignment and state of public IP address "
                "- %s" % public_ip.ipaddress.ipaddress)
     public_ips = PublicIPAddress.list(self.api_client,
                                       id=public_ip.ipaddress.id,
                                       networkid=network.id,
                                       isstaticnat=static_nat,
                                       listall=True
                                       )
     self.assertEqual(isinstance(public_ips, list), True,
                      "List public IP for network should return a "
                      "valid list"
                      )
     self.assertEqual(public_ips[0].ipaddress,
                      public_ip.ipaddress.ipaddress,
                      "List public IP for network should list the assigned "
                      "public IP address"
                      )
     self.assertEqual(public_ips[0].state, "Allocated",
                      "Assigned public IP is not in the allocated state"
                      )
     if static_nat and vm:
         self.assertEqual(public_ips[0].virtualmachineid, vm.id,
                          "Static NAT rule is not enabled for the VM on "
                          "the assigned public IP"
                          )
     self.debug("Successfully validated the assignment and state of public "
                "IP address - %s" % public_ip.ipaddress.ipaddress)
开发者ID:prashanthvarma,项目名称:cloudstack,代码行数:32,代码来源:nuageTestCase.py

示例3: validate_network_rules

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def validate_network_rules(self):
        """ Validate network rules
        """
        vms = VirtualMachine.list(
            self.api_client,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True
        )
        public_ips = PublicIPAddress.list(
            self.api_client,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True
        )
        for vm, public_ip in zip(vms, public_ips):
            try:
                ssh_1 = vm.get_ssh_client(
                    ipaddress=public_ip.ipaddress.ipaddress)
                self.debug("SSH into VM is successfully")

                self.debug(
                    "Verifying if we can ping to outside world from VM?")
                # Ping to outsite world
                res = ssh_1.execute("ping -c 1 www.google.com")
                # res = 64 bytes from maa03s17-in-f20.1e100.net (74.125.236.212):
                # icmp_req=1 ttl=57 time=25.9 ms
                # --- www.l.google.com ping statistics ---
                # 1 packets transmitted, 1 received, 0% packet loss, time 0ms
                # rtt min/avg/max/mdev = 25.970/25.970/25.970/0.000 ms
            except Exception as e:
                self.fail("Failed to SSH into VM - %s, %s" %
                          (public_ip.ipaddress.ipaddress, e))

            result = str(res)
            self.assertEqual(
                result.count("1 received"),
                1,
                "Ping to outside world from VM should be successful"
            )
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:42,代码来源:test_vpc_routers.py

示例4: validate_Public_IP

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
 def validate_Public_IP(self, public_ip, network, static_nat=False, vm=None):
     """Validates the Public IP"""
     self.debug("Check if the Public IP is successfully assigned to the network ?")
     public_ips = PublicIPAddress.list(self.api_client,
                                       id=public_ip.ipaddress.id,
                                       networkid=network.id,
                                       isstaticnat=static_nat,
                                       listall=True
                                       )
     self.assertEqual(isinstance(public_ips, list), True,
                      "List public Ip for network should return a valid list"
                      )
     self.assertEqual(public_ips[0].ipaddress, public_ip.ipaddress.ipaddress,
                      "List public Ip for network should list the assigned public Ip address"
                      )
     self.assertEqual(public_ips[0].state, "Allocated",
                      "Assigned public Ip is not in the allocated state"
                      )
     if static_nat and vm:
         self.assertEqual(public_ips[0].virtualmachineid, vm.id,
                          "Static NAT Rule not enabled for the VM using the assigned public Ip"
                          )
     self.debug("Assigned Public IP is successfully validated - %s" % public_ip.ipaddress.ipaddress)
开发者ID:DKrul,项目名称:cloudstack,代码行数:25,代码来源:nuageTestCase.py

示例5: test_01_firewall_rules_port_fw

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_01_firewall_rules_port_fw(self):
        """"Checking firewall rules deletion after static NAT disable"""


        # Validate the following:
        #1. Enable static NAT for a VM
        #2. Open up some ports. At this point there will be new rows in the
        #   firewall_rules table.
        #3. Disable static NAT for the VM.
        #4. Check fire wall rules are deleted from firewall_rules table.

        public_ip = self.public_ip.ipaddress

        # Enable Static NAT for VM
        StaticNATRule.enable(
                             self.apiclient,
                             public_ip.id,
                             self.virtual_machine.id
                            )
        self.debug("Enabled static NAT for public IP ID: %s" %
                                                    public_ip.id)

        #Create Static NAT rule, in fact it's firewall rule
        nat_rule = StaticNATRule.create(
                        self.apiclient,
                        self.services["firewall_rule"],
                        public_ip.id
                        )
        self.debug("Created Static NAT rule for public IP ID: %s" %
                                                    public_ip.id)
        self.debug("Checking IP address")
        ip_response = PublicIPAddress.list(
                                         self.apiclient,
                                         id = public_ip.id
                                        )
        self.assertEqual(
                            isinstance(ip_response, list),
                            True,
                            "Check ip response returns a valid list"
                        )
        self.assertNotEqual(
                            len(ip_response),
                            0,
                            "Check static NAT Rule is created"
                            )
        self.assertTrue(
                            ip_response[0].isstaticnat,
                            "IP is not static nat enabled"
                        )
        self.assertEqual(
                            ip_response[0].virtualmachineid,
                            self.virtual_machine.id,
                            "IP is not binding with the VM"
                        )

        self.debug("Checking Firewall rule")
        firewall_response = FireWallRule.list(
                                                self.apiclient,
                                                ipaddressid = public_ip.id,
                                                listall = True
                                             )
        self.assertEqual(
                            isinstance(firewall_response, list),
                            True,
                            "Check firewall response returns a valid list"
                        )
        self.assertNotEqual(
                            len(firewall_response),
                            0,
                            "Check firewall rule is created"
                            )
        self.assertEqual(
                            firewall_response[0].state,
                            "Active",
                            "Firewall rule is not active"
                        )
        self.assertEqual(
                            firewall_response[0].ipaddressid,
                            public_ip.id,
                            "Firewall rule is not static nat related"
                        )
        self.assertEqual(
                            firewall_response[0].startport,
                            str(self.services["firewall_rule"]["startport"]),
                            "Firewall rule is not with specific port"
                        )

        self.debug("Removed the firewall rule")
        nat_rule.delete(self.apiclient)

        self.debug("Checking IP address, it should still existed")
        ip_response = PublicIPAddress.list(
                                         self.apiclient,
                                         id = public_ip.id
                                        )
        self.assertEqual(
                            isinstance(ip_response, list),
                            True,
                            "Check ip response returns a valid list"
                        )
#.........这里部分代码省略.........
开发者ID:MountHuang,项目名称:cloudstack,代码行数:103,代码来源:test_blocker_bugs.py

示例6: test_01_redundant_vpc_site2site_vpn

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_01_redundant_vpc_site2site_vpn(self):
        """Test Site 2 Site VPN Across redundant VPCs"""
        self.logger.debug("Starting test: test_02_redundant_vpc_site2site_vpn")

        # 0) Get the default network offering for VPC
        networkOffering = NetworkOffering.list(
            self.apiclient, name="DefaultIsolatedNetworkOfferingForVpcNetworks")
        self.assert_(networkOffering is not None and len(
            networkOffering) > 0, "No VPC based network offering")

        # Create and enable redundant VPC offering
        redundant_vpc_offering = self._create_vpc_offering(
            'redundant_vpc_offering')
        self.assert_(redundant_vpc_offering is not None,
                     "Failed to create redundant VPC Offering")

        redundant_vpc_offering.update(self.apiclient, state='Enabled')

        # Create VPC 1
        vpc1 = None
        try:
            vpc1 = VPC.create(
                apiclient=self.apiclient,
                services=self.services["vpc"],
                networkDomain="vpc1.vpn",
                vpcofferingid=redundant_vpc_offering.id,
                zoneid=self.zone.id,
                account=self.account.name,
                domainid=self.domain.id
            )
        except Exception as e:
            self.fail(e)
        finally:
            self.assert_(vpc1 is not None, "VPC1 creation failed")

        self.logger.debug("VPC1 %s created" % vpc1.id)

        # Create VPC 2
        vpc2 = None
        try:
            vpc2 = VPC.create(
                apiclient=self.apiclient,
                services=self.services["vpc2"],
                networkDomain="vpc2.vpn",
                vpcofferingid=redundant_vpc_offering.id,
                zoneid=self.zone.id,
                account=self.account.name,
                domainid=self.account.domainid
            )
        except Exception as e:
            self.fail(e)
        finally:
            self.assert_(vpc2 is not None, "VPC2 creation failed")

        self.logger.debug("VPC2 %s created" % vpc2.id)

        default_acl = NetworkACLList.list(
            self.apiclient, name="default_allow")[0]

        # Create network in VPC 1
        ntwk1 = None
        try:
            ntwk1 = Network.create(
                apiclient=self.apiclient,
                services=self.services["network_1"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                networkofferingid=networkOffering[0].id,
                zoneid=self.zone.id,
                vpcid=vpc1.id,
                aclid=default_acl.id
            )
        except Exception as e:
            self.fail(e)
        finally:
            self.assertIsNotNone(ntwk1, "Network failed to create")

        self.logger.debug("Network %s created in VPC %s" % (ntwk1.id, vpc1.id))

        # Create network in VPC 2
        ntwk2 = None
        try:
            ntwk2 = Network.create(
                apiclient=self.apiclient,
                services=self.services["network_2"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                networkofferingid=networkOffering[0].id,
                zoneid=self.zone.id,
                vpcid=vpc2.id,
                aclid=default_acl.id
            )
        except Exception as e:
            self.fail(e)
        finally:
            self.assertIsNotNone(ntwk2, "Network failed to create")

        self.logger.debug("Network %s created in VPC %s" % (ntwk2.id, vpc2.id))

        # Deploy a vm in network 2
#.........这里部分代码省略.........
开发者ID:Accelerite,项目名称:cloudstack,代码行数:103,代码来源:test_vpc_vpn.py

示例7: test_01_vpc_remote_access_vpn

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_01_vpc_remote_access_vpn(self):
        """Test Remote Access VPN in VPC"""

        self.logger.debug("Starting test: test_01_vpc_remote_access_vpn")

        # 0) Get the default network offering for VPC
        self.logger.debug("Retrieving default VPC offering")
        networkOffering = NetworkOffering.list(
            self.apiclient, name="DefaultIsolatedNetworkOfferingForVpcNetworks")
        self.assert_(networkOffering is not None and len(
            networkOffering) > 0, "No VPC based network offering")

        # 1) Create VPC
        vpcOffering = VpcOffering.list(self.apiclient, name="Default VPC offering")
        self.assert_(vpcOffering is not None and len(
            vpcOffering) > 0, "No VPC offerings found")

        vpc = None
        try:
            vpc = VPC.create(
                apiclient=self.apiclient,
                services=self.services["vpc"],
                networkDomain="vpc.vpn",
                vpcofferingid=vpcOffering[0].id,
                zoneid=self.zone.id,
                account=self.account.name,
                domainid=self.domain.id
            )
        except Exception as e:
            self.fail(e)
        finally:
            self.assert_(vpc is not None, "VPC creation failed")
            self.logger.debug("VPC %s created" % (vpc.id))

        try:
            # 2) Create network in VPC
            ntwk = Network.create(
                apiclient=self.apiclient,
                services=self.services["network_1"],
                accountid=self.account.name,
                domainid=self.domain.id,
                networkofferingid=networkOffering[0].id,
                zoneid=self.zone.id,
                vpcid=vpc.id
            )
        except Exception as e:
            self.fail(e)
        finally:
            self.assertIsNotNone(ntwk, "Network failed to create")
            self.logger.debug(
                "Network %s created in VPC %s" % (ntwk.id, vpc.id))

        try:
            # 3) Deploy a vm
            vm = VirtualMachine.create(self.apiclient, services=self.services["virtual_machine"],
                                       templateid=self.template.id,
                                       zoneid=self.zone.id,
                                       accountid=self.account.name,
                                       domainid=self.domain.id,
                                       serviceofferingid=self.compute_offering.id,
                                       networkids=ntwk.id,
                                       hypervisor=self.hypervisor
                                       )
            self.assert_(vm is not None, "VM failed to deploy")
            self.assert_(vm.state == 'Running', "VM is not running")
            self.debug("VM %s deployed in VPC %s" % (vm.id, vpc.id))
        except Exception as e:
            self.fail(e)
        finally:
            self.logger.debug("Deployed virtual machine: OK")

        try:
            # 4) Enable VPN for VPC
            src_nat_list = PublicIPAddress.list(
                self.apiclient,
                account=self.account.name,
                domainid=self.account.domainid,
                listall=True,
                issourcenat=True,
                vpcid=vpc.id
            )
            ip = src_nat_list[0]
        except Exception as e:
            self.fail(e)
        finally:
            self.logger.debug("Acquired public ip address: OK")

        try:
            vpn = Vpn.create(self.apiclient,
                             publicipid=ip.id,
                             account=self.account.name,
                             domainid=self.account.domainid,
                             iprange=self.services["vpn"]["iprange"],
                             fordisplay=self.services["vpn"]["fordisplay"]
                             )
        except Exception as e:
            self.fail(e)
        finally:
            self.assertIsNotNone(vpn, "Failed to create Remote Access VPN")
            self.logger.debug("Created Remote Access VPN: OK")
#.........这里部分代码省略.........
开发者ID:Accelerite,项目名称:cloudstack,代码行数:103,代码来源:test_vpc_vpn.py

示例8: test_forceDeleteDomain

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress 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

示例9: test_08_add_TCP_PF_Rule_In_VPN

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_08_add_TCP_PF_Rule_In_VPN(self):
        """
        Test to add TCP Port Forwarding rule for specific ports(500,1701 and 4500) in VPN
        """
        # Steps for verification
        # 1. Enable vpn on SourceNAT IP address
        # 2. Configure PF with TCP ports 500,1701 and 4500. It should be allowed
        # Should not conflict with UPD ports used for VPN

        vm_res = VirtualMachine.list(
            self.apiclient,
            id=self.virtual_machine.id,
            listall=True
        )
        self.assertEqual(
            validateList(vm_res)[0],
            PASS,
            "Failed to list virtual machine"
        )
        network_id = vm_res[0].nic[0].networkid
        src_nat_list = PublicIPAddress.list(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True,
            issourcenat=True,
            associatednetworkid=network_id
        )
        self.assertEqual(
            validateList(src_nat_list)[0],
            PASS,
            "Failed to list source nat ip address"
        )
        ip = src_nat_list[0]
        try:
            vpn = Vpn.create(
                self.apiclient,
                publicipid=ip.id,
                account=self.account.name,
                domainid=self.account.domainid,
            )
            self.assertIsNotNone(
                vpn,
                "Failed to create remote access vpn"
            )
        except Exception as e:
            self.fail("Failed to enable vpn on SourceNAT IP with error: %s" % e)

        #Create PF rule with TCP ports 500,4500 and 1701
        self.services['natrule']['protocol']="TCP"
        for port in [500, 4500, 1701]:
            self.services['natrule']['privateport'] = port
            self.services['natrule']['publicport'] = port
            try:
                nat = NATRule.create(
                    self.apiclient,
                    self.virtual_machine,
                    self.services["natrule"],
                    ip.id
                )
                self.assertIsNotNone(
                    nat,
                    "Failed to add PF rule with tcp parts matching vpn"
                )
            except Exception as e:
                self.fail("Creating PF rule for TCP port %s in VPN failed : %s" % (port, e))
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:69,代码来源:test_vpn_users.py

示例10: test_vpc_network_bcf

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_vpc_network_bcf(self):
        """Test VPC workflow with BigSwitch BCF plugin
           1. Create a VPC with three networks
           2. Create one VM on each of the three networks
           3. Add firewall rule to make virtual router pingable
           4. Test ping to virtual router public IP
           5. Add static NAT to vm_1, with firewall rule to allow ssh
           6. Add NAT rule to allow ping between net1 and net2
           7. Ssh to vm_1, ping vm_2 private address, should succeed
           8. continue ... ping vm_3 private address, should fail
           9. continue ... ping Internet, should succeed
        """

        self.debug("STEP 1: Creating VPC with VPC offering: %s" %
                            self.vpc_offering.id)
        vpc = VPC.create(
                         self.apiclient,
                         self.services["vpc"],
                         accountid=self.account.name,
                         domainid=self.account.domainid,
                         vpcofferingid=self.vpc_offering.id,
                         zoneid=self.zone.id
                        )
        self.debug("Created VPC with ID: %s" % self.vpc.id)

        # Creating network using the vpc network offering created
        self.debug("Creating networks with vpc network offering: %s" %
                    self.vpc_network_offering.id)
        net1 = Network.create(
                              self.apiclient,
                              self.services["vpc_network"],
                              accountid=self.account.name,
                              domainid=self.account.domainid,
                              networkofferingid=self.vpc_network_offering.id,
                              zoneid=self.zone.id,
                              gateway="10.0.100.1",
                              vpcid=vpc.id
                             )
        self.debug("Created network with ID: %s" % net1.id)

        net2 = Network.create(
                              self.apiclient,
                              self.services["vpc_network"],
                              accountid=self.account.name,
                              domainid=self.account.domainid,
                              networkofferingid=self.vpc_network_offering.id,
                              zoneid=self.zone.id,
                              gateway="10.0.101.1",
                              vpcid=vpc.id
                             )
        self.debug("Created network with ID: %s" % net2.id)

        net3 = Network.create(
                              self.apiclient,
                              self.services["vpc_network"],
                              accountid=self.account.name,
                              domainid=self.account.domainid,
                              networkofferingid=self.vpc_network_offering.id,
                              zoneid=self.zone.id,
                              gateway="10.0.102.0",
                              vpcid=vpc.id
                             )
        self.debug("Created network with ID: %s" % net3.id)

        self.debug("STEP 2: Deploying VMs in networks")

        vm_1 = VirtualMachine.create(
                                     self.apiclient,
                                     self.services["virtual_machine"],
                                     accountid=self.account.name,
                                     domainid=self.account.domainid,
                                     serviceofferingid=self.service_offering.id,
                                     networkids=[ str(net1.id), ]
                                    )
        self.debug("Deployed VM in network: %s" % net1.id)
        list_vm_response = VirtualMachine.list(
                                               self.apiclient,
                                               id=vm_1.id
                                              )
        self.debug(
                   "Verify listVirtualMachines response for virtual machine: %s" \
                   % vm_1.id
                  )
        self.assertEqual(
                         isinstance(list_vm_response, list),
                         True,
                         "Check list response returns a valid list"
                        )
        vm_response = list_vm_response[0]

        self.assertEqual(
                         vm_response.state,
                         "Running",
                         "VM state should be running after deployment"
                        )

        vm_2 = VirtualMachine.create(
                                     self.apiclient,
                                     self.services["virtual_machine"],
                                     accountid=self.account.name,
#.........这里部分代码省略.........
开发者ID:Accelerite,项目名称:cloudstack,代码行数:103,代码来源:test_bigswitch_bcf.py

示例11: setUpClass

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def setUpClass(cls):
        cls._cleanup = []
        cls.testClient = super(TestVPCRouterOneNetwork, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.vpcSupported = True
        cls._cleanup = []
        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            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.api_client,
            cls.services["service_offering"]
        )
        cls._cleanup.append(cls.service_offering)
        cls.vpc_off = VpcOffering.create(
            cls.api_client,
            cls.services["vpc_offering"]
        )
        cls.vpc_off.update(cls.api_client, state='Enabled')
        cls._cleanup.append(cls.vpc_off)

        cls.account = Account.create(
            cls.api_client,
            cls.services["account"],
            admin=True,
            domainid=cls.domain.id
        )
        cls._cleanup.insert(0, cls.account)

        cls.services["vpc"]["cidr"] = '10.1.1.1/16'
        cls.vpc = VPC.create(
            cls.api_client,
            cls.services["vpc"],
            vpcofferingid=cls.vpc_off.id,
            zoneid=cls.zone.id,
            account=cls.account.name,
            domainid=cls.account.domainid
        )

        private_gateway = PrivateGateway.create(
            cls.api_client,
            gateway='10.1.3.1',
            ipaddress='10.1.3.100',
            netmask='255.255.255.0',
            vlan=678,
            vpcid=cls.vpc.id
        )
        cls.gateways = PrivateGateway.list(
            cls.api_client,
            id=private_gateway.id,
            listall=True
        )

        static_route = StaticRoute.create(
            cls.api_client,
            cidr='11.1.1.1/24',
            gatewayid=private_gateway.id
        )
        cls.static_routes = StaticRoute.list(
            cls.api_client,
            id=static_route.id,
            listall=True
        )

        cls.nw_off = NetworkOffering.create(
            cls.api_client,
            cls.services["network_offering"],
            conservemode=False
        )
        # Enable Network offering
        cls.nw_off.update(cls.api_client, state='Enabled')
        cls._cleanup.append(cls.nw_off)

        # Creating network using the network offering created
        cls.network_1 = Network.create(
            cls.api_client,
            cls.services["network"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            networkofferingid=cls.nw_off.id,
            zoneid=cls.zone.id,
            gateway='10.1.1.1',
            vpcid=cls.vpc.id
        )

        # Spawn an instance in that network
        vm_1 = VirtualMachine.create(
            cls.api_client,
            cls.services["virtual_machine"],
            accountid=cls.account.name,
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:103,代码来源:test_vpc_routers.py

示例12: test_create_network_with_snat

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_create_network_with_snat(self):
        """Test to create a network with SourceNAT service only"""

        # Validate the following
        # 1. create a network offering with source nat service
        # 2. create a network and deploy a vm within the network
        # 3. deployment and network creation should be successful
        # 4. attempt to create a fw rule. should fail since offering hasn't allowed it
        # 5. try to ping out of the guest to www.google.com to check SourceNAT is working

        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            admin=False,
            domainid=self.domain.id
        )
        self.cleanup.append(self.account)

        # Create a network offering VR and only SourceNAT service
        self.debug(
            "creating network offering with source NAT only"
        )
        self.network_offering = NetworkOffering.create(
            self.apiclient,
            self.services["network_offering_sourcenat"]
        )
        # Enable Network offering
        self.network_offering.update(self.apiclient, state='Enabled')
        self.debug("Created n/w offering with ID: %s" %
                   self.network_offering.id)

        # Creating network using the network offering created
        self.debug("Creating network with network offering: %s" %
                   self.network_offering.id)
        self.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 guest network with ID: %s within account %s" % (self.network.id, self.account.name))

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

        src_nat_list = PublicIPAddress.list(
            self.apiclient,
            associatednetworkid=self.network.id,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True,
            issourcenat=True,
        )
        self.assertEqual(
            isinstance(src_nat_list, list),
            True,
            "List Public IP should return a valid source NAT"
        )
        self.assertNotEqual(
            len(src_nat_list),
            0,
            "Length of response from listPublicIp should not be 0"
        )

        src_nat = src_nat_list[0]

        self.debug("Successfully implemented network with source NAT IP: %s" %
                   src_nat.ipaddress)

        with self.assertRaises(Exception):
            FireWallRule.create(
                self.apiclient,
                ipaddressid=src_nat.id,
                protocol='TCP',
                cidrlist=[self.services["fw_rule"]["cidr"]],
                startport=self.services["fw_rule"]["startport"],
                endport=self.services["fw_rule"]["endport"]
            )
        return
开发者ID:miguelaferreira,项目名称:cosmic-core,代码行数:92,代码来源:test_network_offering.py

示例13: test_02_network_off_with_conserve_mode

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_02_network_off_with_conserve_mode(self):
        """Test Network offering with Conserve mode ON and VR - All services
        """


        # Validate the following
        # 1. Create a Network from the above network offering and deploy a VM.
        # 2. On source NAT ipaddress, we should be allowed to add a LB rules
        # 3. On source NAT ipaddress, we should be allowed to add a PF rules
        # 4. On source NAT ipaddress, we should be allowed to add a Firewall
        #    rules
        # 5. On an ipaddress that has Lb rules, we should be allowed to
        #    program PF rules.
        # 6. We should be allowed to program multiple PF rules on the same Ip
        #    address on different public ports.
        # 7. We should be allowed to program multiple LB rules on the same Ip
        #    address for different public port ranges.
        # 8. On source NAT ipaddress, we should be allowed to Enable VPN
        #    access.

        # Create a network offering with all virtual router services enabled
        self.debug(
            "Creating n/w offering with all services in VR & conserve mode:off"
            )
        self.network_offering = NetworkOffering.create(
                                            self.api_client,
                                            self.services["network_offering"],
                                            conservemode=True
                                            )
        self.cleanup.append(self.network_offering)

        self.debug("Created n/w offering with ID: %s" %
                                                    self.network_offering.id)
    # Enable Network offering
        self.network_offering.update(self.apiclient, state='Enabled')

        # Creating network using the network offering created
        self.debug("Creating network with network offering: %s" %
                                                    self.network_offering.id)
        self.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" % self.network.id)

        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(self.network.id)]
                                  )
        self.debug("Deployed VM in network: %s" % self.network.id)

        src_nat_list = PublicIPAddress.list(
                                        self.apiclient,
                                        associatednetworkid=self.network.id,
                                        account=self.account.name,
                                        domainid=self.account.domainid,
                                        listall=True,
                                        issourcenat=True,
                                        )
        self.assertEqual(
                         isinstance(src_nat_list, list),
                         True,
                         "List Public IP should return a valid source NAT"
                         )
        self.assertNotEqual(
                    len(src_nat_list),
                    0,
                    "Length of response from listPublicIp should not be 0"
                    )

        src_nat = src_nat_list[0]

        self.debug("Trying to create LB rule on source NAT IP: %s" %
                                                        src_nat.ipaddress)
        # Create Load Balancer rule with source NAT
        lb_rule = LoadBalancerRule.create(
                                    self.apiclient,
                                    self.services["lbrule"],
                                    ipaddressid=src_nat.id,
                                    accountid=self.account.name
                                )
        self.debug("Created LB rule on source NAT: %s" % src_nat.ipaddress)

        lb_rules = LoadBalancerRule.list(
                                         self.apiclient,
                                         id=lb_rule.id
                                         )
        self.assertEqual(
                         isinstance(lb_rules, list),
#.........这里部分代码省略.........
开发者ID:miguelaferreira,项目名称:cosmic-core,代码行数:103,代码来源:test_network_offering.py

示例14: test_01_vpc_remote_access_vpn

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def test_01_vpc_remote_access_vpn(self):
        """Test Remote Access VPN in VPC"""
        # 1) Create VPC
        vpc = VPC.create(
            api_client=self.apiclient,
            services=self.services["vpc"],
            networkDomain="vpc.vpn",
            vpcofferingid=self.vpc_offering.id,
            zoneid=self.zone.id,
            account=self.account.name,
            domainid=self.domain.id
        )

        self.assertIsNotNone(vpc, "VPC creation failed")
        self.logger.debug("VPC %s created" % (vpc.id))

        self.cleanup.append(vpc)

        # 2) Create network in VPC
        ntwk = Network.create(
            api_client=self.apiclient,
            services=self.services["network_1"],
            accountid=self.account.name,
            domainid=self.domain.id,
            networkofferingid=self.network_offering.id,
            zoneid=self.zone.id,
            vpcid=vpc.id
        )

        self.assertIsNotNone(ntwk, "Network failed to create")
        self.logger.debug("Network %s created in VPC %s" % (ntwk.id, vpc.id))

        self.cleanup.append(ntwk)

        # 3) Deploy a vm
        vm = VirtualMachine.create(self.apiclient, services=self.services["virtual_machine"],
                                   templateid=self.template.id,
                                   zoneid=self.zone.id,
                                   accountid=self.account.name,
                                   domainid=self.domain.id,
                                   serviceofferingid=self.virtual_machine_offering.id,
                                   networkids=ntwk.id,
                                   hypervisor=self.hypervisor
                                   )
        self.assertIsNotNone(vm, "VM failed to deploy")
        self.assertEquals(vm.state, 'Running', "VM is not running")
        self.debug("VM %s deployed in VPC %s" % (vm.id, vpc.id))

        self.logger.debug("Deployed virtual machine: OK")
        self.cleanup.append(vm)

        # 4) Enable VPN for VPC
        src_nat_list = PublicIPAddress.list(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True,
            issourcenat=True,
            vpcid=vpc.id
        )
        ip = src_nat_list[0]

        self.logger.debug("Acquired public ip address: OK")

        vpn = Vpn.create(self.apiclient,
                         publicipid=ip.id,
                         account=self.account.name,
                         domainid=self.account.domainid,
                         iprange=self.services["vpn"]["iprange"],
                         fordisplay=self.services["vpn"]["fordisplay"]
                         )

        self.assertIsNotNone(vpn, "Failed to create Remote Access VPN")
        self.logger.debug("Created Remote Access VPN: OK")

        vpn_user = None
        # 5) Add VPN user for VPC
        vpn_user = VpnUser.create(self.apiclient,
                                  account=self.account.name,
                                  domainid=self.account.domainid,
                                  username=self.services["vpn"]["vpn_user"],
                                  password=self.services["vpn"]["vpn_pass"]
                                  )

        self.assertIsNotNone(vpn_user, "Failed to create Remote Access VPN User")
        self.logger.debug("Created VPN User: OK")

        # TODO: Add an actual remote vpn connection test from a remote vpc

        # 9) Disable VPN for VPC
        vpn.delete(self.apiclient)

        self.logger.debug("Deleted the Remote Access VPN: OK")
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:95,代码来源:test_vpc_vpn.py

示例15: _test_vpc_site2site_vpn

# 需要导入模块: from marvin.lib.base import PublicIPAddress [as 别名]
# 或者: from marvin.lib.base.PublicIPAddress import list [as 别名]
    def _test_vpc_site2site_vpn(self, vpc_offering, num_VPCs=3):
        # Number of VPNs (to test) is number_of_VPCs - 1
        # By default test setting up 2 VPNs from VPC0, requiring total of 3 VPCs

        maxnumVM = num_VPCs - 1
        # Create VPC i
        vpc_list = []
        for i in range(num_VPCs):
            # Generate VPC (mostly subnet) info
            vpcservice_n = copy.deepcopy(self.services["vpcN"])
            for key in vpcservice_n.keys():
                vpcservice_n[key] = vpcservice_n[key].format(N=`i`)

            vpc_n = VPC.create(
                api_client=self.apiclient,
                services=vpcservice_n,
                networkDomain="vpc%d.vpn" % i,
                vpcofferingid=vpc_offering.id,
                zoneid=self.zone.id,
                account=self.account.name,
                domainid=self.domain.id
            )
            self.assertIsNotNone(vpc_n, "VPC%d creation failed" % i)
            vpc_list.append(vpc_n)
            self.cleanup.append(vpc_n)
            self.logger.debug("VPC%d %s created" % (i, vpc_list[i].id))

        default_acl = NetworkACLList.list(self.apiclient, name="default_allow")[0]

        # Create network in VPC i
        ntwk_list = []
        for i in range(num_VPCs):
            # Generate network (mostly subnet) info
            ntwk_info_n = copy.deepcopy(self.services["network_N"])
            for key in ntwk_info_n.keys():
                ntwk_info_n[key] = ntwk_info_n[key].format(N=`i`)

            ntwk_n = Network.create(
                api_client=self.apiclient,
                services=ntwk_info_n,
                accountid=self.account.name,
                domainid=self.account.domainid,
                networkofferingid=self.network_offering.id,
                zoneid=self.zone.id,
                vpcid=vpc_list[i].id,
                aclid=default_acl.id
            )
            self.assertIsNotNone(ntwk_n, "Network%d failed to create" % i)
            self.cleanup.append(ntwk_n)
            ntwk_list.append(ntwk_n)
            self.logger.debug("Network%d %s created in VPC %s" % (i, ntwk_list[i].id, vpc_list[i].id))

        # Deploy a vm in network i
        vm_list = []
        vm_n = None

        for i in range(num_VPCs):
            vm_n = VirtualMachine.create(self.apiclient, services=self.services["virtual_machine"],
                                         templateid=self.template.id,
                                         zoneid=self.zone.id,
                                         accountid=self.account.name,
                                         domainid=self.account.domainid,
                                         serviceofferingid=self.virtual_machine_offering.id,
                                         networkids=[ntwk_list[i].id],
                                         hypervisor=self.hypervisor,
                                         mode='advanced' if (i == 0) or (i == maxnumVM) else 'default'
                                         )
            self.assertIsNotNone(vm_n, "VM%d failed to deploy" % i)
            self.cleanup.append(vm_n)
            vm_list.append(vm_n)
            self.logger.debug("VM%d %s deployed in VPC %s" % (i, vm_list[i].id, vpc_list[i].id))
            self.assertEquals(vm_n.state, 'Running', "VM%d is not running" % i)

        # 4) Enable Site-to-Site VPN for VPC
        vpn_response_list = []
        for i in range(num_VPCs):
            vpn_response = Vpn.createVpnGateway(self.apiclient, vpc_list[i].id)
            self.assertIsNotNone(vpn_response, "Failed to enable VPN Gateway %d" % i)
            vpn_response_list.append(vpn_response)
            self.logger.debug("VPN gateway for VPC%d %s enabled" % (i, vpc_list[i].id))

        # 5) Add VPN Customer gateway info
        vpn_cust_gw_list = []
        services = self.services["vpncustomergateway"]
        for i in range(num_VPCs):
            src_nat_list = PublicIPAddress.list(
                self.apiclient,
                account=self.account.name,
                domainid=self.account.domainid,
                listall=True,
                issourcenat=True,
                vpcid=vpc_list[i].id
            )
            ip = src_nat_list[0]

            customer_response = VpnCustomerGateway.create(self.apiclient, services, "Peer VPC" + `i`, ip.ipaddress, vpc_list[i].cidr, self.account.name, self.domain.id)
            self.cleanup.insert(0, customer_response)  # this has to be cleaned up after the VPCs have been destroyed (due to client connectionsonections)
            vpn_cust_gw_list.append(customer_response)
            self.logger.debug("VPN customer gateway added for VPC%d %s enabled" % (i, vpc_list[i].id))

#.........这里部分代码省略.........
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:103,代码来源:test_vpc_vpn.py


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