network/roles/fabric/templates/ports.conf.j2
Timotej Lazar 0e9dac6985 fabric: support arbitrary port breakouts
Not that we use anything but 1x and 4x. Mainly done so I can drop
nonexistent (because they have been broken out) interfaces from NetBox.
2024-05-13 17:44:39 +02:00

8 lines
578 B
Django/Jinja

# https://docs.nvidia.com/networking-ethernet-software/cumulus-linux/Layer-1-and-Switch-Ports/Interface-Configuration-and-Management/Switch-Port-Attributes/#breakout-ports
{% for interface in interfaces | selectattr('name', 'match', '^swp[0-9]+(s0)?$') %}
{# get '1' from 'swp1' and '2' from 'swp2s0' #}
{% set port = interface.name | regex_replace('^swp([0-9]+).*$', '\\1') %}
{% set count = interfaces | selectattr('name', 'match', '^swp'+port+'(s[0-9])*$') | length %}
{{ port }}={% if interface.enabled or count > 1 %}{{ count }}x{% else %}disabled{% endif +%}
{% endfor %}