Skip to content

Conversation

@abates
Copy link
Contributor

@abates abates commented Feb 11, 2026

This request adds a method to slice lists of interfaces in order to facilitate provisioning. Sometimes upstream connections are placed within a given range of interfaces. For instance, a primary connection may always go in the range of Ethernet[1-24] and a secondary connection may go into Ethernet[25-48]. If a switch has all the interfaces Ethernet[1-48] available, then the two needed slices are returned. If a subset of needed interfaces are available, then only those interfaces in the subset are returned. For instance:

slice_interface_range(["Ethernet2", "Ethernet3", "Ethernet4", "Ethernet6", "Ethernet7", "Ethernet8"], "Ethernet1", "Ethernet5")

will effectively produce:

["Ethernet2", "Ethernet3", "Ethernet4"], ["Ethernet6", "Ethernet7", "Ethernet8"]

Comment on lines +467 to +468
up to (but not including) the next cut point. The final slice contains all
remaining interface names from the last cut point to the end of the sorted list. This
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me, but in my mind should also be extended to start. Having to always define the first element (Ethernet1 in tests below) seems off to me.

I could understand either both start and end needing to be explicit or neither being explicit, but start being explicit and end being implicit is a bit confusing to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants