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


Python DMUtils.make_private_vrf_filter_name方法代码示例

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


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

示例1: add_inet_vrf_filter

# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import make_private_vrf_filter_name [as 别名]
 def add_inet_vrf_filter(self, firewall_config, vrf_name):
     firewall_config.set_family("inet")
     f = FirewallFilter(name=DMUtils.make_private_vrf_filter_name(vrf_name))
     f.set_comment(DMUtils.vrf_filter_comment(vrf_name))
     firewall_config.add_firewall_filters(f)
     term = Term(name="default-term", then=Then(accept_or_reject=True))
     f.add_terms(term)
     return f
开发者ID:rombie,项目名称:contrail-controller,代码行数:10,代码来源:ansible_role_common.py

示例2: add_routing_instance

# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import make_private_vrf_filter_name [as 别名]

#.........这里部分代码省略.........
        # add firewall config for public VRF
        forwarding_options_config = self.forwarding_options_config
        firewall_config = self.firewall_config
        if router_external and is_l2 == False:
            forwarding_options_config = self.forwarding_options_config or ForwardingOptions()
            firewall_config = self.firewall_config or Firewall()
            if has_ipv4_prefixes and not self.inet4_forwarding_filter:
                # create single instance inet4 filter
                self.inet4_forwarding_filter = self.add_inet_public_vrf_filter(
                    forwarding_options_config, firewall_config, "inet"
                )
            if has_ipv6_prefixes and not self.inet6_forwarding_filter:
                # create single instance inet6 filter
                self.inet6_forwarding_filter = self.add_inet_public_vrf_filter(
                    forwarding_options_config, firewall_config, "inet6"
                )
            if has_ipv4_prefixes:
                # add terms to inet4 filter
                term = self.add_inet_filter_term(ri_name, prefixes, "inet4")
                # insert before the last term
                terms = self.inet4_forwarding_filter.get_term()
                terms = [term] + (terms or [])
                self.inet4_forwarding_filter.set_term(terms)
            if has_ipv6_prefixes:
                # add terms to inet6 filter
                term = self.add_inet_filter_term(ri_name, prefixes, "inet6")
                # insert before the last term
                terms = self.inet6_forwarding_filter.get_term()
                terms = [term] + (terms or [])
                self.inet6_forwarding_filter.set_term(terms)

        if fip_map is not None:
            firewall_config = firewall_config or Firewall()
            f = FirewallFilter(name=DMUtils.make_private_vrf_filter_name(ri_name))
            ff = firewall_config.get_family()
            if not ff:
                ff = FirewallFamily()
                firewall_config.set_family(ff)
            inet = ff.get_inet()
            if not inet:
                inet = FirewallInet()
                ff.set_inet(inet)
            inet.add_filter(f)

            term = Term(name=DMUtils.make_vrf_term_name(ri_name))
            from_ = From()
            for fip_user_ip in fip_map.keys():
                from_.add_source_address(fip_user_ip)
            term.set_from(from_)
            term.set_then(Then(routing_instance=[ri_name]))
            f.add_term(term)

            term = Term(name="default-term", then=Then(accept=""))
            f.add_term(term)

            interfaces_config = self.interfaces_config or Interfaces()
            irb_intf = Interface(name="irb")
            interfaces_config.add_interface(irb_intf)

            intf_unit = Unit(name=str(network_id))
            if restrict_proxy_arp:
                intf_unit.set_proxy_arp(ProxyArp(restricted=""))
            inet = FamilyInet()
            inet.set_filter(InetFilter(input=DMUtils.make_private_vrf_filter_name(ri_name)))
            intf_unit.set_family(Family(inet=inet))
            irb_intf.add_unit(intf_unit)
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:70,代码来源:physical_router_config.py

示例3: add_routing_instance

# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import make_private_vrf_filter_name [as 别名]

