Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vary interface ordering depending on platform #284

Closed
cstueckrath opened this issue Jul 13, 2016 · 16 comments
Closed

Vary interface ordering depending on platform #284

cstueckrath opened this issue Jul 13, 2016 · 16 comments

Comments

@cstueckrath
Copy link

#248 helped with device bays, but there are other instances:

Racks (e.g. B1.0.[1-12])

Interfaces (e.g. INT[1-14], EXT[1-11], which leads to something like this:
EXT1
INT1
INT2
EXT2
EXT3
INT3
...)

@jeremystretch
Copy link
Member

When I create INT[1-3] and EXT[1-3] on a device, they are ordered as:

  • EXT1
  • INT1
  • EXT2
  • INT2
  • EXT3
  • INT3

This is due to how interfaces are ordered by their manager, sorting on the trailing numeric ID before the alphabetic type.

@Zanthras
Copy link
Contributor

For the simple case of just one integer field might it be worth sorting on sub-section A then B? Modular order usually does not apply when there isnt a module number (because its just a single integer field)

@bellwood
Copy link
Contributor

bellwood commented Jul 13, 2016

I'm having some issues as well:

Cisco switch

TenGigabitEthernet1/0/1
GigabitEthernet1/0/1
TenGigabitEthernet1/0/2
GigabitEthernet1/0/2
...

Another Cisco switch

...
 GigabitEthernet1/0/51    
 GigabitEthernet1/0/52  
 vlan1

An HP Switch

 vlan 1  
 interface 1
...

Another HP Switch

 interface 1      
 vlan 1  
 interface 2
...

Juniper Router

...
xe-1/0/0
xe-1/1/0
xe-1/2/0
xe-1/3/0
GigabitEthernet2/0/0
GigabitEthernet2/0/1
GigabitEthernet2/0/2
GigabitEthernet2/0/3
GigabitEthernet2/0/4
GigabitEthernet2/0/5
GigabitEthernet2/0/6
GigabitEthernet2/0/7
GigabitEthernet2/0/8
GigabitEthernet2/0/9
GigabitEthernet2/1/0
GigabitEthernet2/1/1
GigabitEthernet2/1/2
GigabitEthernet2/1/3
GigabitEthernet2/1/4
GigabitEthernet2/1/5
GigabitEthernet2/1/6
GigabitEthernet2/1/7
GigabitEthernet2/1/8
GigabitEthernet2/1/9
xe-2/2/0
xe-2/3/0
...

I would say for consistency sort alphabetically then numerically on the leading interface digit otherwise you end up with what I've got above

@ghost
Copy link

ghost commented Jul 15, 2016

can interfaces not be sorted wholly as a string? if they were, then all characters should sort as expected. that includes trailing numbers. this is a snippet of my virtual interfaces. they're not sorted this way in the menus (by last 4 digits), but, sorted alphabetically in a spreadsheet or other app, they end up as desired:

V01-0199
V01-0299
V01-0399
V01-0499
...
V01-1999
V01-2099
V02-0199
V02-0299
V02-0399
V02-0499
...
V02-1899
V02-1999
V02-2099

edit: even better, sort by name in the select statement, let the DB do the sorting work. that should return everything sorted alphabetically based on what i've seen in the DB.

@jeremystretch
Copy link
Member

can interfaces not be sorted wholly as a string?

This leads to chaos on some platforms. For instance, a Juniper switch might show

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

Hence the need to order on slot/number rather than by type.

It doesn't seem like there exists a one-size-fits-all solution, unfortunately. Maybe we need to implement a few different ordering options (e.g. Cisco style, Juniper style, etc.) and make it an option on the device type.

@bellwood
Copy link
Contributor

I'm actually OK with that Juniper example, all the ge interfaces come first followed by the xe interfaces

Ideally I don't want ge and xe mixing as the actual conf has them sorted out as you indicate above

Sorting of interfaces should be just as you'd see them on a switch config.

@jeremystretch
Copy link
Member

Sorting of interfaces should be just as you'd see them on a switch config.

I agree. Junos always sorts interfaces by slot and position, both in the configuration and in the output of show interfaces. It disregards interface type entirely because this can change (e.g. by using a different transceiver). NetBox replicates this ordering.

Cisco IOS, conversely, lists interfaces first by media type and then by slot/position. I can't think of any practical way to consolidate both strategies in a single function.

@bellwood
Copy link
Contributor

Maybe then as you stated we have different ones that can be tied to the devices' platform:

-Cisco IOS
-HP OS
-JunOS

...and so forth.

We'd have to ship with a few default platforms to match up with the associated sorting strategies.

This could also can-of-worms where in people will want to define their own sorting strategies (is that accomplishable?)

Just thinking the angles

@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application and removed discussion labels Jul 22, 2016
@jeremystretch jeremystretch changed the title still lexicographic sorting issues Vary interface ordering depending on platform Sep 28, 2016
@jeremystretch jeremystretch added roadmap and removed type: feature Introduction of new functionality to the application labels Nov 22, 2016
@jeremystretch
Copy link
Member

Per #373, it would be nice to add some capability to dynamically group interfaces by slot.

@jeremystretch
Copy link
Member

I've added an interface_ordering field to the DeviceType model, which allows for toggling the natural order of Interfaces (and InterfaceTemplates) per device type. The two options provided (by position and by name) seem sufficient, but if additional use cases arise we can handle them in a new issue.

@JNR8
Copy link

JNR8 commented Jan 25, 2017

After the 1.8.2 release I now get the otoin to toggle the Interface list using the tow options above, but this only works on the Device Type Page. The Actual device page doesn't take any notice of this and does not have an optoin to toggle the sort options.

@jeremystretch
Copy link
Member

@jennec The device view inherits interface ordering from its parent device type. This can be observed by creating, for example, interfaces named Gi0/[1-4] and Te0/[1-4] on a device. If the parent device type is configured to order interfaces by slot/position, the interfaces will appear intermingled; if it is configured to order alphabetically, all the Gi interfaces will be listed first, followed by all the Te interfaces. This is confirmed to be working on v1.8.2.

@JNR8
Copy link

JNR8 commented Jan 26, 2017

1
2

@jeremystretch That doesn't match up wtih my expirience. I have a switch setup with 54 ports. Each labeled similarly to "04 - 10GBE (SFP+)". The Switch Device Type is set for Alphabetical sorting. When viewing the interfaces from the Device Type page the interfaces are sorted in reverse order (which is OK). But when viewed from the Device page they are in, what seems like, a random order. Perhaps it's related to the way I've named the interfaces, but that doesn;t make sense when it works on the Device Type Page but not the Device page.

Is the sort order inherited, when changed, for existing Devices using that Device Type or will it only affect new Devices created using that Device Type?

(see attached screen shots)

@jeremystretch
Copy link
Member

You've appended the interface type to the name, which is evading the natural ordering logic. The interfaces should be named as they appear on the device; the interface form factor is maintained in a separate field. If you name the interfaces using only their numeric IDs (as they appear on the device), they will be sorted correctly.

@JNR8
Copy link

JNR8 commented Jan 26, 2017

I can appreciate the logic in that. But its competing against the sorting working correctly in the Device Type page but not on the Device itself. Are there differences between the two pages?

@jeremystretch
Copy link
Member

Since the ordering logic can't work with the names you've given the interfaces, the objects effectively aren't being ordered. This can result in non-deterministic behavior.

lampwins pushed a commit to lampwins/netbox that referenced this issue Oct 13, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants