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


Python call.add_rule函数代码示例

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


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

示例1: test_remove_metering_label

    def test_remove_metering_label(self):
        routers = [{'_metering_labels': [
            {'id': 'c5df2fe5-c600-4a2a-b2f4-c0fb6df73c83',
             'rules': [{
                 'direction': 'ingress',
                 'excluded': False,
                 'id': '7f1a261f-2489-4ed1-870c-a62754501379',
                 'metering_label_id': 'c5df2fe5-c600-4a2a-b2f4-c0fb6df73c83',
                 'remote_ip_prefix': '10.0.0.0/24'}]
             }],
            'admin_state_up': True,
            'gw_port_id': '7d411f48-ecc7-45e0-9ece-3b5bdb54fcee',
            'id': '473ec392-1711-44e3-b008-3251ccfc5099',
            'name': 'router1',
            'status': 'ACTIVE',
            'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'}]

        self.metering.add_metering_label(None, routers)
        self.metering.remove_metering_label(None, routers)
        calls = [call.add_chain('neutron-meter-l-c5df2fe5-c60', wrap=False),
                 call.add_chain('neutron-meter-r-c5df2fe5-c60', wrap=False),
                 call.add_rule('neutron-meter-FORWARD', '-j '
                               'neutron-meter-r-c5df2fe5-c60', wrap=False),
                 call.add_rule('neutron-meter-l-c5df2fe5-c60',
                               '',
                               wrap=False),
                 call.add_rule('neutron-meter-r-c5df2fe5-c60',
                               '-i qg-7d411f48-ec -d 10.0.0.0/24'
                               ' -j neutron-meter-l-c5df2fe5-c60',
                               wrap=False, top=False),
                 call.remove_chain('neutron-meter-l-c5df2fe5-c60', wrap=False),
                 call.remove_chain('neutron-meter-r-c5df2fe5-c60', wrap=False)]

        self.v4filter_inst.assert_has_calls(calls)
开发者ID:50infivedays,项目名称:neutron,代码行数:34,代码来源:test_iptables_driver.py

示例2: test_filter_ipv4_egress_icmp

 def test_filter_ipv4_egress_icmp(self):
     rule = {'ethertype': 'IPv4',
             'direction': 'egress',
             'protocol': 'icmp'}
     egress = call.add_rule('ofake_dev', '-p icmp -j RETURN')
     ingress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhirajbutala,项目名称:neutron,代码行数:7,代码来源:test_iptables_firewall.py

示例3: test_filter_ipv4_ingress_udp

 def test_filter_ipv4_ingress_udp(self):
     rule = {'ethertype': 'IPv4',
             'direction': 'ingress',
             'protocol': 'udp'}
     ingress = call.add_rule('ifake_dev', '-p udp -m udp -j RETURN')
     egress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhirajbutala,项目名称:neutron,代码行数:7,代码来源:test_iptables_firewall.py

示例4: test_filter_ipv6_egress_udp

 def test_filter_ipv6_egress_udp(self):
     rule = {'ethertype': 'IPv6',
             'direction': 'egress',
             'protocol': 'udp'}
     egress = call.add_rule('ofake_dev', '-j RETURN -p udp')
     ingress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhiraut,项目名称:quantum,代码行数:7,代码来源:test_iptables_firewall.py

示例5: test_filter_ipv6_ingress_icmp

 def test_filter_ipv6_ingress_icmp(self):
     rule = {'ethertype': 'IPv6',
             'direction': 'ingress',
             'protocol': 'icmp'}
     ingress = call.add_rule('ifake_dev', '-j RETURN -p icmpv6')
     egress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhiraut,项目名称:quantum,代码行数:7,代码来源:test_iptables_firewall.py

示例6: test_filter_ipv4_ingress_prefix

 def test_filter_ipv4_ingress_prefix(self):
     prefix = FAKE_PREFIX['IPv4']
     rule = {'ethertype': 'IPv4',
             'direction': 'ingress',
             'source_ip_prefix': prefix}
     ingress = call.add_rule('ifake_dev', '-s %s -j RETURN' % prefix)
     egress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhirajbutala,项目名称:neutron,代码行数:8,代码来源:test_iptables_firewall.py

示例7: test_filter_ipv6_egress_prefix

 def test_filter_ipv6_egress_prefix(self):
     prefix = FAKE_PREFIX['IPv6']
     rule = {'ethertype': 'IPv6',
             'direction': 'egress',
             'source_ip_prefix': prefix}
     egress = call.add_rule('ofake_dev', '-j RETURN -s %s' % prefix)
     ingress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhiraut,项目名称:quantum,代码行数:8,代码来源:test_iptables_firewall.py

