Timotej Lazar
1c0709a6a6
Don’t try to guess what should be allowed because not all switch links are tagged in NetBox. For now we limit mainly on access switches.
24 lines
1 KiB
Django/Jinja
24 lines
1 KiB
Django/Jinja
{# Note that there must be exactly one VLAN-aware bridge. #}
|
|
{% set bridge = interfaces | selectattr('type') | selectattr('type.value', '==', 'bridge') | first %}
|
|
{# interfaces that belong to this bridge #}
|
|
{% set ports = interfaces | selectattr('enabled') | selectattr('bridge') | selectattr('bridge.name', '==', bridge.name) %}
|
|
{# allowed VLANs can be specified on the bridge, any of its ports, or all VLANs in NetBox #}
|
|
{% set my_vlans = bridge.tagged_vlans or vlans %}
|
|
{% set my_vlan_ids = my_vlans | map(attribute='vid') | sort -%}
|
|
|
|
auto {{ bridge.name }}
|
|
iface {{ bridge.name }}
|
|
bridge-ports {{ ports | map(attribute='name') | join(' ') }}{% if my_vlans %} vxlan{% endif +%}
|
|
bridge-vlan-aware yes
|
|
bridge-pvid {{ bridge.untagged_vlan | default(1, true) }}
|
|
{% if bridge.mode.value == 'tagged' and my_vlans %}
|
|
bridge-vids {{ my_vlan_ids | join(' ') }}
|
|
{% endif %}
|
|
|
|
{% if my_vlans %}
|
|
auto vxlan
|
|
iface vxlan
|
|
bridge-vlan-vni-map {{ my_vlan_ids | zip(my_vlan_ids) | map('join', '=') | join(' ') }}
|
|
bridge-learning off
|
|
{% endif %}
|