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


Python DMUtils.l3_lo_intf_comment方法代码示例

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


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

示例1: add_routing_instance

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

#.........这里部分代码省略.........
        term.set_then(Then(accept=''))

        from_ = From()
        term = Term(name="t1", fromxx=from_)
        ps.add_term(term)
        for route_target in import_targets:
            from_.add_community(DMUtils.make_community_name(route_target))
            if not self.is_spine():
                self.add_vni_option(vni or network_id, route_target)
        term.set_then(Then(accept=''))
        policy_config.add_policy_statement(ps)
        self.add_to_global_switch_opts(DMUtils.make_import_name(ri_name), True)

        # add L2 EVPN and BD config
        interfaces_config = self.interfaces_config
        if (is_l2 and vni is not None and
                self.is_family_configured(self.bgp_params, "e-vpn")):
            # add vlan config
            vlan_conf = self.add_vlan_config(ri_name, vni)
            interfaces_config = self.interfaces_config or Interfaces(comment=DMUtils.interfaces_comment())
            if is_l2_l3 and self.is_spine():
                irb_intf = Interface(name='irb', gratuitous_arp_reply='')
                interfaces_config.add_interface(irb_intf)
                if gateways is not None:
                    intf_unit = Unit(name=str(network_id),
                                     comment=DMUtils.vn_irb_comment(vn, False, is_l2_l3))
                    irb_intf.add_unit(intf_unit)
                    if self.is_spine():
                        intf_unit.set_proxy_macip_advertisement('')
                    family = Family()
                    intf_unit.set_family(family)
                    inet = None
                    inet6 = None
                    for (irb_ip, gateway) in gateways:
                        if ':' in irb_ip:
                            if not inet6:
                                inet6 = FamilyInet6()
                                family.set_inet6(inet6)
                            addr = Address()
                            inet6.add_address(addr)
                        else:
                            if not inet:
                                inet = FamilyInet()
                                family.set_inet(inet)
                            addr = Address()
                            inet.add_address(addr)
                        addr.set_name(irb_ip)
                        addr.set_comment(DMUtils.irb_ip_comment(irb_ip))
                        if len(gateway) and gateway != '0.0.0.0':
                            addr.set_virtual_gateway_address(gateway)
            self.build_l2_evpn_interface_config(interfaces_config,
                                              interfaces, vn, vlan_conf)

        if (not is_l2 and vni is not None and
                self.is_family_configured(self.bgp_params, "e-vpn")):
            ri.set_vtep_source_interface("lo0.0")
            evpn = self.build_evpn_config()
            if evpn:
                ri.set_protocols(RoutingInstanceProtocols(evpn=evpn))
            #add vlans
            self.add_ri_vlan_config(ri, vni)

        if (not is_l2 and not is_l2_l3 and gateways):
            interfaces_config = self.interfaces_config or \
                               Interfaces(comment=DMUtils.interfaces_comment())
            ifl_num = str(1000 + int(network_id))
            lo_intf = Interface(name="lo0")
            interfaces_config.add_interface(lo_intf)
            intf_unit = Unit(name=ifl_num, comment=DMUtils.l3_lo_intf_comment(vn))
            lo_intf.add_unit(intf_unit)
            family = Family()
            intf_unit.set_family(family)
            inet = None
            inet6 = None
            for (lo_ip, _) in gateways:
                subnet = lo_ip
                (ip, _) = lo_ip.split('/')
                if ':' in lo_ip:
                    if not inet6:
                        inet6 = FamilyInet6()
                        family.set_inet6(inet6)
                    addr = Address()
                    inet6.add_address(addr)
                    lo_ip = ip + '/' + '128'
                else:
                    if not inet:
                        inet = FamilyInet()
                        family.set_inet(inet)
                    addr = Address()
                    inet.add_address(addr)
                    lo_ip = ip + '/' + '32'
                addr.set_name(lo_ip)
                addr.set_comment(DMUtils.lo0_ip_comment(subnet))
            ri.add_interface(Interface(name="lo0." + ifl_num,
                                       comment=DMUtils.lo0_ri_intf_comment(vn)))

        self.policy_config = policy_config
        self.interfaces_config = interfaces_config
        self.route_targets |= import_targets | export_targets
        self.ri_config = ri_config
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:104,代码来源:qfx_conf.py

示例2: add_routing_instance

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

