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


Python Gateway.get_nat_rules方法代码示例

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


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

示例1: test_0030_update_nat_rule

# 需要导入模块: from pyvcloud.vcd.gateway import Gateway [as 别名]
# 或者: from pyvcloud.vcd.gateway.Gateway import get_nat_rules [as 别名]
    def test_0030_update_nat_rule(self):
        """Update a Nat Rule.

        Invokes the update_nat_rule of the NatRule.
        """
        gateway = Environment. \
            get_test_gateway(TestNatRule._client)
        gateway_obj = Gateway(TestNatRule._client,
                              TestNatRule._name,
                              href=gateway.get('href'))
        nat_rule = gateway_obj.get_nat_rules()
        rule_id = self.__get_snat_rule_id(nat_rule)
        nat_obj = NatRule(TestNatRule._client, self._name, rule_id)
        nat_obj.update_nat_rule(
            original_address=TestNatRule._new_snat_orig_addr,
            translated_address=TestNatRule._new_snat_trans_addr,
            description=TestNatRule._new_snat_desc)
        #Verify
        nat_rule = gateway_obj.get_nat_rules()
        match_found = False
        for natRule in nat_rule.natRules.natRule:
            if natRule.originalAddress == TestNatRule._new_snat_orig_addr and \
                natRule.translatedAddress == TestNatRule._new_snat_trans_addr and \
                natRule.description == TestNatRule._new_snat_desc:
                match_found = True
        self.assertTrue(match_found)
开发者ID:vmware,项目名称:pyvcloud,代码行数:28,代码来源:nat_rule_tests.py

示例2: test_0025_reorder_nat_rule

# 需要导入模块: from pyvcloud.vcd.gateway import Gateway [as 别名]
# 或者: from pyvcloud.vcd.gateway.Gateway import get_nat_rules [as 别名]
    def test_0025_reorder_nat_rule(self):
        """Reorder the nat rule position on gateway.

        Invokes the reorder_nat_rule of the Gateway.
        """
        gateway = Environment. \
            get_test_gateway(TestNatRule._client)
        gateway_obj = Gateway(TestNatRule._client,
                              TestNatRule._name,
                              href=gateway.get('href'))
        nat_rule = gateway_obj.get_nat_rules()
        rule_id = self.__get_snat_rule_id(nat_rule)
        index1 = self.__get_snat_rule_index(nat_rule)
        new_index = 2
        gateway_obj.reorder_nat_rule(rule_id, new_index)
        nat_rule = gateway_obj.get_nat_rules()
        index2 = self.__get_snat_rule_index(nat_rule)
        self.assertNotEqual(index1, index2)
开发者ID:vmware,项目名称:pyvcloud,代码行数:20,代码来源:nat_rule_tests.py

示例3: test_0090_delete_nat_rule

# 需要导入模块: from pyvcloud.vcd.gateway import Gateway [as 别名]
# 或者: from pyvcloud.vcd.gateway.Gateway import get_nat_rules [as 别名]
    def test_0090_delete_nat_rule(self):
        """Delete Nat Rule in the gateway.

        Invokes the delete_nat_rule of the NatRule.
        """
        gateway = Environment. \
            get_test_gateway(TestNatRule._client)
        gateway_obj = Gateway(TestNatRule._client,
                              TestNatRule._name,
                              href=gateway.get('href'))
        nat_rule = gateway_obj.get_nat_rules()

        nat_objects = []
        for natRule in nat_rule.natRules.natRule:
            nat_objects.append(
                NatRule(TestNatRule._client, self._name, natRule.ruleId))

        for nat_object in nat_objects:
            nat_object.delete_nat_rule()
        #Verify
        nat_rule = gateway_obj.get_nat_rules()
        self.assertFalse(hasattr(nat_rule.natRules, 'natRule'))
开发者ID:vmware,项目名称:pyvcloud,代码行数:24,代码来源:nat_rule_tests.py

示例4: test_0015_get_nat_rule_info

# 需要导入模块: from pyvcloud.vcd.gateway import Gateway [as 别名]
# 或者: from pyvcloud.vcd.gateway.Gateway import get_nat_rules [as 别名]
    def test_0015_get_nat_rule_info(self):
        """Get the details of nat rule.

        Invokes the get_nat_rule_info of the NatRule.
        """
        gateway = Environment. \
            get_test_gateway(TestNatRule._client)
        gateway_obj = Gateway(TestNatRule._client,
                              TestNatRule._name,
                              href=gateway.get('href'))
        nat_rule = gateway_obj.get_nat_rules()
        rule_id = self.__get_snat_rule_id(nat_rule)
        nat_obj = NatRule(TestNatRule._client, self._name, rule_id)
        nat_rule_info =  nat_obj.get_nat_rule_info()
        #Verify
        self.assertTrue(len(nat_rule_info) > 0)
        self.assertEqual(nat_rule_info['Action'], TestNatRule._snat_action)
        self.assertEqual(nat_rule_info['OriginalAddress'],
                         TestNatRule._snat_orig_addr)
开发者ID:vmware,项目名称:pyvcloud,代码行数:21,代码来源:nat_rule_tests.py

示例5: test_0010_add_nat_rule

# 需要导入模块: from pyvcloud.vcd.gateway import Gateway [as 别名]
# 或者: from pyvcloud.vcd.gateway.Gateway import get_nat_rules [as 别名]
    def test_0010_add_nat_rule(self):
        """Add Nat Rule in the gateway.

        Invokes the add_nat_rule of the gateway.
        """
        gateway = Environment. \
            get_test_gateway(TestNatRule._client)
        gateway_obj = Gateway(TestNatRule._client,
                              TestNatRule._name,
                              href=gateway.get('href'))
        # Create SNAT Rule
        gateway_obj.add_nat_rule(
            action=TestNatRule._snat_action,
            original_address=TestNatRule._snat_orig_addr,
            translated_address=TestNatRule._snat_trans_addr)
        # Create DNAT Rule for tcp/udp protocol
        gateway_obj.add_nat_rule(
            action=TestNatRule._dnat_action,
            original_address=TestNatRule._dnat1_orig_addr,
            translated_address=TestNatRule._dnat1_trans_addr,
            protocol=TestNatRule._dnat1_protocol,
            original_port=TestNatRule._dnat1_orig_port,
            translated_port=TestNatRule._dnat1_trans_port)
        # Create DNAT Rule for icmp protocol
        gateway_obj.add_nat_rule(
            action=TestNatRule._dnat_action,
            original_address=TestNatRule._dnat2_orig_addr,
            translated_address=TestNatRule._dnat2_trans_addr,
            description=TestNatRule._dnat2_protocol,
            protocol=TestNatRule._dnat2_protocol)
        nat_rule = gateway_obj.get_nat_rules()
        #Verify
        snat_found = False
        dnat_found = False
        for natRule in nat_rule.natRules.natRule:
            if natRule.action == 'snat' and \
                natRule.originalAddress == TestNatRule._snat_orig_addr :
                snat_found = True
            if natRule.action == 'dnat' and \
                natRule.originalAddress == TestNatRule._dnat1_orig_addr :
                dnat_found = True
        self.assertTrue(snat_found)
        self.assertTrue(dnat_found)
开发者ID:vmware,项目名称:pyvcloud,代码行数:45,代码来源:nat_rule_tests.py


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