-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Replace regex-based natural ordering of interfaces with a discrete field #3097
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
Comments
I've played around with this a bit and I think it will be doable, but I need to figure out how best to store the values. Ordering is by:
While it's possible to order on an array of numeric values, having the alphanumeric "type" value in the middle of the fields presents a problem. I'm also wondering if this is going down the wrong path, since ultimately we'll want to do something similar for other device components that may need different logic. |
The one thing I would still like to ask for is some way to control the ordering precedence. Right now, my biggest annoyance with Netbox is that it fouls up the ordering when dealing with the interfaces on my Cisco gear. This is because Cisco puts different interface types on the same subslot. As such, on my 3750Es, the ten gig interfaces are mixed into the middle of the GigabitEthernet, and a similar thing happens with the 3560s and so forth. If there was some way to adjust the ordering precedence, so that I could have Slot, Subslot, Type, Position, Subposition would make me a happy camper. |
I would also like to have control over the ordering... But should this be per device? In our company ( extreme edge case) we have lot of virtual interfaces on some devices named like P.S. Normally the prefix name of the virtual vlan interface is the same as the interface itself. Naming like |
I played around with using a PostgreSQL composite field in https://github.com/steffann/netbox/tree/3097-interface-ordering. I'm not completely happy with the dependency and its implementation, but it seems to work. |
@steffann That's an interesting approach! I have some reservations however about introducing new dependencies without fully mature migration support. Does it provide any significant benefit (other than convenience) over just adding the interface name part fields to the Interface model directly? |
Nope, just convenience and simple ordering ( |
This was implemented under #3799. |
Environment
Proposed Functionality
The current form of natural ordering for device interfaces was introduced in #2165. It employs a set of regular expressions evaluated at query time to determine the preferred order of rows being returned. This is generally not an issues when retrieving only the interfaces which belong to a particular device, however it imposes excessive delay when querying a large number of interfaces.
Now that the natural ordering logic is fairly mature, I'd like to ditch the regex-based ordering and instead save the ordering data in a dedicated field as an index on the Interface model. Logic similar to the regex currently in use will be evaluated when an object is being saved, and its output will be stored in the database. (A schema migration will take care of updating this field for all existing interfaces.)
The exact nature of the ordering data is yet to be determined.
Use Case
This approach will allow for much more efficient querying and greatly simplify the Interface manager.
Database Changes
External Dependencies
None
The text was updated successfully, but these errors were encountered: