-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathndfc_underlay_ip_address.j2
More file actions
135 lines (128 loc) · 5.09 KB
/
Copy pathndfc_underlay_ip_address.j2
File metadata and controls
135 lines (128 loc) · 5.09 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
# This NDFC policy and switch attachments config data structure is auto-generated
# DO NOT EDIT MANUALLY
#
{% if vxlan.underlay.general.manual_underlay_allocation is true %}
{% set routing_lo_id = vxlan.underlay.general.underlay_routing_loopback_id %}
{% set vtep_lo_id = vxlan.underlay.general.underlay_vtep_loopback_id %}
{%- set switch_secondary_ip = {} -%}
{%- set switch_list = {} %}
{%- for switch in vxlan.topology.switches %}
{%- set _ = switch_list.update({
switch.name: {
'management_ipv4_address': switch.management.management_ipv4_address,
'serial_number': switch.serial_number
}
}) %}
{%- endfor %}
{% macro generate_loopback_config(loopback_id) %}
{%- for switch in vxlan.topology.switches %}
{%- set ns = namespace(ip="") %}
{%- for interface in switch.interfaces %}
{%- if interface.name.lower() == "loopback" ~ loopback_id or interface.name.lower() == "lo" ~ loopback_id %}
{%- if interface.ipv4_address is defined and interface.ipv4_address is iterable %}
{%- set ns.ip = interface.ipv4_address %}
{%- elif interface.ipv6_address is defined and interface.ipv6_address is iterable %}
{%- set ns.ip = interface.ipv6_address %}
{%- endif %}
{%- endif %}
{%- endfor %}
- 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.ip }}"
switch:
- "{{ switch_list[switch.name].management_ipv4_address }}"
{% 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 vxlan.topology.vpc_peers is defined %}
{% for peer in vxlan.topology.vpc_peers %}
- 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 }}"
{% endfor %}
{% endif %}
{# Configure IPv6 router_id #}
{% for switch in vxlan.topology.switches %}
{% if switch.manual_ipv6_router_id is defined and switch.manual_ipv6_router_id is iterable %}
- entity_name: "{{ switch_list[switch.name].serial_number }}"
pool_type: IP
pool_name: "ROUTER_ID_POOL"
scope_type: device
resource: "{{ switch.manual_ipv6_router_id }}"
switch:
- "{{ switch_list[switch.name].management_ipv4_address }}"
{% endif %}
{% endfor%}
{# build p2p links - Check if ipv4 or ipv6 is present to distinct with fabric_link with template #}
{# build subnet #}
{% if vxlan.topology.fabric_links is defined %}
{% for switch in vxlan.topology.fabric_links %}
{# Allocation for IPv4 #}
{% 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 %}
{# Allocation for IPv6 #}
{% if switch.ipv6 is defined and switch.ipv6 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.ipv6.subnet }}"
switch:
- "{{ switch_list[switch.source_device].management_ipv4_address }}"
{# assign ips #}
{% if switch.ipv6.source_ipv6 is defined and switch.ipv6.dest_ipv6 is defined %}
- entity_name: "{{ switch_list[switch.source_device].serial_number }}~{{ switch.source_interface }}"
pool_type: IP
pool_name: "{{switch.ipv6.subnet}}"
scope_type: device_interface
resource: "{{ switch.ipv6.source_ipv6 }}"
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.ipv6.subnet}}"
scope_type: device_interface
resource: "{{ switch.ipv6.dest_ipv6 }}"
switch:
- "{{ switch_list[switch.dest_device].management_ipv4_address }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}