-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v3.2.2
Feature type
Change to existing functionality
Proposed functionality
The interface name is naturalized to make it sortable in a proper way. (1,2,10,11,20,21; and not 1,10,11,2,20,21)
The current implementation is not covering all use cases to sort interfaces properly.
By making the function more generic, it could cover more use cases:
output = ''
parts = re.split(r'(\d+)',value.lower())
for part in parts:
if part.isdigit():
output += part.rjust(4, '0')
elif part not in ['.',':','/']:
output += part
It splits the interfacename into parts with and without numbers. the numbers are pre-padded with zero's and the chars [dot,colon,slash] are removed from between the numbers.
There might be corner cases with mixed number schema's on one device, but it will keep them grouped.
Unless there was a reason why the slot/subslot/position/.. were prepended to the interfacetype, rather then post ?
Use case
On Arista we have interfaces that are split in lanes, without slot/pos/subpos identifiers.
Ethernet1
Ethernet2
Ethernet3
Ethernet48/1
Ethernet48/2
Ethernet48/3
Ethernet48/4
Ethernet49/1
Ethernet49/2
Ethernet49/3
Ethernet49/4
The current rules sorts them as
Ethernet48/1
Ethernet48/2
Ethernet48/3
Ethernet48/4
Ethernet49/1
Ethernet49/2
Ethernet49/3
Ethernet49/4
Ethernet1
Ethernet2
Ethernet3
because the /1 is prepended to the interfacetype, while with non-slashed interfaces, the prepend is 9999
netbox/netbox/utilities/ordering.py
Line 46 in a2203da
def naturalize_interface(value, max_length): |
Database changes
All _name fields of all interfaces need to be re-calculated.
External dependencies
No response