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

unexpected interface ordering behaviour #1173

Closed
bleything opened this issue May 12, 2017 · 5 comments
Closed

unexpected interface ordering behaviour #1173

bleything opened this issue May 12, 2017 · 5 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@bleything
Copy link
Contributor

Issue type: bug report

Python version: 2.7.5
NetBox version: v2.0.1

I've got switches that have ports named 1/g[1-48] and 1/xg[1-4]. No matter how I set the interface ordering, they always display in a specific order that doesn't make sense to me. On the device type page:

screenshot 2017-05-12 11 32 12

On a specific device page:

screenshot 2017-05-12 11 34 09

It's very possible that I am just misunderstanding how this is supposed to work... but I would expect the xgN interfaces to sort to the bottom in alphabetical mode, at the very least. And I'd expect the sorting to change when I change the interface ordering option. Aaaaaaaaand it's pretty weird that xg3 and xg4 sort differently on the device type page vs. the device page.

Is this an actual bug or am I just not understanding what's happening?

@jeremystretch jeremystretch added the type: bug A confirmed report of unexpected behavior in the application label May 12, 2017
@jeremystretch
Copy link
Member

This is happening because the intermingled alphabetic characters inside the numeric slot/position are not matched by the regexes we use for ordering. Only the leading "1" is being matched, so the interfaces are essentially unordered.

I'm going to tweak the ordering so that it uses the entire name field as a tiebreaker. This will result in a deterministic order for the names listed above, however it won't be perfect. For example, 1/g11 will be listed before 1/g2 because we're not able to cast the position as an independent integer.

@bleything
Copy link
Contributor Author

Ah, I guess I expected that when it was set to alphabetic, it would sort the entire string... but you're saying it's just a subset? What's the goal there?

@jeremystretch
Copy link
Member

@bleything The name is broken into segments so that we can CAST() and sort on integers to achieve a more natural ordering. Otherwise, we end up with things like:

  • ge-0/0/1
  • ge-0/0/10
  • ge-0/0/11
  • ge-0/0/2
  • ge-0/0/3

It's not a flawless approach but it's the best we have at the moment.

@bleything
Copy link
Contributor Author

Ah, got it! Thanks for the explanation. Totally makes sense; it's a complicated kind of thing to order.

@bleything
Copy link
Contributor Author

Oh, and thanks for the quick fix, too!

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 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants