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


Python base.StaticNATRule类代码示例

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


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

示例1: delete_StaticNatRule_For_VM

 def delete_StaticNatRule_For_VM(self, vm, public_ip):
     self.debug("Disabling static NAT for public IP - %s" % public_ip.ipaddress.ipaddress)
     StaticNATRule.disable(self.api_client,
                           ipaddressid=public_ip.ipaddress.id,
                           virtualmachineid=vm.id
                           )
     self.debug("Static NAT disabled for public IP - %s" % public_ip.ipaddress.ipaddress)
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:7,代码来源:nuageTestCase.py

示例2: createNetworkRulesForVM

def createNetworkRulesForVM(apiclient, virtualmachine, ruletype,
                            account, networkruledata):
    """Acquire IP, create Firewall and NAT/StaticNAT rule
        (associating it with given vm) for that IP"""

    try:
        public_ip = PublicIPAddress.create(
                apiclient,accountid=account.name,
                zoneid=virtualmachine.zoneid,domainid=account.domainid,
                networkid=virtualmachine.nic[0].networkid)

        FireWallRule.create(
            apiclient,ipaddressid=public_ip.ipaddress.id,
            protocol='TCP', cidrlist=[networkruledata["fwrule"]["cidr"]],
            startport=networkruledata["fwrule"]["startport"],
            endport=networkruledata["fwrule"]["endport"]
            )

        if ruletype == NAT_RULE:
            # Create NAT rule
            NATRule.create(apiclient, virtualmachine,
                                 networkruledata["natrule"],ipaddressid=public_ip.ipaddress.id,
                                 networkid=virtualmachine.nic[0].networkid)
        elif ruletype == STATIC_NAT_RULE:
            # Enable Static NAT for VM
            StaticNATRule.enable(apiclient,public_ip.ipaddress.id,
                                     virtualmachine.id, networkid=virtualmachine.nic[0].networkid)
    except Exception as e:
        [FAIL, e]
    return [PASS, public_ip]
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:30,代码来源:common.py

示例3: delete_StaticNatRule_For_VM

 def delete_StaticNatRule_For_VM(self, public_ip):
     self.debug("Disabling Static NAT rule on public IP - %s" %
                public_ip.ipaddress.ipaddress)
     StaticNATRule.disable(self.api_client,
                           ipaddressid=public_ip.ipaddress.id
                           )
     self.debug("Static NAT rule disabled on public IP - %s" %
                public_ip.ipaddress.ipaddress)
开发者ID:prashanthvarma,项目名称:cloudstack,代码行数:8,代码来源:nuageTestCase.py

示例4: create_StaticNatRule_For_VM

 def create_StaticNatRule_For_VM(self, vm, public_ip, network, vmguestip=None):
     self.debug("Enabling static NAT for public IP - %s" % public_ip.ipaddress.ipaddress)
     StaticNATRule.enable(self.api_client,
                          ipaddressid=public_ip.ipaddress.id,
                          virtualmachineid=vm.id,
                          networkid=network.id,
                          vmguestip=vmguestip
                          )
     self.debug("Static NAT enabled for public IP - %s" % public_ip.ipaddress.ipaddress)
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:9,代码来源:nuageTestCase.py

示例5: delete_StaticNatRule_For_VM

 def delete_StaticNatRule_For_VM(self, vm, public_ip):
     self.debug("Disabling static NAT for IP: %s" %
                                                     public_ip.ipaddress.ipaddress)
     try:
             StaticNATRule.disable(
                                     self.apiclient,
                                     ipaddressid=public_ip.ipaddress.id,
                                     virtualmachineid=vm.id,
                                     )
             self.debug("Static NAT disabled for IP: %s" %
                                                     public_ip.ipaddress.ipaddress)
     except Exception as e:
             self.fail("Failed to disabled static NAT on IP: %s - %s" % (
                                                 public_ip.ipaddress.ipaddress, e))
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:14,代码来源:test_vpc_network_staticnatrule.py

示例6: create_StaticNatRule_For_VM

 def create_StaticNatRule_For_VM(self, vm, public_ip, network):
     self.debug("Enabling static NAT for IP: %s" %
                                                     public_ip.ipaddress.ipaddress)
     try:
             StaticNATRule.enable(
                                     self.apiclient,
                                     ipaddressid=public_ip.ipaddress.id,
                                     virtualmachineid=vm.id,
                                     networkid=network.id
                                     )
             self.debug("Static NAT enabled for IP: %s" %
                                                     public_ip.ipaddress.ipaddress)
     except Exception as e:
             self.fail("Failed to enable static NAT on IP: %s - %s" % (
                                                 public_ip.ipaddress.ipaddress, e))
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:15,代码来源:test_vpc_network_staticnatrule.py

