Replace DeviceComponentManager with NaturalOrderingManager to improve display order #2449

Closed
opened 2025-12-29 18:18:57 +01:00 by adam · 2 comments
Owner

Originally created by @tardoe on GitHub (Mar 11, 2019).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.7

Proposed Functionality

Replace the use of DeviceComponentManager in netbox/dcim/models.py with NaturalOrderingManager from the parent utilities/managers.py to better order display of device components.

Use Case

This would affect the way device bays, front/rear ports, power connections and console connections are displayed to the user. Given all of these will most likely have a numerical component to the name, we have an opportunity to reuse the work done in the NaturalOrderingManager to make the above model's ordering consistent with Site, Device etc. views.

Database Changes

None.

External Dependencies

None.

Originally created by @tardoe on GitHub (Mar 11, 2019). ### Environment * Python version: 3.5.2 * NetBox version: 2.5.7 ### Proposed Functionality Replace the use of DeviceComponentManager in netbox/dcim/models.py with NaturalOrderingManager from the parent utilities/managers.py to better order display of device components. ### Use Case This would affect the way device bays, front/rear ports, power connections and console connections are displayed to the user. Given all of these will most likely have a numerical component to the name, we have an opportunity to reuse the work done in the NaturalOrderingManager to make the above model's ordering consistent with Site, Device etc. views. ### Database Changes None. ### External Dependencies None.
adam added the status: acceptedtype: feature labels 2025-12-29 18:18:57 +01:00
adam closed this issue 2025-12-29 18:18:57 +01:00
Author
Owner

@DanSheps commented on GitHub (Mar 20, 2019):

DeviceComponentManager adjusts the sorting and enhances it to make the natural sorting better. Could you explain how the current DeviceComponentManager is insufficient for the need for ordering?

@DanSheps commented on GitHub (Mar 20, 2019): DeviceComponentManager adjusts the sorting and enhances it to make the natural sorting better. Could you explain how the current DeviceComponentManager is insufficient for the need for ordering?
Author
Owner

@tardoe commented on GitHub (Mar 21, 2019):

Thanks @DanSheps - I was going to extend on this but never got around to it.

For devices with Front/Rear ports - they tend to have the same naming characteristics as other device interfaces - that is, consecutive or patterned numerical names.

I patched my own installation such that RearPort and RearPortTemplate used the NaturalOrderingManager leaving FrontPort and FrontPortTemplate using the existing DeviceComponentManager - this was the result:

Screenshot 2019-03-21 10 21 24

Screenshot 2019-03-21 10 21 18

I also tested this functionality with another familiar DC patch panel naming scheme used by $globalDCProvider with similar results.
<city><number>:<level>:<function>:<cage>:<vertical>:<pair>

@tardoe commented on GitHub (Mar 21, 2019): Thanks @DanSheps - I was going to extend on this but never got around to it. For devices with Front/Rear ports - they tend to have the same naming characteristics as other device interfaces - that is, consecutive or patterned numerical names. I patched my own installation such that RearPort and RearPortTemplate used the NaturalOrderingManager leaving FrontPort and FrontPortTemplate using the existing DeviceComponentManager - this was the result: ![Screenshot 2019-03-21 10 21 24](https://user-images.githubusercontent.com/5331531/54725648-fbfeda80-4bc3-11e9-88dc-40a5f20f8757.png) ![Screenshot 2019-03-21 10 21 18](https://user-images.githubusercontent.com/5331531/54725653-03be7f00-4bc4-11e9-8fe1-76e41a4eeb63.png) I also tested this functionality with another familiar DC patch panel naming scheme used by $globalDCProvider with similar results. `<city><number>:<level>:<function>:<cage>:<vertical>:<pair>`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2449