本文整理汇总了Python中dm_utils.DMUtils.vn_irb_comment方法的典型用法代码示例。如果您正苦于以下问题:Python DMUtils.vn_irb_comment方法的具体用法?Python DMUtils.vn_irb_comment怎么用?Python DMUtils.vn_irb_comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dm_utils.DMUtils
的用法示例。
在下文中一共展示了DMUtils.vn_irb_comment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_irb_config
# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import vn_irb_comment [as 别名]
def add_irb_config(self, ri_conf):
vn = ri_conf.get("vn")
is_l2_l3 = ri_conf.get("is_l2_l3", False)
gateways = ri_conf.get("gateways", [])
network_id = ri_conf.get("network_id", None)
irb_intf, li_map = self.set_default_pi('irb', 'irb')
self._logger.info("Vn=" + vn.name + ", IRB: " + str(gateways) + ", pr="
+ self.physical_router.name)
if gateways is not None:
intf_unit = self.set_default_li(li_map,
'irb.' + str(network_id),
network_id)
intf_unit.set_comment(DMUtils.vn_irb_comment(vn, False, is_l2_l3))
for (irb_ip, gateway) in gateways:
if len(gateway) and gateway != '0.0.0.0':
intf_unit.set_gateway(gateway)
self.add_ip_address(intf_unit, irb_ip, gateway=gateway)
else:
self.add_ip_address(intf_unit, irb_ip)
示例2: add_irb_config
# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import vn_irb_comment [as 别名]
def add_irb_config(self, ri_conf):
vn = ri_conf.get("vn")
is_l2 = ri_conf.get("is_l2", False)
is_l2_l3 = ri_conf.get("is_l2_l3", False)
gateways = ri_conf.get("gateways", [])
vni = ri_conf.get("vni", None)
network_id = ri_conf.get("network_id", None)
interfaces_config = self.interfaces_config or \
Interfaces(comment=DMUtils.interfaces_comment())
self.interfaces_config = interfaces_config
irb_intf = Interface(name='irb', gratuitous_arp_reply='')
interfaces_config.add_interface(irb_intf)
self._logger.info("Vn=" + vn.name + ", IRB: " + str(gateways) + ", pr=" + self.physical_router.name)
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)
示例3: add_routing_instance
# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import vn_irb_comment [as 别名]
#.........这里部分代码省略.........
if (is_l2 and vni is not None and
self.is_family_configured(self.bgp_params, "e-vpn")):
ri.set_vtep_source_interface("lo0.0")
if highest_enapsulation_priority == "VXLAN":
bd_config = BridgeDomains()
ri.set_bridge_domains(bd_config)
bd = Domain(name=DMUtils.make_bridge_name(vni), vlan_id='none', vxlan=VXLan(vni=vni))
bd.set_comment(DMUtils.vn_bd_comment(vn, "VXLAN"))
bd_config.add_domain(bd)
for interface in interfaces:
bd.add_interface(Interface(name=interface.name))
if is_l2_l3:
# network_id is unique, hence irb
bd.set_routing_interface("irb." + str(network_id))
ri.set_protocols(RoutingInstanceProtocols(
evpn=Evpn(encapsulation='vxlan', extended_vni_list='all')))
elif highest_enapsulation_priority in ["MPLSoGRE", "MPLSoUDP"]:
ri.set_vlan_id('none')
if is_l2_l3:
# network_id is unique, hence irb
ri.set_routing_interface("irb." + str(network_id))
evpn = Evpn()
evpn.set_comment(DMUtils.vn_evpn_comment(vn, highest_enapsulation_priority))
for interface in interfaces:
evpn.add_interface(Interface(name=interface.name))
ri.set_protocols(RoutingInstanceProtocols(evpn=evpn))
interfaces_config = self.interfaces_config or Interfaces(comment=DMUtils.interfaces_comment())
if is_l2_l3:
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)
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)
示例4: add_routing_instance
# 需要导入模块: from dm_utils import DMUtils [as 别名]
# 或者: from dm_utils.DMUtils import vn_irb_comment [as 别名]
def add_routing_instance(self, ri_conf):
ri_name = ri_conf.get("ri_name")
vn = ri_conf.get("vn")
is_l2 = ri_conf.get("is_l2", False)
is_l2_l3 = ri_conf.get("is_l2_l3", False)
import_targets = ri_conf.get("import_targets", set())
export_targets = ri_conf.get("export_targets", set())
prefixes = ri_conf.get("prefixes", [])
gateways = ri_conf.get("gateways", [])
interfaces = ri_conf.get("interfaces", [])
vni = ri_conf.get("vni", None)
network_id = ri_conf.get("network_id", None)
self.routing_instances[ri_name] = ri_conf
ri_config = None
policy_config = self.policy_config or \
PolicyOptions(comment=DMUtils.policy_options_comment())
ri = None
ri_opt = None
if not is_l2:
ri_config = self.ri_config or \
RoutingInstances(comment=DMUtils.routing_instances_comment())
ri = Instance(name=ri_name)
ri_config.add_instance(ri)
ri.set_vrf_import(DMUtils.make_import_name(ri_name))
ri.set_vrf_export(DMUtils.make_export_name(ri_name))
has_ipv6_prefixes = DMUtils.has_ipv6_prefixes(prefixes)
has_ipv4_prefixes = DMUtils.has_ipv4_prefixes(prefixes)
if not is_l2:
if ri_opt is None:
ri_opt = RoutingInstanceRoutingOptions()
ri.set_routing_options(ri_opt)
ri.set_instance_type("vrf")
for interface in interfaces:
ri.add_interface(Interface(name=interface.name))
family = Family()
if has_ipv4_prefixes:
family.set_inet(FamilyInet(unicast=''))
if has_ipv6_prefixes:
family.set_inet6(FamilyInet6(unicast=''))
if has_ipv4_prefixes or has_ipv6_prefixes:
auto_export = AutoExport(family=family)
ri_opt.set_auto_export(auto_export)
# add policies for export route targets
if self.is_spine():
ps = PolicyStatement(name=DMUtils.make_export_name(ri_name))
ps.set_comment(DMUtils.vn_ps_comment(vn, "Export"))
then = Then()
ps.add_term(Term(name="t1", then=then))
for route_target in export_targets:
comm = Community(add='',
community_name=DMUtils.make_community_name(route_target))
then.add_community(comm)
then.set_accept('')
policy_config.add_policy_statement(ps)
self.add_to_global_switch_opts(DMUtils.make_export_name(ri_name), False)
# add policies for import route targets
ps = PolicyStatement(name=DMUtils.make_import_name(ri_name))
ps.set_comment(DMUtils.vn_ps_comment(vn, "Import"))
# add term switch policy
from_ = From()
term = Term(name=DMUtils.get_switch_policy_name(), fromxx=from_)
ps.add_term(term)
from_.add_community(DMUtils.get_switch_policy_name())
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()
#.........这里部分代码省略.........