1#jinja2: trim_blocks: True,lstrip_blocks: True
2{################################
3Purpose:
4Configure VLT commands for os9 Devices.
5os9_vlt:
6   domain: 1
7   backup_destination: 192.168.1.1
8   destination_type: ipv4
9   priority: 1
10   VLTi: 101
11   backup_destination_vrf: VLTi-KEEPALIVE
12   unit_id: 0
13   peer_routing: True
14   peer_routing_timeout: 200
15   multicast_peer_routing_timeout: 300
16   vlt_peers:
17     Po 12:
18      peer_lag: 13
19   system_mac: aa:aa:aa:aa:aa:aa
20   delay_restore: 100
21   delay_restore_abort_threshold: 110
22   proxy_gateway:
23     static:
24       remote_mac:
25         - address: aa:aa:aa:aa:aa:aa
26           exclude_vlan_range: 2
27           state: present
28       proxy_static_state: present
29     lldp:
30       vlt_peer_mac: true
31       peer_timeout: 20
32       peer_domain_link:
33          - port_channel_id: 10
34            exclude_vlan_range: 3
35            state: present
36       proxy_lldp_state: present
37
38   state: present
39################################}
40{% if os9_vlt is defined and os9_vlt %}
41  {% if os9_vlt.vlt_peers is defined and  os9_vlt.vlt_peers %}
42    {% for key in os9_vlt.vlt_peers.keys() %}
43      {% set channel_id = key.split(" ") %}
44      {% set peer_vars = os9_vlt.vlt_peers[key] %}
45interface Port-channel {{ channel_id[1] }}
46      {% if peer_vars.peer_lag is defined %}
47        {% if peer_vars.peer_lag %}
48 vlt-peer-lag port-channel {{ peer_vars.peer_lag}}
49        {% else %}
50 no vlt-peer-lag
51        {% endif %}
52      {% endif %}
53    {% endfor %}
54  {% endif %}
55  {% if os9_vlt.domain is defined and os9_vlt.domain %}
56    {% if os9_vlt.state is defined and os9_vlt.state == 'absent'  %}
57no vlt domain {{ os9_vlt.domain }}
58    {% else %}
59vlt domain {{ os9_vlt.domain }}
60    {% if os9_vlt.backup_destination is defined %}
61      {% if os9_vlt.backup_destination %}
62        {% if os9_vlt.destination_type is defined %}
63          {% if os9_vlt.destination_type == 'ipv6' %}
64 back-up destination ipv6 {{ os9_vlt.backup_destination }}
65          {% elif os9_vlt.destination_type ==  'ipv4' %}
66            {% if os9_vlt.backup_destination_vrf is defined and os9_vlt.backup_destination_vrf %}
67 back-up destination {{ os9_vlt.backup_destination }} vrf {{ os9_vlt.backup_destination_vrf }}
68            {% else %}
69 back-up destination {{ os9_vlt.backup_destination }}
70            {% endif %}
71          {% endif %}
72        {% endif %}
73      {% else %}
74 no back-up destination
75      {% endif %}
76    {% endif %}
77    {% if os9_vlt.VLTi is defined %}
78      {% if os9_vlt.VLTi %}
79 peer-link port-channel {{ os9_vlt.VLTi  }}
80      {% else %}
81 no peer-link
82      {% endif %}
83    {% endif %}
84    {% if os9_vlt.priority is defined %}
85      {% if os9_vlt.priority %}
86 primary-priority {{ os9_vlt.priority }}
87      {% else %}
88 no primary-priority
89      {% endif %}
90    {% endif %}
91    {% if os9_vlt.unit_id is defined %}
92      {% if os9_vlt.unit_id >= 0 %}
93 unit-id {{ os9_vlt.unit_id }}
94      {% else %}
95 no unit-id
96      {% endif %}
97    {% endif %}
98    {% if os9_vlt.peer_routing is defined %}
99      {% if os9_vlt.peer_routing == True %}
100 peer-routing
101      {% else %}
102 no peer-routing
103      {% endif %}
104    {% endif %}
105    {% if os9_vlt.peer_routing_timeout is defined %}
106      {% if os9_vlt.peer_routing_timeout %}
107 peer-routing-timeout {{ os9_vlt.peer_routing_timeout }}
108      {% else %}
109 no peer-routing-timeout
110      {% endif %}
111    {% endif %}
112    {% if os9_vlt.multicast_peer_routing_timeout is defined %}
113      {% if os9_vlt.multicast_peer_routing_timeout %}
114 multicast peer-routing timeout {{ os9_vlt.multicast_peer_routing_timeout }}
115      {% else %}
116 no multicast peer-routing timeout
117      {% endif %}
118    {% endif %}
119    {% if os9_vlt.system_mac is defined and os9_vlt.system_mac %}
120 system-mac mac-address {{ os9_vlt.system_mac }}
121    {% else %}
122 no system-mac
123    {% endif %}
124    {% if os9_vlt.delay_restore is defined %}
125      {% if os9_vlt.delay_restore %}
126 delay-restore {{ os9_vlt.delay_restore }}
127      {% else %}
128 no delay-restore
129      {% endif %}
130    {% endif %}
131    {% if os9_vlt.delay_restore_abort_threshold is defined %}
132      {% if os9_vlt.delay_restore_abort_threshold %}
133 delay-restore abort-threshold {{ os9_vlt.delay_restore_abort_threshold }}
134      {% else %}
135 no delay-restore abort-threshold
136      {% endif %}
137    {% endif %}
138
139    {% if os9_vlt.proxy_gateway is defined and os9_vlt.proxy_gateway %}
140      {% for key in os9_vlt.proxy_gateway.keys() %}
141        {% if key == "static" %}
142        {% set static_vars = os9_vlt.proxy_gateway[key] %}
143          {% if static_vars.proxy_static_state is defined and static_vars.proxy_static_state =="absent" %}
144 no proxy-gateway static
145          {% else %}
146 proxy-gateway static
147            {% if static_vars.remote_mac is defined and static_vars.remote_mac  %}
148              {% for mac in static_vars.remote_mac %}
149                {% if mac.state is defined and mac.state =="absent" %}
150                  {% if mac.address is defined and mac.address %}
151                    {% if mac.exclude_vlan_range is defined and mac.exclude_vlan_range %}
152  no remote-mac-address {{ mac.address }} exclude-vlan {{ mac.exclude_vlan_range }}
153                    {% else %}
154  no remote-mac-address {{ mac.address }}
155                    {% endif %}
156                  {% endif %}
157                {% else %}
158                  {% if mac.address is defined and mac.address %}
159                    {% if mac.exclude_vlan_range is defined and mac.exclude_vlan_range %}
160  remote-mac-address {{ mac.address }} exclude-vlan {{ mac.exclude_vlan_range }}
161                    {% else %}
162  remote-mac-address {{ mac.address }}
163                    {% endif %}
164                  {% endif %}
165                {% endif %}
166              {% endfor %}
167            {% endif %}
168          {% endif %}
169        {% elif key == "lldp" %}
170        {% set lldp_vars = os9_vlt.proxy_gateway[key] %}
171          {% if lldp_vars.proxy_lldp_state is defined and lldp_vars.proxy_lldp_state =="absent" %}
172 no proxy-gateway lldp
173          {% else %}
174 proxy-gateway lldp
175            {% if lldp_vars.peer_domain_link is defined and lldp_vars.peer_domain_link %}
176              {% for mac in lldp_vars.peer_domain_link %}
177                {% if mac.state is defined and mac.state =="absent" %}
178                  {% if mac.port_channel_id is defined and mac.port_channel_id %}
179                    {% if mac.exclude_vlan_range is defined and mac.exclude_vlan_range %}
180  no peer-domain-link port-channel {{ mac.port_channel_id }} exclude-vlan {{ mac.exclude_vlan_range }}
181                    {% else %}
182  no peer-domain-link port-channel {{ mac.port_channel_id }}
183                    {% endif %}
184                  {% endif %}
185                {% else %}
186                  {% if mac.port_channel_id is defined and mac.port_channel_id %}
187                    {% if mac.exclude_vlan_range is defined and mac.exclude_vlan_range %}
188  peer-domain-link port-channel {{ mac.port_channel_id }} exclude-vlan {{ mac.exclude_vlan_range }}
189                    {% else %}
190  peer-domain-link port-channel {{ mac.port_channel_id }}
191                    {% endif %}
192                  {% endif %}
193                {% endif %}
194              {% endfor %}
195            {% endif %}
196            {% if lldp_vars.vlt_peer_mac is defined %}
197              {% if lldp_vars.vlt_peer_mac %}
198  vlt-peer-mac transmit
199              {% else %}
200  no vlt-peer-mac transmit
201              {% endif %}
202            {% endif %}
203            {% if lldp_vars.peer_timeout is defined %}
204              {% if lldp_vars.peer_timeout %}
205  peer-timeout {{ lldp_vars.peer_timeout }}
206              {% else %}
207  no peer-timeout 2
208              {% endif %}
209            {% endif %}
210          {% endif %}
211        {% endif %}
212      {% endfor %}
213    {% endif %}
214
215    {% endif %}
216  {% endif %}
217{% endif %}