|
1 | | -{% import "templates/routing/_redistribute.cumulus_nvue.j2" as redistribute with context %} |
2 | | -{% macro advertise_communities(comms) %} |
3 | | - community-advertise: |
4 | | -{% for c in ['standard', 'extended', 'large'] %} |
5 | | - {{ c.replace("standard","regular") }}: {{ 'on' if c in comms else 'off' }} |
6 | | -{% endfor %} |
7 | | -{% endmacro %} |
8 | | - |
9 | | -- set: |
10 | | - router: |
11 | | - bgp: |
12 | | - enable: on |
13 | | - vrf: |
14 | | - default: |
15 | | - router: |
16 | | - bgp: |
17 | | -{% if bgp.rr|default(False) %} |
18 | | - route-reflection: |
19 | | - enable: on |
20 | | -{% if bgp.rr_cluster_id is defined %} |
21 | | - cluster-id: {{ bgp.rr_cluster_id }} |
22 | | -{% endif %} |
23 | | -{% endif %} |
24 | | -{% for af in ['ipv4','ipv6'] if bgp[af] is defined %} |
25 | | -{% if loop.first %} |
26 | | - address-family: |
27 | | -{% endif %} |
28 | | - {{ af }}-unicast: |
29 | | - enable: on |
30 | | -{{ redistribute.config(bgp,af=af)|indent(16,first=True) }} |
31 | | -{% set _loopback = [ loopback[af] ] if loopback[af] is defined and bgp.advertise_loopback else [] %} |
32 | | -{% set data = namespace(networks=_loopback) %} |
33 | | -{% for l in interfaces|default([]) if l.bgp.advertise|default("") and l[af] is defined and not 'vrf' in l %} |
34 | | -{% set data.networks = data.networks + [ l[af] ] %} |
35 | | -{% endfor %} |
36 | | -{% for pfx in bgp.originate|default([]) if af == 'ipv4' %} |
37 | | -{% set data.networks = data.networks + [ pfx ] %} |
38 | | -{% endfor %} |
39 | | -{% if data.networks!=[] %} |
40 | | - network: |
41 | | -{% for pfx in data.networks %} |
42 | | - {{ pfx|ipaddr('0') }}: {} |
43 | | -{% endfor %} |
44 | | -{% endif %} |
45 | | -{% endfor %} |
46 | | - autonomous-system: {{ bgp.as }} |
47 | | -{% for n in bgp.neighbors %} |
48 | | -{% if loop.first %} |
49 | | - neighbor: |
50 | | -{% endif %} |
51 | | -{% if n.local_if is defined %} |
52 | | - {{ n.local_if }}: |
53 | | - type: unnumbered |
54 | | - remote-as: {{ n.as }} |
55 | | - address-family: |
56 | | - ipv4-unicast: |
57 | | - enable: {{ 'on' if n.ipv4_rfc8950|default(False) else 'off' }} |
58 | | - community-advertise: |
59 | | - extended: on |
60 | | - ipv6-unicast: |
61 | | - enable: {{ 'on' if n.ipv6|default(False) and n.activate.ipv6|default(False) else 'off' }} |
62 | | - community-advertise: |
63 | | - extended: on |
64 | | -{% endif %} |
65 | | -{% for af in ('ipv4','ipv6') if af in n and n[af] is string %} |
66 | | - {{ n[af] }}: |
67 | | - description: "{{ n.name }}" |
68 | | -{% if n._source_ifname is defined %} |
69 | | - update-source: {{ n._source_ifname }} |
70 | | -{% endif %} |
71 | | - remote-as: {{ 'internal' if n.as==bgp.as else n.as }} |
72 | | -{% if n.local_as is defined %} |
73 | | - local-as: |
74 | | - asn: {{ n.local_as }} |
75 | | - enable: on |
76 | | -{% if n.replace_global_as|default(True) %} |
77 | | - replace: on |
78 | | - prepend: off |
79 | | -{% endif %} |
80 | | -{% endif %} |
81 | | - address-family: |
82 | | -{# NVUE cannot turn off default IPv4 activation, so we have to implement a fix for IPv6 #} |
83 | | -{% if af == 'ipv6' %} |
84 | | - ipv4-unicast: |
85 | | - enable: off |
86 | | -{% endif %} |
87 | | - {{ af }}-unicast: |
88 | | - enable: {{ 'on' if n.activate[af]|default(False) else 'off' }} |
89 | | -{% if 'ibgp' in n.type %} |
90 | | -{% if bgp.next_hop_self|default(False) %} |
91 | | - nexthop-setting: self |
92 | | -{% endif %} |
93 | | -{% if bgp.rr|default('') and not n.rr|default('') %} |
94 | | - route-reflector-client: on |
95 | | -{% endif %} |
96 | | -{% endif %} |
97 | | -{% if n.type in bgp.community|default({}) %} |
98 | | -{{ advertise_communities( bgp.community[n.type] ) }} |
99 | | -{% endif %} |
100 | | -{% endfor %} |
101 | | -{% endfor %} |
102 | | -{% if 'router_id' in bgp %} |
103 | | - router-id: {{ bgp.router_id }} |
104 | | -{% endif %} |
105 | | -{% if bgp.originate is defined %} |
106 | | - static: |
107 | | -{% for pfx in bgp.originate|default([]) %} |
108 | | - {{ pfx|ipaddr('0') }}: |
109 | | - address-family: ipv4-unicast |
110 | | - via: |
111 | | - blackhole: |
112 | | - type: blackhole |
113 | | -{% endfor %} |
114 | | -{% endif %} |
| 1 | +{% from "bgp/cumulus_nvue.macro.j2" import bgp_in_vrf with context %} |
| 2 | +--- |
| 3 | +{{ bgp_in_vrf('default', { 'bgp': bgp, 'loopback': loopback, 'af': af } ) }} |
0 commit comments