/
os10_interface.j2
286 lines (272 loc) · 8.12 KB
/
os10_interface.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#jinja2: trim_blocks: True,lstrip_blocks: True
{#####################################################
Purpose:
Configure interface commands for os10 Devices.
os10_interface:
ethernet 1/1/31:
desc: "OS10 intf"
portmode: trunk
mtu: 2000
speed: 1000
switchport: False
admin: up
ip_type_dynamic: True
ip_and_mask: "192.168.11.1/24"
virtual_gateway_ip: "172.17.17.1"
suppress_ra: present
ipv6_autoconfig: True
ipv6_and_mask: 2001:4898:5808:ffa2::5/126
state_ipv6: present
ip_helper:
- ip: 10.0.0.36
state: present
flowcontrol:
mode: "receive"
enable: "on"
state: "present"
ethernet 1/1/3:
fanout: 10g-4x
range ethernet 1/1/1-1/1/4:
switchport: True
admin: down
stp_rpvst_default_behaviour: False
virtual-network 100:
vrf: "test"
ip_and_mask: "15.1.1.1/24"
virtual_gateway_ip: "15.1.1.254"
admin: up
port-channel 10:
admin: up
switchport: False
suppress_ra:
ipv6_bgp_unnum:
state: present
peergroup_type: ebgp
port-channel 20:
admin: up
stp_rpvst_default_behaviour: True
vlan 10:
ip_and_mask: "10.1.1.1/24"
virtual_gateway_ip: "10.1.1.254"
virtual_gateway_ipv6: "10:1:1::254"
admin: up
#####################################################}
{% if os10_interface is defined and os10_interface %}
{% for key in os10_interface.keys() %}
{% set intf_vars = os10_interface[key] %}
{% set port = key.split(" ") %}
{% set interface_key = "" %}
{% if intf_vars.fanout is defined %}
{% if intf_vars.fanout %}
interface breakout {{ port[1] }} map {{ intf_vars.fanout }}
{% else %}
no interface breakout {{ port[1] }}
{% endif %}
{% endif %}
{% endfor %}
{% for key in os10_interface.keys() %}
{% set intf_vars = os10_interface[key] %}
{% set port = key.split(" ") %}
{% set interface_key = "" %}
{% if (intf_vars.fanout is defined and not intf_vars.fanout) or (intf_vars.fanout is not defined) %}
{% if key.startswith('range')%}
{% set interface_key = port[0] + " " + port[1] + port[2] %}
{% else %}
{% set interface_key = port[0] + port[1] %}
{% endif %}
interface {{ interface_key }}
{% if intf_vars.desc is defined %}
{% if intf_vars.desc %}
{% if intf_vars.desc|wordcount > 1 %}
description "{{ intf_vars.desc }}"
{% else %}
description {{ intf_vars.desc }}
{% endif %}
{% else %}
no description
{% endif %}
{% endif %}
{% if intf_vars.switchport is defined %}
{% if intf_vars.switchport %}
{% if intf_vars.portmode is defined and intf_vars.portmode %}
switchport mode {{ intf_vars.portmode }}
{% endif %}
{% else %}
no switchport
{% endif %}
{% else %}
{% if intf_vars.portmode is defined %}
{% if intf_vars.portmode %}
switchport mode {{ intf_vars.portmode }}
{% else %}
no switchport
{% endif %}
{% endif %}
{% endif %}
{% if intf_vars.fec is defined %}
{% if intf_vars.fec %}
fec on
{% else %}
fec off
{% endif %}
no fec
{% endif %}
{% if intf_vars.mtu is defined %}
{% if intf_vars.mtu %}
mtu {{ intf_vars.mtu }}
{% else %}
no mtu
{% endif %}
{% endif %}
{% if intf_vars.speed is defined %}
{% if intf_vars.speed %}
speed {{ intf_vars.speed }}
{% else %}
no speed
{% endif %}
{% endif %}
{% if intf_vars.negotiation is defined %}
{% if intf_vars.negotiation == "on" %}
negotiation on
{% elif intf_vars.negotiation == "off" %}
negotiation off
{% else %}
negotiation auto
{% endif %}
{% endif %}
{% if intf_vars.ip_type_dynamic is defined %}
{% if intf_vars.ip_type_dynamic %}
ip address dhcp
{% else %}
no ip address
{% endif %}
{% else %}
{% if intf_vars.vrf is defined %}
{% if intf_vars.vrf %}
ip vrf forwarding {{ intf_vars.vrf }}
{% else %}
no ip vrf forwarding
{% endif %}
{% endif %}
{% if intf_vars.ip_and_mask is defined %}
{% if intf_vars.ip_and_mask %}
ip address {{ intf_vars.ip_and_mask }}
{% else %}
no ip address
{% endif %}
{% endif %}
{% endif %}
{% if intf_vars.virtual_gateway_ip is defined %}
{% if intf_vars.virtual_gateway_ip %}
ip virtual-router address {{ intf_vars.virtual_gateway_ip }}
{% else %}
no ip virtual-router address
{% endif %}
{% endif %}
{% if intf_vars.virtual_gateway_ipv6 is defined %}
{% if intf_vars.virtual_gateway_ipv6 %}
ipv6 virtual-router address {{ intf_vars.virtual_gateway_ipv6 }}
{% else %}
no ipv6 virtual-router address
{% endif %}
{% endif %}
{% if intf_vars.suppress_ra is defined %}
{% if intf_vars.suppress_ra == "present" %}
no ipv6 nd send-ra
{% else %}
ipv6 nd send-ra
{% endif %}
{% endif %}
{% if intf_vars.stp_rpvst_default_behaviour is defined %}
{% if intf_vars.stp_rpvst_default_behaviour %}
spanning-tree rapid-pvst default-behavior
{% else %}
no spanning-tree rapid-pvst default-behavior
{% endif %}
{% endif %}
{% if intf_vars.ipv6_autoconfig is defined %}
{% if intf_vars.ipv6_autoconfig %}
ipv6 address autoconfig
{% else %}
no ipv6 address
{% endif %}
{% elif intf_vars.ipv6_type_dynamic is defined %}
{% if intf_vars.ipv6_type_dynamic %}
ipv6 address dhcp
{% else %}
no ipv6 address
{% endif %}
{% else %}
{% if intf_vars.state_ipv6 is defined and intf_vars.state_ipv6 == "absent" %}
{% if intf_vars.ipv6_and_mask is defined and intf_vars.ipv6_and_mask %}
no ipv6 address {{ intf_vars.ipv6_and_mask }}
{% else %}
no ipv6 address
{% endif %}
{% else %}
{% if intf_vars.ipv6_and_mask is defined and intf_vars.ipv6_and_mask %}
ipv6 address {{ intf_vars.ipv6_and_mask }}
{% endif %}
{% endif %}
{% endif %}
{% if intf_vars.max_ra is defined %}
{% if intf_vars.max_ra %}
ipv6 nd max-ra-interval {{ intf_vars.max_ra }}
{% else %}
no ipv6 nd max-ra-interval
{% endif %}
{% endif %}
{% if intf_vars.min_ra is defined %}
{% if intf_vars.min_ra %}
ipv6 nd min-ra-interval {{ intf_vars.min_ra }}
{% else %}
no ipv6 nd min-ra-interval
{% endif %}
{% endif %}
{% if intf_vars.ip_helper is defined and intf_vars.ip_helper %}
{% for helper in intf_vars.ip_helper %}
{% if helper.ip is defined and helper.ip %}
{% if helper.state is defined and helper.state == "absent" %}
no ip helper-address {{ helper.ip }}
{% else %}
ip helper-address {{ helper.ip }}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% if intf_vars.flowcontrol is defined and intf_vars.flowcontrol %}
{% if intf_vars.flowcontrol.mode is defined %}
{% if intf_vars.flowcontrol.mode %}
{% if intf_vars.flowcontrol.state is defined and intf_vars.flowcontrol.state == "absent" %}
no flowcontrol {{ intf_vars.flowcontrol.mode }}
{% else %}
{% if intf_vars.flowcontrol.enable is defined %}
{% if intf_vars.flowcontrol.enable == "on" %}
flowcontrol {{ intf_vars.flowcontrol.mode }} on
{% else %}
flowcontrol {{ intf_vars.flowcontrol.mode }} off
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if intf_vars.admin is defined %}
{% if intf_vars.admin == "up" %}
no shutdown
{% elif intf_vars.admin == "down" %}
shutdown
{% endif %}
{% endif %}
{% if intf_vars.ipv6_bgp_unnum is defined and intf_vars.ipv6_bgp_unnum %}
{% if intf_vars.ipv6_bgp_unnum.state == "absent" %}
no ipv6 bgp unnumbered
{% elif intf_vars.ipv6_bgp_unnum.state == "present" and intf_vars.ipv6_bgp_unnum.peergroup_type == "ebgp" %}
ipv6 bgp unnumbered ebgp-template
{% elif intf_vars.ipv6_bgp_unnum.state == "present" and intf_vars.ipv6_bgp_unnum.peergroup_type == "ibgp" %}
ipv6 bgp unnumbered ibgp-template
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}