Revamp interface naturalize function #11602

Closed
opened 2025-12-29 21:47:31 +01:00 by adam · 1 comment
Owner

Originally created by @PieterL75 on GitHub (Sep 12, 2025).

NetBox version

v4.2.9

Feature type

Change to existing functionality

Proposed functionality

Interfaces are sorted according a specific interface naturalization function
cf0ef92268/netbox/utilities/ordering.py (L51)

This function suits very well for Cisco branded devices, but does not always work for other vendors.

There has been few proposals (can only find this one https://github.com/netbox-community/netbox/issues/9368 ) to address this, but for now non has been accepted,

I see few options

  • sort the interfaces manually. This can be done on the template, and then is automatically done in the devices. The devices would also need the option to move interfaces manually (for me the easiest and most flexible solution)
  • provide different sorting mechanisms, which can be applied per template/vendor/device; also allow plugins to extend these sorting mechanisms (very flexible solution, but the creation of a few general sorting algorithms)
  • update the current function to work different, based on interface names/models/vendors.

Use case

A recent poll in #netbox shows that there is a need for this: https://netdev-community.slack.com/archives/C01P0FRSXRV/p1757313471550629?thread_ts=1757065483.482359&cid=C01P0FRSXRV

On Arista we have interfaces that are split in lanes, without slot/pos/subpos identifiers.

Ethernet1
Ethernet2
Ethernet48/1
Ethernet48/2
Ethernet49/1
Ethernet49/2

The current rules sorts them as

Ethernet48/1
Ethernet48/2
Ethernet49/1
Ethernet49/2
Ethernet1
Ethernet2

Juniper interfaces get different prefixes depending on the speed

ge-0/0/0
xe-0/0/1
xe-0/0/2
ge-0/0/3

get sorted as

ge-0/0/0
ge-0/0/3
xe-0/0/1
xe-0/0/2

Netapp interfaces are even more difficult. they sometimes have a prefix 'e' and sometimes not, but the number is the way to sort

e9a
e9e
10a
10b
e11a
e11e

is sorted as

10a
10b
e9a
e9e
e11a
e11e

Database changes

No response

External dependencies

No response

Originally created by @PieterL75 on GitHub (Sep 12, 2025). ### NetBox version v4.2.9 ### Feature type Change to existing functionality ### Proposed functionality Interfaces are sorted according a specific interface naturalization function https://github.com/netbox-community/netbox/blob/cf0ef9226866223be6b54e791ea157ef849a340f/netbox/utilities/ordering.py#L51 This function suits very well for Cisco branded devices, but does not always work for other vendors. There has been few proposals (can only find this one https://github.com/netbox-community/netbox/issues/9368 ) to address this, but for now non has been accepted, I see few options - sort the interfaces manually. This can be done on the template, and then is automatically done in the devices. The devices would also need the option to move interfaces manually (for me the easiest and most flexible solution) - provide different sorting mechanisms, which can be applied per template/vendor/device; also allow plugins to extend these sorting mechanisms (very flexible solution, but the creation of a few general sorting algorithms) - update the current function to work different, based on interface names/models/vendors. ### Use case A recent poll in #netbox shows that there is a need for this: https://netdev-community.slack.com/archives/C01P0FRSXRV/p1757313471550629?thread_ts=1757065483.482359&cid=C01P0FRSXRV On Arista we have interfaces that are split in lanes, without slot/pos/subpos identifiers. ``` Ethernet1 Ethernet2 Ethernet48/1 Ethernet48/2 Ethernet49/1 Ethernet49/2 ``` The current rules sorts them as ``` Ethernet48/1 Ethernet48/2 Ethernet49/1 Ethernet49/2 Ethernet1 Ethernet2 ``` Juniper interfaces get different prefixes depending on the speed ``` ge-0/0/0 xe-0/0/1 xe-0/0/2 ge-0/0/3 ``` get sorted as ``` ge-0/0/0 ge-0/0/3 xe-0/0/1 xe-0/0/2 ``` Netapp interfaces are even more difficult. they sometimes have a prefix 'e' and sometimes not, but the number is the way to sort ``` e9a e9e 10a 10b e11a e11e ``` is sorted as ``` 10a 10b e9a e9e e11a e11e ``` ### Database changes _No response_ ### External dependencies _No response_
adam added the netbox label 2025-12-29 21:47:31 +01:00
adam closed this issue 2025-12-29 21:47:31 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 18, 2025):

I see few options

It sounds like you have several ideas, and need some help deciding which one to pursue and developing an implementation proposal. I'm going to convert this to a discussion. Once you've identified a direction and can provide a reasonably detailed proposal, please open a new feature request.

Please also be aware that we have several tests in place to validate the current behavior, and that invalidating any of these tests would be considered a break change by many users.

@jeremystretch commented on GitHub (Sep 18, 2025): > I see few options It sounds like you have several ideas, and need some help deciding which one to pursue and developing an implementation proposal. I'm going to convert this to a discussion. Once you've identified a direction and can provide a reasonably detailed proposal, please open a new feature request. Please also be aware that we have [several tests](https://github.com/netbox-community/netbox/blob/main/netbox/dcim/tests/test_natural_ordering.py) in place to validate the current behavior, and that invalidating any of these tests would be considered a break change by many users.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11602