-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathndfc_underlay_ip_address.j2
More file actions
103 lines (99 loc) · 4.21 KB
/
Copy pathndfc_underlay_ip_address.j2
File metadata and controls
103 lines (99 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
# This NDFC policy and switch attachments config data structure is auto-generated
# DO NOT EDIT MANUALLY
#
{% if data_model_extended.vxlan.underlay.general.manual_underlay_allocation is true %}
{% set routing_lo_id = data_model_extended.vxlan.underlay.general.underlay_routing_loopback_id %}
{% set vtep_lo_id = data_model_extended.vxlan.underlay.general.underlay_vtep_loopback_id %}
{%- set switch_secondary_ip = {} -%}
{%- set switch_list = {} %}
{%- for switch in data_model_extended.vxlan.topology.switches %}
{%- set _ = switch_list.update({
switch.name: {
'management_ipv4_address': switch.management.management_ipv4_address,
'serial_number': switch.serial_number,
'role': switch.role
}
}) %}
{%- endfor %}
{% macro generate_loopback_config(loopback_id) %}
{%- for switch in data_model_extended.vxlan.topology.switches %}
{%- set ns = namespace(ipv4="") %}
{%- for interface in switch.interfaces %}
{%- if interface.name.lower() == "loopback" ~ loopback_id or interface.name.lower() == "lo" ~ loopback_id %}
{%- set ns.ipv4 = interface.ipv4_address %}
{%- endif %}
{%- endfor %}
{% if not ((switch.role == 'spine' or switch.role == 'super_spine') and loopback_id == vtep_lo_id) %}
{% if switch.role != 'tor' %}
- entity_name: "{{ switch_list[switch.name].serial_number }}~loopback{{ loopback_id }}"
pool_type: IP
pool_name: "LOOPBACK{{ loopback_id }}_IP_POOL"
scope_type: device_interface
resource: "{{ ns.ipv4 }}"
switch:
- "{{ switch_list[switch.name].management_ipv4_address }}"
{% endif %}
{% endif %}
{% endfor %}
{% endmacro %}
{# resource for routing loopback #}
{{ generate_loopback_config(routing_lo_id) }}
{# resource for vtep loopback #}
{{ generate_loopback_config(vtep_lo_id) }}
{# resource for leaf in vPC #}
{% if data_model_extended.vxlan.topology.vpc_peers is defined %}
{% for peer in data_model_extended.vxlan.topology.vpc_peers %}
{% if switch_list[peer.peer1].role != 'tor' and switch_list[peer.peer2].role != 'tor' %}
- entity_name: "{{ switch_list[peer.peer1].serial_number }}~{{ switch_list[peer.peer2].serial_number }}~loopback{{ vtep_lo_id }}"
pool_type: IP
pool_name: "LOOPBACK{{ vtep_lo_id }}_IP_POOL"
scope_type: device_interface
resource: "{{ peer.vtep_vip }}"
switch:
- "{{ switch_list[peer.peer1].management_ipv4_address }}"
{% endif %}
{% endfor %}
{% endif %}
{# build p2p links - Check if ipv4 or ipv6 is present to distinct with fabric_link with template #}
{# build subnet #}
{% if data_model_extended.vxlan.topology.fabric_links is defined %}
{% for switch in data_model_extended.vxlan.topology.fabric_links %}
{% if switch.ipv4 is defined and switch.ipv4 is iterable %}
- entity_name: "{{ switch_list[switch.source_device].serial_number }}~{{ switch.source_interface }}~{{ switch_list[switch.dest_device].serial_number }}~{{ switch.dest_interface }}"
pool_type: SUBNET
pool_name: "SUBNET"
scope_type: link
resource: "{{ switch.ipv4.subnet }}"
switch:
- "{{ switch_list[switch.source_device].management_ipv4_address }}"
{# assign ips #}
{% if switch.ipv4.source_ipv4 is defined and switch.ipv4.dest_ipv4 is defined %}
- entity_name: "{{ switch_list[switch.source_device].serial_number }}~{{ switch.source_interface }}"
pool_type: IP
pool_name: "{{switch.ipv4.subnet}}"
scope_type: device_interface
resource: "{{ switch.ipv4.source_ipv4 }}"
switch:
- "{{ switch_list[switch.source_device].management_ipv4_address }}"
- entity_name: "{{ switch_list[switch.dest_device].serial_number }}~{{ switch.dest_interface }}"
pool_type: IP
pool_name: "{{switch.ipv4.subnet}}"
scope_type: device_interface
resource: "{{ switch.ipv4.dest_ipv4 }}"
switch:
- "{{ switch_list[switch.dest_device].management_ipv4_address }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{# resource for anycast RP (multicast replication only) #}
{% set replication_mode = data_model_extended.vxlan.underlay.general.replication_mode | default(defaults.vxlan.underlay.general.replication_mode) %}
{% if replication_mode == "multicast" and data_model_extended.vxlan.underlay.multicast.ipv4.anycast_rp is defined %}
- entity_name: "ANYCAST_RP"
pool_type: IP
pool_name: "ANYCAST_RP_IP_POOL"
scope_type: fabric
resource: "{{ data_model_extended.vxlan.underlay.multicast.ipv4.anycast_rp }}"
{% endif %}
{% endif %}