示例7: removeNetworkRules

    def removeNetworkRules(self, rule, ipaddressobj):
        """ Remove specified rule on acquired public IP and
        default network of virtual machine
        """
        self.fw_rule.delete(self.apiclient)

        if rule == STATIC_NAT_RULE:
            StaticNATRule.disable(
                self.apiclient,
                ipaddressobj.ipaddress.id)

        elif rule == LB_RULE:
            self.lb_rule.delete(self.apiclient)
        else:
            self.nat_rule.delete(self.apiclient)
        return
开发者ID:Tosta-Mixta,项目名称:cloudstack,代码行数:16,代码来源:test_network.py

示例8: createNetworkRules

    def createNetworkRules(self, rule, ipaddressobj, networkid):
        """ Create specified rule on acquired public IP and
        default network of virtual machine
        """
        # Open up firewall port for SSH
        self.fw_rule = FireWallRule.create(
            self.apiclient,
            ipaddressid=ipaddressobj.ipaddress.id,
            protocol=self.services["fwrule"]["protocol"],
            cidrlist=['0.0.0.0/0'],
            startport=self.services["fwrule"]["startport"],
            endport=self.services["fwrule"]["endport"]
        )

        if rule == STATIC_NAT_RULE:
            StaticNATRule.enable(
                self.apiclient,
                ipaddressobj.ipaddress.id,
                self.virtual_machine.id,
                networkid
            )

        elif rule == LB_RULE:
            self.lb_rule = LoadBalancerRule.create(
                self.apiclient,
                self.services["lbrule"],
                ipaddressid=ipaddressobj.ipaddress.id,
                accountid=self.account.name,
                networkid=self.virtual_machine.nic[0].networkid,
                domainid=self.account.domainid)

            vmidipmap = [{"vmid": str(self.virtual_machine.id),
                          "vmip": str(self.virtual_machine.nic[0].ipaddress)}]

            self.lb_rule.assign(
                self.apiclient,
                vmidipmap=vmidipmap
            )
        else:
            self.nat_rule = NATRule.create(
                self.apiclient,
                self.virtual_machine,
                self.services["natrule"],
                ipaddressobj.ipaddress.id
            )
        return
开发者ID:Tosta-Mixta,项目名称:cloudstack,代码行数:46,代码来源:test_network.py

示例9: removeNetworkRules

    def removeNetworkRules(self, rule):
        """ Remove specified rule on acquired public IP and
        default network of virtual machine
        """
        self.fw_rule.delete(self.apiclient)

        if rule == STATIC_NAT_RULE:
            StaticNATRule.disable(
                self.apiclient,
                self.ipaddress.ipaddress.id)

        elif rule == LB_RULE:
            self.lb_rule.delete(self.apiclient)
        else:
            self.nat_rule.delete(self.apiclient)

        logger.debug("Releasing IP %s from account %s" % (self.ipaddress.ipaddress.ipaddress, self.account.name))
        self.ipaddress.delete(self.apiclient)

        return
开发者ID:PCextreme,项目名称:cloudstack,代码行数:20,代码来源:test_network.py

示例10: create_StaticNatRule_For_VM

 def create_StaticNatRule_For_VM(self, vm, public_ip, network, vmguestip=None):
     self.debug("Enabling Static NAT rule on public IP - %s for VM with ID - %s in network with ID - %s" %
                (public_ip.ipaddress.ipaddress, vm.id, network.id))
     static_nat_rule = StaticNATRule.enable(self.api_client,
                                            ipaddressid=public_ip.ipaddress.id,
                                            virtualmachineid=vm.id,
                                            networkid=network.id,
                                            vmguestip=vmguestip
                                            )
     self.debug("Static NAT rule enabled on public IP - %s for VM with ID - %s in network with ID - %s" %
                (public_ip.ipaddress.ipaddress, vm.id, network.id))
     return static_nat_rule
开发者ID:KamilStupak,项目名称:cloudstack,代码行数:12,代码来源:nuageTestCase.py

示例11: test_01_firewall_rules_port_fw

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

示例12: test_03_deploy_vms_in_vpc_with_regionlevelvpc


