netbox icon indicating copy to clipboard operation
netbox copied to clipboard

lexicographical sorting order of device bays

Open Zanthras opened this issue 10 years ago • 6 comments

Minor issue but slightly annoying. If I create say a blade chassis container and add device bays with the names Server[1-16]. It creates them as expected, but then displays the sort order in a technically correct, but unrealistic way. aka Server1, Server10, Server11... Server16, Server2.

Zanthras avatar Jul 08 '16 22:07 Zanthras

@jeremystretch this should have been ... sorted ... in #9 right?

bellwood avatar Jul 09 '16 00:07 bellwood

That fix only applied to interfaces and interface templates. We could use an additional, more generic natural sort manager for this sort of thing. The same problem applies to device names, console ports, etc.

jeremystretch avatar Jul 09 '16 03:07 jeremystretch

Merged #248 which should address this. Need to pip install natsort or run upgrade.sh.

jeremystretch avatar Jul 12 '16 18:07 jeremystretch

After updating today I still see that all Device interfaces I've created are ordered incorrectly. Seems very Random. Device Type Template Interfaces are ordered OK, but any devices created from them get a random sort. Does this fix apply to devices you've already created?

JNR8 avatar Jul 14 '16 16:07 JNR8

The same ordering is used for both Interfaces and InterfaceTemplates. This issue is only for natsorted objects; we don't use natsort on interfaces because they're ordered by position rather than by name.

jeremystretch avatar Jul 14 '16 16:07 jeremystretch

OK, so a different ordering for interfaces regardless of on the device or in a template. But Interfaces on a device template are sorted in reverse order and also in the order in which they were added. So for example if I add "[1-48]" followed by "Management" virtual interface followed by "[49-52]" then they appear in the imterface list in the order in which they were added. But if I create a device from that template the order is randomised (or so it seems), such as in the included screen shot.

[image: Inline images 1]

If you would prefer I could log this as a separate issue, so you can track it easier. I appreciate I have kind of hijacked this issue thread.

Chris Jenner Mob: 07739712218

On 14 July 2016 at 17:48, Jeremy Stretch [email protected] wrote:

The same ordering https://github.com/digitalocean/netbox/blob/develop/netbox/dcim/models.py#L98 is used for both Interfaces and InterfaceTemplates. This issue is only for natsorted objects; we don't use natsort on interfaces because they're ordered by position rather than by name.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/digitalocean/netbox/issues/243#issuecomment-232723543, or mute the thread https://github.com/notifications/unsubscribe/AEDGqXVmG4sDzHMATHGujhFmJ1oXpD59ks5qVmhTgaJpZM4JIdbW .

JNR8 avatar Jul 15 '16 11:07 JNR8