Sort interface names - requires using 'natsort' module and configuring custom Jinja2 filter

netbox
Daniel Ankers 2024-07-04 15:40:30 +01:00
parent 1392e221c7
commit 73895d1e5d
1 changed files with 1 additions and 7 deletions

View File

@ -213,13 +213,7 @@ interfaces {
} }
{% endif %} {% endif %}
{# Physical interfaces should be sorted by FPC/PIC/Port value - that's a challenge to do in Jinja so we cheat for now by putting the xe- interfaces first. This won't work for all devices! #} {# Physical interfaces should be sorted by FPC/PIC/Port value - that's a challenge to do in Jinja so we cheat for now by putting the xe- interfaces first. This won't work for all devices! #}
{% for interface in device.interfaces.filter(name__startswith='ge-') %} {% for interface in device.interfaces.filter(name__contains='-')|natsort %}
{{ interfaceconfig(interface) }}
{% endfor %}
{% for interface in device.interfaces.filter(name__startswith='xe-') %}
{{ interfaceconfig(interface) }}
{% endfor %}
{% for interface in device.interfaces.filter(name__startswith='et-') %}
{{ interfaceconfig(interface) }} {{ interfaceconfig(interface) }}
{% endfor %} {% endfor %}
{% for interface in device.interfaces.filter(name__startswith='ae') %} {% for interface in device.interfaces.filter(name__startswith='ae') %}