29 lines
1.4 KiB
Django/Jinja
29 lines
1.4 KiB
Django/Jinja
{%- for bridge in device.interfaces.filter(type="bridge")|list %}
|
|
{%- set brid = bridge.id %}
|
|
{%- set brname = bridge.name %}
|
|
/interface bridge add name={{ brname }} vlan-filtering=yes frame-types=admit-only-vlan-tagged
|
|
{%- for iface in device.interfaces.filter(bridge=brid) %}
|
|
{%- if iface.untagged_vlan or iface.tagged_vlans.exists() or iface.mode=="tagged-all" %}
|
|
/interface bridge port add bridge={{ brname }} interface={{ iface.name }}
|
|
{%- if iface.untagged_vlan %} pvid={{ iface.untagged_vlan.vid }} {%- endif %}
|
|
{%- if iface.mode == "access" %} frame-types=admit-only-untagged-and-priority-tagged
|
|
{%- elif iface.mode == "tagged-all" %} frame-types=admit-only-vlan-tagged {%- endif %}
|
|
{%- endif %}
|
|
{%- for ip in iface.ip_addresses.filter(status="active") %}
|
|
/ip address add address={{ ip }} interface={{ iface }}
|
|
{%- endfor %}
|
|
{%- endfor %}
|
|
{%- for v in device.site.vlans.all() %}
|
|
{%- set ift = device.interfaces.filter(tagged_vlans=v,bridge=brid)|list %}
|
|
{%- set ifta = device.interfaces.filter(mode="tagged-all")|list %}
|
|
{%- set iftm = ift|default([]) + ifta|default([]) %}
|
|
{%- set ifu = device.interfaces.filter(untagged_vlan=v,bridge=brid)|list -%}
|
|
{%- if ift or iftm %}
|
|
/interface bridge vlan add bridge={{ brname }} vlan-ids={{ v.vid }}
|
|
{%- if iftm %} tagged={{ iftm|join(",") }}{% endif %}
|
|
{%- if ifu %} untagged={{ ifu|join(",") }}{% endif %}
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
{%- endfor %}
|
|
|
|
|