#.........这里部分代码省略.........
        forwarding_options_config = self.forwarding_options_config
        firewall_config = self.firewall_config
        if router_external and is_l2 == False:
            forwarding_options_config = (self.forwarding_options_config or
                                           etree.Element("forwarding-options"))
            firewall_config = self.firewall_config or etree.Element("firewall")
            if has_ipv4_prefixes and not self.inet4_forwarding_filter:
                #create single instance inet4 filter
                self.inet4_forwarding_filter = self.add_inet_public_vrf_filter(
                                                       forwarding_options_config,
                                                       firewall_config, "inet4", "inet")
            if has_ipv6_prefixes and not self.inet6_forwarding_filter:
                #create single instance inet6 filter
                self.inet6_forwarding_filter = self.add_inet_public_vrf_filter(
                                                       forwarding_options_config,
                                                       firewall_config, "inet6", "inet6")
            if has_ipv4_prefixes:
                #add terms to inet4 filter
                term = self.add_inet_filter_term(ri_name, prefixes, "inet4")
                # insert after 'name' element but before the last term
                self.inet4_forwarding_filter.insert(1, term)
            if has_ipv6_prefixes:
                #add terms to inet6 filter
                term = self.add_inet_filter_term(ri_name, prefixes, "inet6")
                # insert after 'name' element but before the last term
                self.inet6_forwarding_filter.insert(1, term)

        if fip_map is not None:
            firewall_config = self.firewall_config or etree.Element("firewall")
            fc = etree.SubElement(firewall_config, "family")
            inet = etree.SubElement(fc, "inet")
            f = etree.SubElement(inet, "filter")
            etree.SubElement(
                f, "name").text = DMUtils.make_private_vrf_filter_name(ri_name)
            term = etree.SubElement(f, "term")
            etree.SubElement(term, "name").text = DMUtils.make_vrf_term_name(ri_name)
            from_ = etree.SubElement(term, "from")
            for fip_user_ip in fip_map.keys():
                etree.SubElement(from_, "source-address").text = fip_user_ip
            then_ = etree.SubElement(term, "then")
            etree.SubElement(then_, "routing-instance").text = ri_name
            term = etree.SubElement(f, "term")
            etree.SubElement(term, "name").text = "default-term"
            then_ = etree.SubElement(term, "then")
            etree.SubElement(then_, "accept")

            interfaces_config = self.interfaces_config or etree.Element(
                "interfaces")
            irb_intf = etree.SubElement(interfaces_config, "interface")
            etree.SubElement(irb_intf, "name").text = "irb"
            intf_unit = etree.SubElement(irb_intf, "unit")
            etree.SubElement(intf_unit, "name").text = str(network_id)
            if restrict_proxy_arp:
                proxy_arp = etree.SubElement(intf_unit, "proxy-arp")
                etree.SubElement(proxy_arp, "restricted")
            family = etree.SubElement(intf_unit, "family")
            inet = etree.SubElement(family, "inet")
            f = etree.SubElement(inet, "filter")
            iput = etree.SubElement(f, "input")
            etree.SubElement(
                iput,
                "filter-name").text = DMUtils.make_private_vrf_filter_name(ri_name)

        # add L2 EVPN and BD config
        bd_config = None
        interfaces_config = self.interfaces_config
开发者ID:tcpcloud,项目名称:contrail-controller,代码行数:70,代码来源:physical_router_config.py

示例4: add_routing_instance

# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import make_private_vrf_filter_name [as 别名]

#.........这里部分代码省略.........
                    self.firewall_config, "inet6")
            if has_ipv4_prefixes:
                # add terms to inet4 filter
                term = self.add_inet_filter_term(ri_name, prefixes, "inet4")
                # insert before the last term
                terms = self.inet4_forwarding_filter.get_terms()
                terms = [term] + (terms or [])
                self.inet4_forwarding_filter.set_terms(terms)
            if has_ipv6_prefixes:
                # add terms to inet6 filter
                term = self.add_inet_filter_term(ri_name, prefixes, "inet6")
                # insert before the last term
                terms = self.inet6_forwarding_filter.get_terms()
                terms = [term] + (terms or [])
                self.inet6_forwarding_filter.set_terms(terms)

        # add firewall config for DCI Network
        if is_dci:
            self.firewall_config = self.firewall_config or Firewall(
                comment=DMUtils.firewall_comment())
            self.dci_forwarding_filter[vn.uuid] = self.add_inet_vrf_filter(
                    self.firewall_config, ri_name)
            # add terms to inet4 filter
            term = self.add_inet_filter_term(ri_name, prefixes, "inet4")
            # insert before the last term
            terms = self.dci_forwarding_filter[vn.uuid].get_terms()
            terms = [term] + (terms or [])
            self.dci_forwarding_filter[vn.uuid].set_terms(terms)

        if fip_map is not None:
            self.firewall_config = self.firewall_config or Firewall(
                comment=DMUtils.firewall_comment())
            f = FirewallFilter(
                name=DMUtils.make_private_vrf_filter_name(ri_name))
            f.set_comment(DMUtils.vn_firewall_comment(vn, "private"))
            self.firewall_config.add_firewall_filters(f)

            term = Term(name=DMUtils.make_vrf_term_name(ri_name))
            from_ = From()
            for fip_user_ip in fip_map.keys():
                from_.add_source_address(self.get_subnet_for_cidr(fip_user_ip))
            term.set_from(from_)
            term.set_then(Then(routing_instance=[ri_name]))
            f.add_terms(term)

            irb_intf, li_map = self.set_default_pi('irb', 'irb')
            intf_name = 'irb.' + str(network_id)
            intf_unit = self.set_default_li(li_map, intf_name, network_id)
            intf_unit.set_comment(DMUtils.vn_irb_fip_inet_comment(vn))
            intf_unit.set_family("inet")
            intf_unit.add_firewall_filters(
                DMUtils.make_private_vrf_filter_name(ri_name))
            self.add_ref_to_list(ri.get_routing_interfaces(), intf_name)

        if gateways is not None:
            for (ip, gateway) in gateways:
                ri.add_gateways(GatewayRoute(
                    ip_address=self.get_subnet_for_cidr(ip),
                    gateway=self.get_subnet_for_cidr(gateway)))

        # add L2 EVPN and BD config
        if (is_l2 and vni is not None and
                self.is_family_configured(self.bgp_params, "e-vpn")):
            vlan = None
            if encapsulation_priorities[0] == "VXLAN":
                vlan = Vlan(name=DMUtils.make_bridge_name(vni), vxlan_id=vni)
开发者ID:rombie,项目名称:contrail-controller,代码行数:70,代码来源:ansible_role_common.py


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