#.........这里部分代码省略.........
                                    vpcid=vpc.id,
                                    domainid=self.account.domainid
                                )

        self.debug("Associating public IP for network: %s" % vpc.name)
        public_ip_2 = PublicIPAddress.create(
                                self.apiclient,
                                accountid=self.account.name,
                                zoneid=self.zone.id,
                                domainid=self.account.domainid,
                                networkid=network.id,
                                vpcid=vpc.id
                                )
        self.debug("Associated %s with network %s" % (
                                        public_ip_2.ipaddress.ipaddress,
                                        network.id
                                        ))

        NATRule.create(
                                  self.apiclient,
                                  virtual_machine,
                                  self.services["natrule"],
                                  ipaddressid=public_ip_2.ipaddress.id,
                                  openfirewall=False,
                                  networkid=network.id,
                                  vpcid=vpc.id
                                  )

        self.debug("Adding NetwrokACl rules to make PF and LB accessible")
        NetworkACL.create(
                self.apiclient,
                networkid=network.id,
                services=self.services["natrule"],
                traffictype='Ingress'
                )

        NetworkACL.create(
                                self.apiclient,
                                networkid=network.id,
                                services=self.services["lbrule"],
                                traffictype='Ingress'
                                )
        self.debug("Checking if we can SSH into VM?")
        try:
            virtual_machine.get_ssh_client(
                ipaddress=public_ip_2.ipaddress.ipaddress,
                )
            self.debug("SSH into VM is successfully")
        except Exception as e:
            self.fail("Failed to SSH into VM - %s, %s" %
                    (public_ip_2.ipaddress.ipaddress, e))

        self.debug("Associating public IP for network: %s" % network.name)
        public_ip_3 = PublicIPAddress.create(
                                self.apiclient,
                                accountid=self.account.name,
                                zoneid=self.zone.id,
                                domainid=self.account.domainid,
                                networkid=network.id,
                                vpcid=vpc.id
                                )
        self.debug("Associated %s with network %s" % (
                                        public_ip_3.ipaddress.ipaddress,
                                        network.id
                                        ))
        self.debug("Enabling static NAT for IP: %s" %
                                            public_ip_3.ipaddress.ipaddress)
        try:
            StaticNATRule.enable(
                              self.apiclient,
                              ipaddressid=public_ip_3.ipaddress.id,
                              virtualmachineid=virtual_machine.id,
                              networkid=network.id
                              )
            self.debug("Static NAT enabled for IP: %s" %
                                            public_ip_3.ipaddress.ipaddress)
        except Exception as e:
            self.fail("Failed to enable static NAT on IP: %s - %s" % (
                                            public_ip_3.ipaddress.ipaddress, e))

        public_ips = PublicIPAddress.list(
                                          self.apiclient,
                                          networkid=network.id,
                                          listall=True,
                                          isstaticnat=True,
                                          account=self.account.name,
                                          domainid=self.account.domainid
                                          )
        self.assertEqual(
                         isinstance(public_ips, list),
                         True,
                         "List public Ip for network should list the Ip addr"
                         )
        self.assertEqual(
                         public_ips[0].ipaddress,
                         public_ip_3.ipaddress.ipaddress,
                         "List public Ip for network should list the Ip addr"
                         )
        # TODO: Remote Access VPN is not yet supported in VPC
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:101,代码来源:test_region_vpc.py

示例13: setUpClass


#.........这里部分代码省略.........
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[str(cls.network_1.id)]
        )

        VirtualMachine.list(
            cls.api_client,
            account=cls.account.name,
            domainid=cls.account.domainid,
            listall=True
        )

        public_ip_1 = PublicIPAddress.create(
            cls.api_client,
            accountid=cls.account.name,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            networkid=cls.network_1.id,
            vpcid=cls.vpc.id
        )

        NATRule.create(
            cls.api_client,
            vm_1,
            cls.services["natrule"],
            ipaddressid=public_ip_1.ipaddress.id,
            openfirewall=False,
            networkid=cls.network_1.id,
            vpcid=cls.vpc.id
        )

        NetworkACL.create(
            cls.api_client,
            networkid=cls.network_1.id,
            services=cls.services["natrule"],
            traffictype='Ingress'
        )

        public_ip_2 = PublicIPAddress.create(
            cls.api_client,
            accountid=cls.account.name,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            networkid=cls.network_1.id,
            vpcid=cls.vpc.id
        )
        try:
            StaticNATRule.enable(
                cls.api_client,
                ipaddressid=public_ip_2.ipaddress.id,
                virtualmachineid=vm_2.id,
                networkid=cls.network_1.id
            )
        except Exception as e:
            cls.fail("Failed to enable static NAT on IP: %s - %s" % (
                public_ip_2.ipaddress.ipaddress, e))

        PublicIPAddress.list(
            cls.api_client,
            networkid=cls.network_1.id,
            listall=True,
            isstaticnat=True,
            account=cls.account.name,
            domainid=cls.account.domainid
        )
        public_ip_3 = PublicIPAddress.create(
            cls.api_client,
            accountid=cls.account.name,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            networkid=cls.network_1.id,
            vpcid=cls.vpc.id
        )

        lb_rule = LoadBalancerRule.create(
            cls.api_client,
            cls.services["lbrule"],
            ipaddressid=public_ip_3.ipaddress.id,
            accountid=cls.account.name,
            networkid=cls.network_1.id,
            vpcid=cls.vpc.id,
            domainid=cls.account.domainid
        )

        lb_rule.assign(cls.api_client, [vm_3])

        NetworkACL.create(
            cls.api_client,
            networkid=cls.network_1.id,
            services=cls.services["lbrule"],
            traffictype='Ingress'
        )

        NetworkACL.create(
            cls.api_client,
            networkid=cls.network_1.id,
            services=cls.services["http_rule"],
            traffictype='Egress'
        )
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:101,代码来源:test_vpc_routers.py


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