示例8: test_create_firewall_no_rules

    def test_create_firewall_no_rules(self):
        apply_list = self._fake_apply_list()
        firewall = self._fake_firewall_no_rule()
        self.firewall.create_firewall(apply_list, firewall)
        invalid_rule = '-m state --state INVALID -j DROP'
        est_rule = '-m state --state ESTABLISHED,RELATED -j ACCEPT'
        bname = fwaas.iptables_manager.binary_name

        for ip_version in (4, 6):
            ingress_chain = ('iv%s%s' % (ip_version, firewall['id']))
            egress_chain = ('ov%s%s' % (ip_version, firewall['id']))
            calls = [call.ensure_remove_chain('iv%sfake-fw-uuid' % ip_version),
                     call.ensure_remove_chain('ov%sfake-fw-uuid' % ip_version),
                     call.ensure_remove_chain('fwaas-default-policy'),
                     call.add_chain('fwaas-default-policy'),
                     call.add_rule('fwaas-default-policy', '-j DROP'),
                     call.add_chain(ingress_chain),
                     call.add_rule(ingress_chain, invalid_rule),
                     call.add_rule(ingress_chain, est_rule),
                     call.add_chain(egress_chain),
                     call.add_rule(egress_chain, invalid_rule),
                     call.add_rule(egress_chain, est_rule),
                     call.add_rule('FORWARD',
                                   '-o qr-+ -j %s-fwaas-defau' % bname),
                     call.add_rule('FORWARD',
                                   '-i qr-+ -j %s-fwaas-defau' % bname)]
            if ip_version == 4:
                v4filter_inst = apply_list[0].iptables_manager.ipv4['filter']
                v4filter_inst.assert_has_calls(calls)
            else:
                v6filter_inst = apply_list[0].iptables_manager.ipv6['filter']
                v6filter_inst.assert_has_calls(calls)
开发者ID:50infivedays,项目名称:neutron,代码行数:32,代码来源:test_iptables_fwaas.py

示例9: test_filter_ipv6_ingress_udp_prefix

 def test_filter_ipv6_ingress_udp_prefix(self):
     prefix = FAKE_PREFIX['IPv6']
     rule = {'ethertype': 'IPv6',
             'direction': 'ingress',
             'protocol': 'udp',
             'source_ip_prefix': prefix}
     ingress = call.add_rule('ifake_dev', '-j RETURN -p udp -s %s' % prefix)
     egress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhiraut,项目名称:quantum,代码行数:9,代码来源:test_iptables_firewall.py

示例10: test_filter_ipv4_ingress_udp_port

 def test_filter_ipv4_ingress_udp_port(self):
     rule = {'ethertype': 'IPv4',
             'direction': 'ingress',
             'protocol': 'udp',
             'port_range_min': 10,
             'port_range_max': 10}
     ingress = call.add_rule('ifake_dev', '-j RETURN -p udp --dport 10')
     egress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhiraut,项目名称:quantum,代码行数:9,代码来源:test_iptables_firewall.py

示例11: test_filter_ipv6_egress_tcp_port

 def test_filter_ipv6_egress_tcp_port(self):
     rule = {'ethertype': 'IPv6',
             'direction': 'egress',
             'protocol': 'tcp',
             'port_range_min': 10,
             'port_range_max': 10}
     egress = call.add_rule('ofake_dev', '-j RETURN -p tcp --dport 10')
     ingress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhiraut,项目名称:quantum,代码行数:9,代码来源:test_iptables_firewall.py

示例12: test_filter_ipv4_egress_udp_prefix

 def test_filter_ipv4_egress_udp_prefix(self):
     prefix = FAKE_PREFIX['IPv4']
     rule = {'ethertype': 'IPv4',
             'direction': 'egress',
             'protocol': 'udp',
             'source_ip_prefix': prefix}
     egress = call.add_rule('ofake_dev',
                            '-s %s -p udp -m udp -j RETURN' % prefix)
     ingress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhirajbutala,项目名称:neutron,代码行数:10,代码来源:test_iptables_firewall.py

示例13: test_filter_ipv4_ingress_udp_port

 def test_filter_ipv4_ingress_udp_port(self):
     rule = {
         "ethertype": "IPv4",
         "direction": "ingress",
         "protocol": "udp",
         "port_range_min": 10,
         "port_range_max": 10,
     }
     ingress = call.add_rule("ifake_dev", "-j RETURN -p udp --dport 10")
     egress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:vglafirov,项目名称:quantum,代码行数:11,代码来源:test_iptables_firewall.py

示例14: test_filter_ipv6_egress_udp_mport

 def test_filter_ipv6_egress_udp_mport(self):
     rule = {'ethertype': 'IPv6',
             'direction': 'egress',
             'protocol': 'udp',
             'port_range_min': 10,
             'port_range_max': 100}
     egress = call.add_rule(
         'ofake_dev',
         '-j RETURN -p udp -m multiport --dports 10:100')
     ingress = None
     self._test_prepare_port_filter(rule, ingress, egress)
开发者ID:abhiraut,项目名称:quantum,代码行数:11,代码来源:test_iptables_firewall.py

示例15: test_create_firewall_with_admin_down

 def test_create_firewall_with_admin_down(self):
     rule_list = self._fake_rules_v4(FAKE_FW_ID)
     apply_list = self._fake_apply_list()
     firewall = self._fake_firewall_with_admin_down(rule_list)
     self.firewall.create_firewall(apply_list, firewall)
     calls = [call.ensure_remove_chain('iv4fake-fw-uuid'),
              call.ensure_remove_chain('ov4fake-fw-uuid'),
              call.ensure_remove_chain('fwaas-default-policy'),
              call.add_chain('fwaas-default-policy'),
              call.add_rule('fwaas-default-policy', '-j DROP')]
     self.v4filter_inst.assert_has_calls(calls)
开发者ID:CampHarmony,项目名称:neutron,代码行数:11,代码来源:test_iptables_fwaas.py


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