@@ -10,36 +10,45 @@ spanning-tree mode {{ mode }}
10
10
spanning-tree rstp force-version stp
11
11
{% endif %}
12
12
13
- {% if 'priority' in stp %}
13
+ {% if 'priority' in stp %}
14
14
spanning-tree rstp priority {{ stp.priority }}
15
- {% endif %}
15
+ {% endif %}
16
16
17
17
{# Check for per-VLAN enable and priority; implies Rapid-PVST #}
18
- {% if vlans is defined %}
18
+ {% if vlans is defined %}
19
19
{% for vname ,vdata in vlans .items () if 'stp' in vdata %}
20
20
{% if not vdata .stp .enable |default (True ) %}
21
21
spanning-tree vlan {{ vdata.id }} disable
22
22
{% elif 'priority' in vdata .stp %}
23
23
spanning-tree vlan {{ vdata.id }} priority {{ vdata.stp.priority }}
24
24
{% endif %}
25
25
{% endfor +%}
26
- {% endif %}
26
+ {% endif %}
27
27
28
- {% for ifdata in interfaces if 'stp' in ifdata %}
29
- {% if ifdata .vlan .trunk_id is defined or ifdata .vlan .access_id is defined %}
28
+ {% for ifdata in interfaces if 'stp' in ifdata or ifdata .vlan .trunk |default ({})|dict 2items |map (attribute ='value' )|selectattr ('stp' ,'defined' ) %}
30
29
interface {{ ifdata.ifname }}
30
+ {% if 'stp' in ifdata %}
31
31
{% if not ifdata .stp .enable |default (True ) %}
32
32
spanning-tree disable
33
33
{% elif 'port_priority' in ifdata .stp %}
34
34
#
35
35
# Use 16x port_priority to get the correct 4-bit value on the wire
36
36
#
37
37
{% if stp .protocol =='pvrst' %}
38
- spanning-tree vlan {{ ifdata.vlan.trunk_id |default(ifdata.vlan.access_id ) }} priority {{ ifdata.stp.port_priority * 16 }}
38
+ spanning-tree vlan {{ ifdata.vlan.access_id |default(1 ) }} priority {{ ifdata.stp.port_priority * 16 }}
39
39
{% else %}
40
40
spanning-tree rstp priority {{ ifdata.stp.port_priority * 16 }}
41
41
{% endif %}
42
42
{% endif %}
43
+ {% else %}
44
+ {# Trunk port(s) with STP attributes #}
45
+ {% for id in ifdata .vlan .trunk_id %}
46
+ {% for vname ,vdata in vlans .items () if vdata .id ==id %}
47
+ {% if vname in ifdata .vlan .trunk and ifdata .vlan .trunk [vname ].stp .port_priority is defined %}
48
+ spanning-tree vlan {{ id }} priority {{ ifdata.vlan.trunk[vname] .stp.port_priority * 16 }}
49
+ {% endif %}
50
+ {% endfor %}
51
+ {% endfor %}
43
52
{% endif %}
44
- {% endfor %}
53
+ {% endfor %}
45
54
{% endif %}
0 commit comments