#.........这里部分代码省略.........
                if gateways is not None:
                    intf_unit = Unit(name=str(network_id),
                                     comment=DMUtils.vn_irb_comment(vn, False, is_l2_l3))
                    irb_intf.add_unit(intf_unit)
                    family = Family()
                    intf_unit.set_family(family)
                    inet = None
                    inet6 = None
                    for (irb_ip, gateway) in gateways:
                        if ':' in irb_ip:
                            if not inet6:
                                inet6 = FamilyInet6()
                                family.set_inet6(inet6)
                            addr = Address()
                            inet6.add_address(addr)
                        else:
                            if not inet:
                                inet = FamilyInet()
                                family.set_inet(inet)
                            addr = Address()
                            inet.add_address(addr)
                        addr.set_name(irb_ip)
                        addr.set_comment(DMUtils.irb_ip_comment(irb_ip))
                        if len(gateway) and gateway != '0.0.0.0':
                            addr.set_virtual_gateway_address(gateway)

            self.build_l2_evpn_interface_config(interfaces_config, interfaces, vn)

        if (not is_l2 and not is_l2_l3 and gateways):
            interfaces_config = self.interfaces_config or Interfaces(comment=DMUtils.interfaces_comment())
            ifl_num = str(1000 + int(network_id))
            lo_intf = Interface(name="lo0")
            interfaces_config.add_interface(lo_intf)
            intf_unit = Unit(name=ifl_num, comment=DMUtils.l3_lo_intf_comment(vn))
            lo_intf.add_unit(intf_unit)
            family = Family()
            intf_unit.set_family(family)
            inet = None
            inet6 = None
            for (lo_ip, _) in gateways:
                subnet = lo_ip
                (ip, _) = lo_ip.split('/')
                if ':' in lo_ip:
                    if not inet6:
                        inet6 = FamilyInet6()
                        family.set_inet6(inet6)
                    addr = Address()
                    inet6.add_address(addr)
                    lo_ip = ip + '/' + '128'
                else:
                    if not inet:
                        inet = FamilyInet()
                        family.set_inet(inet)
                    addr = Address()
                    inet.add_address(addr)
                    lo_ip = ip + '/' + '32'
                addr.set_name(lo_ip)
                addr.set_comment(DMUtils.lo0_ip_comment(subnet))
            ri.add_interface(Interface(name="lo0." + ifl_num,
                                       comment=DMUtils.lo0_ri_intf_comment(vn)))

        # fip services config
        services_config = self.services_config
        if fip_map is not None:
            services_config = self.services_config or Services()
            services_config.set_comment(DMUtils.services_comment())
开发者ID:Juniper,项目名称:contrail-controller,代码行数:70,代码来源:mx_conf.py

示例3: add_routing_instance

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

#.........这里部分代码省略.........
            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)
                vlan.set_comment(DMUtils.vn_bd_comment(vn, "VXLAN"))
                self.vlan_map[vlan.get_name()] = vlan
                for interface in interfaces:
                    self.add_ref_to_list(vlan.get_interfaces(), interface.name)
                if is_l2_l3:
                    # network_id is unique, hence irb
                    irb_intf = "irb." + str(network_id)
                    self.add_ref_to_list(vlan.get_interfaces(), irb_intf)
            elif (any(x in encapsulation_priorities for x in ["MPLSoGRE", "MPLSoUDP"])):
                self.init_evpn_config(encapsulation_priorities[1])
                self.evpn.set_comment(
                      DMUtils.vn_evpn_comment(vn, encapsulation_priorities[1]))
                for interface in interfaces:
                    self.add_ref_to_list(self.evpn.get_interfaces(), interface.name)

            self.build_l2_evpn_interface_config(interfaces, vn, vlan)

        if (not is_l2 and vni is not None and
                self.is_family_configured(self.bgp_params, "e-vpn")):
            self.init_evpn_config()
            if not is_internal_vn and not is_dci_vn:
                # add vlans
                self.add_ri_vlan_config(ri_name, vni)

        if (not is_l2 and not is_l2_l3 and gateways):
            ifl_num = 1000 + int(network_id)
            lo_intf, li_map = self.set_default_pi('lo0', 'loopback')
            intf_name = 'lo0.' + str(ifl_num)
            intf_unit = self.set_default_li(li_map, intf_name, ifl_num)
            intf_unit.set_comment(DMUtils.l3_lo_intf_comment(vn))
            for (lo_ip, _) in gateways:
                subnet = lo_ip
                (ip, _) = lo_ip.split('/')
                if ':' in lo_ip:
                    lo_ip = ip + '/' + '128'
                else:
                    lo_ip = ip + '/' + '32'
                self.add_ip_address(intf_unit, lo_ip)
            self.add_ref_to_list(ri.get_loopback_interfaces(), intf_name)

        # fip services config
        if fip_map is not None:
            nat_rules = NatRules(allow_overlapping_nat_pools=True,
                                 name=DMUtils.make_services_set_name(ri_name),
                                 comment=DMUtils.service_set_comment(vn))
            ri.set_nat_rules(nat_rules)
            snat_rule = NatRule(
                name=DMUtils.make_snat_rule_name(ri_name),
                comment=DMUtils.service_set_nat_rule_comment(vn, "SNAT"),
                direction="input", translation_type="basic-nat44")
            snat_rule.set_comment(DMUtils.snat_rule_comment())
            nat_rules.add_rules(snat_rule)
            dnat_rule = NatRule(
                name=DMUtils.make_dnat_rule_name(ri_name),
                comment=DMUtils.service_set_nat_rule_comment(vn, "DNAT"),
                direction="output", translation_type="dnat-44")
            dnat_rule.set_comment(DMUtils.dnat_rule_comment())
            nat_rules.add_rules(dnat_rule)
            nat_rules.set_inside_interface(interfaces[0].name)
            nat_rules.set_outside_interface(interfaces[1].name)

            for pip, fip_vn in fip_map.items():
                fip = fip_vn["floating_ip"]
                # private ip
                snat_rule.add_source_addresses(self.get_subnet_for_cidr(pip))
                # public ip
                snat_rule.add_source_prefixes(self.get_subnet_for_cidr(fip))

                # public ip
                dnat_rule.add_destination_addresses(
                    self.get_subnet_for_cidr(fip))
                # private ip
                dnat_rule.add_destination_prefixes(
                    self.get_subnet_for_cidr(pip))

            self.add_ref_to_list(ri.get_ingress_interfaces(), interfaces[0].name)
            self.add_ref_to_list(ri.get_egress_interfaces(), interfaces[1].name)

        for target in import_targets:
            self.add_to_list(ri.get_import_targets(), target)

        for target in export_targets:
            self.add_to_list(ri.get_export_targets(), target)
开发者ID:rombie,项目名称:contrail-controller,代码行数:104,代码来源:ansible_role_common.py


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