From 73895d1e5de60729823147513f62486f946069c9 Mon Sep 17 00:00:00 2001 From: Daniel Ankers Date: Thu, 4 Jul 2024 15:40:30 +0100 Subject: [PATCH] Sort interface names - requires using 'natsort' module and configuring custom Jinja2 filter --- juniper-macros.j2 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/juniper-macros.j2 b/juniper-macros.j2 index 70ed381..39ab1d1 100644 --- a/juniper-macros.j2 +++ b/juniper-macros.j2 @@ -213,13 +213,7 @@ interfaces { } {% 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! #} -{% for interface in device.interfaces.filter(name__startswith='ge-') %} -{{ interfaceconfig(interface) }} -{% endfor %} -{% for interface in device.interfaces.filter(name__startswith='xe-') %} -{{ interfaceconfig(interface) }} -{% endfor %} -{% for interface in device.interfaces.filter(name__startswith='et-') %} +{% for interface in device.interfaces.filter(name__contains='-')|natsort %} {{ interfaceconfig(interface) }} {% endfor %} {% for interface in device.interfaces.filter(name__startswith='ae') %}