-
Notifications
You must be signed in to change notification settings - Fork 681
/
minigraph_dpg.j2
217 lines (216 loc) · 9.19 KB
/
minigraph_dpg.j2
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<DpgDec>
<DeviceDataPlaneInfo>
<IPSecTunnels/>
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
{% if cardtype is not defined or cardtype != 'supervisor' %}
<a:LoopbackIPInterface>
<Name>HostIP</Name>
<AttachTo>Loopback0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ lp_ipv4 }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ lp_ipv4 }}</a:PrefixStr>
</a:LoopbackIPInterface>
<a:LoopbackIPInterface>
<Name>HostIP1</Name>
<AttachTo>Loopback0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ lp_ipv6 }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ lp_ipv6 }}</a:PrefixStr>
</a:LoopbackIPInterface>
{%- if 'addl_loopbacks' in dual_tor_facts -%}
{%- for loopback_num in dual_tor_facts['addl_loopbacks'][inventory_hostname] -%}
{%- set loopback_facts = dual_tor_facts['addl_loopbacks'][inventory_hostname][loopback_num] -%}
<a:LoopbackIPInterface>
<Name>HostIP{{ loopback_facts['host_ip_base_index'] }}</Name>
<AttachTo>Loopback{{ loopback_num }}</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ loopback_facts['ipv4'] }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ loopback_facts['ipv4'] }}</a:PrefixStr>
</a:LoopbackIPInterface>
<a:LoopbackIPInterface>
<Name>HostIP{{ loopback_facts['host_ip_base_index'] + 1 }}</Name>
<AttachTo>Loopback{{ loopback_num }}</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ loopback_facts['ipv6'] }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ loopback_facts['ipv6'] }}</a:PrefixStr>
</a:LoopbackIPInterface>
{%- endfor -%}
{%- endif -%}
{% endif %}
</LoopbackIPInterfaces>
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:ManagementIPInterface>
<Name>HostIP</Name>
<AttachTo>eth0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ ansible_host }}/{{ mgmt_subnet_mask_length }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ ansible_host }}/{{ mgmt_subnet_mask_length }}</a:PrefixStr>
</a:ManagementIPInterface>
<a:ManagementIPInterface>
<Name>V6HostIP</Name>
<AttachTo>eth0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ ansible_hostv6 if ansible_hostv6 is defined else 'FC00:2::32' }}/64</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ ansible_hostv6 if ansible_hostv6 is defined else 'FC00:2::32' }}/64</a:PrefixStr>
</a:ManagementIPInterface>
</ManagementIPInterfaces>
<ManagementVIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
<MplsInterfaces/>
<MplsTeInterfaces/>
<RsvpInterfaces/>
<Hostname>{{ inventory_hostname }}</Hostname>
<PortChannelInterfaces>
{% for index in range(vms_number) %}
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
{% set port_channel_intf=';'.join(intf_names[vms[index]]) %}
<PortChannel>
<Name>PortChannel{{ ((index+1)|string).zfill(4) }}</Name>
<AttachTo>{{ port_channel_intf }}</AttachTo>
<SubInterface/>
</PortChannel>
{% endif %}
{% endfor %}
{% if 'tor' in vm_topo_config['dut_type'] | lower %}
{% for portchannel, params in portchannel_config.items() %}
{% set port_channel_intf=';'.join(params['intfs'] | map('extract', port_alias)) %}
<PortChannel>
<Name>{{ portchannel }}</Name>
<AttachTo>{{ port_channel_intf }}</AttachTo>
<SubInterface/>
</PortChannel>
{% endfor %}
{% endif %}
</PortChannelInterfaces>
{% if tunnel_configs | length > 0 %}
<TunnelInterfaces>
{% for tunnel, tunnel_param in tunnel_configs.items() %}
<TunnelInterface Name="{{ tunnel }}" Type="{{ tunnel_param['type'] }}" AttachTo="{{ tunnel_param['attach_to'] }}" DifferentiatedServicesCodePointMode="{{ tunnel_param['dscp'] }}" EcnEncapsulationMode="{{ tunnel_param['ecn_encap'] }}" EcnDecapsulationMode="{{ tunnel_param['ecn_decap'] }}" TtlMode="{{ tunnel_param['ttl_mode'] }}" />
{% endfor %}
</TunnelInterfaces>
{% endif %}
<VlanInterfaces>
{% if 'tor' in vm_topo_config['dut_type'] | lower %}
{% for vlan, vlan_param in vlan_configs.items() %}
<VlanInterface>
<Name>{{ vlan }}</Name>
{% set vlan_intf_str=';'.join(vlan_param['intfs'] + vlan_param['portchannels']) %}
<AttachTo>{{ vlan_intf_str }}</AttachTo>
<NoDhcpRelay>False</NoDhcpRelay>
<StaticDHCPRelay>0.0.0.0/0</StaticDHCPRelay>
<Type i:nil="true"/>
{% set dhcp_servers_str=';'.join(dhcp_servers) %}
<DhcpRelays>{{ dhcp_servers_str }}</DhcpRelays>
<VlanID>{{ vlan_param['id'] }}</VlanID>
<Tag>{{ vlan_param['tag'] }}</Tag>
<Subnets>{{ vlan_param['prefix'] | ipaddr('network') }}/{{ vlan_param['prefix'] | ipaddr('prefix') }}</Subnets>
{% if 'mac' in vlan_param %}
<MacAddress>{{ vlan_param['mac'] }}</MacAddress>
{% endif %}
</VlanInterface>
{% endfor %}
{% endif %}
</VlanInterfaces>
<IPInterfaces>
{% if cardtype is not defined or cardtype != 'supervisor' %}
{% for index in range(vms_number) %}
{% if vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int] is not none %}
<IPInterface>
<Name i:nil="true"/>
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
<AttachTo>PortChannel{{ ((index+1) |string).zfill(4) }}</AttachTo>
{% else %}
<AttachTo>{{ port_alias[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] }}</AttachTo>
{% endif %}
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv4'][dut_index|int] }}/{{ vm_topo_config['vm'][vms[index]]['ipv4mask'][dut_index|int] }}</Prefix>
</IPInterface>
<IPInterface>
<Name i:Name="true"/>
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
<AttachTo>PortChannel{{ ((index+1) |string).zfill(4) }}</AttachTo>
{% else %}
<AttachTo>{{ port_alias[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] }}</AttachTo>
{% endif %}
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv6'][dut_index|int] }}/{{ vm_topo_config['vm'][vms[index]]['ipv6mask'][dut_index|int] }}</Prefix>
</IPInterface>
{% endif %}
{% endfor %}
{% if 'tor' in vm_topo_config['dut_type'] | lower %}
{% for vlan, vlan_param in vlan_configs.items() %}
<IPInterface>
<Name i:nil="true"/>
<AttachTo>{{ vlan }}</AttachTo>
<Prefix>{{ vlan_param['prefix'] }}</Prefix>
</IPInterface>
{% endfor %}
{% for vlan, vlan_param in vlan_configs.items() %}
{% if 'prefix_v6' in vlan_param %}
<IPInterface>
<Name i:nil="true"/>
<AttachTo>{{ vlan }}</AttachTo>
<Prefix>{{ vlan_param['prefix_v6'] }}</Prefix>
</IPInterface>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
</IPInterfaces>
<DataAcls/>
<AclInterfaces>
{% if cardtype is not defined or cardtype != 'supervisor' %}
<AclInterface>
<InAcl>SNMP_ACL</InAcl>
<AttachTo>SNMP</AttachTo>
<Type>SNMP</Type>
</AclInterface>
<AclInterface>
<AttachTo>ERSPAN</AttachTo>
<InAcl>Everflow</InAcl>
<Type>Everflow</Type>
</AclInterface>
<AclInterface>
<AttachTo>ERSPANV6</AttachTo>
<InAcl>EverflowV6</InAcl>
<Type>EverflowV6</Type>
</AclInterface>
<AclInterface>
<AttachTo>VTY_LINE</AttachTo>
<InAcl>ssh-only</InAcl>
<Type>SSH</Type>
</AclInterface>
{% if enable_data_plane_acl|default('true')|bool %}
<AclInterface>
<AttachTo>
{%- set acl_intfs = [] -%}
{%- for index in range(vms_number) %}
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
{% set a_intf = 'PortChannel' + ((index+1) |string).zfill(4) %}
{{- acl_intfs.append(a_intf) -}}
{% endif %}
{% endfor %}
{% for index in range(vms_number) %}
{% if 'port-channel' not in vm_topo_config['vm'][vms[index]]['ip_intf']|lower %}
{% if vm_topo_config['vm'][vms[index]]['intfs'][dut_index|int]|length %}
{% set a_intf = port_alias[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] %}
{{- acl_intfs.append(a_intf) -}}
{% endif %}
{% endif %}
{% endfor -%}
{{- acl_intfs|join(';') -}}
</AttachTo>
<InAcl>DataAcl</InAcl>
<Type>DataPlane</Type>
</AclInterface>
{% endif %}
{% endif %}
</AclInterfaces>
<DownstreamSummaries/>
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</DeviceDataPlaneInfo>
{% include 'minigraph_dpg_asic.j2' %}
</DpgDec>