Improve interfaces templates: allow word expansion #2964

Closed
opened 2025-12-29 18:24:06 +01:00 by adam · 5 comments
Owner

Originally created by @fser on GitHub (Oct 18, 2019).

Environment

  • Python version: 3.7
  • NetBox version: 2.6.6

Proposed Functionality

In the template interface, allow user to expand names. For example Interface/[FRONT|BACK]/Eth[1-10] would produce:

Interface/FRONT/Eth1
Interface/FRONT/Eth2
Interface/FRONT/Eth3
Interface/FRONT/Eth4
Interface/FRONT/Eth5
Interface/FRONT/Eth6
Interface/FRONT/Eth7
Interface/FRONT/Eth8
Interface/FRONT/Eth9
Interface/FRONT/Eth10
Interface/BACK/Eth1
Interface/BACK/Eth2
Interface/BACK/Eth3
Interface/BACK/Eth4
Interface/BACK/Eth5
Interface/BACK/Eth6
Interface/BACK/Eth7
Interface/BACK/Eth8
Interface/BACK/Eth9
Interface/BACK/Eth10

Use Case

We need such expansion pattern for our device templates. Maybe others do as well!

Database Changes

None

External Dependencies

None

Originally created by @fser on GitHub (Oct 18, 2019). <!-- NOTE: This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7 * NetBox version: 2.6.6 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality In the template interface, allow user to expand names. For example `Interface/[FRONT|BACK]/Eth[1-10]` would produce: ``` Interface/FRONT/Eth1 Interface/FRONT/Eth2 Interface/FRONT/Eth3 Interface/FRONT/Eth4 Interface/FRONT/Eth5 Interface/FRONT/Eth6 Interface/FRONT/Eth7 Interface/FRONT/Eth8 Interface/FRONT/Eth9 Interface/FRONT/Eth10 Interface/BACK/Eth1 Interface/BACK/Eth2 Interface/BACK/Eth3 Interface/BACK/Eth4 Interface/BACK/Eth5 Interface/BACK/Eth6 Interface/BACK/Eth7 Interface/BACK/Eth8 Interface/BACK/Eth9 Interface/BACK/Eth10 ``` <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case We need such expansion pattern for our device templates. Maybe others do as well! <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes None <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 18:24:06 +01:00
adam closed this issue 2025-12-29 18:24:06 +01:00
Author
Owner

@kobayashi commented on GitHub (Oct 20, 2019):

Thank you for opening this issue.
Could you let me know what kind of devices have both front/back interface?

@kobayashi commented on GitHub (Oct 20, 2019): Thank you for opening this issue. Could you let me know what kind of devices have both front/back interface?
Author
Owner

@fser commented on GitHub (Oct 21, 2019):

Hello,

from my understanding, mostly patch panels.

@fser commented on GitHub (Oct 21, 2019): Hello, from my understanding, mostly patch panels.
Author
Owner

@DanSheps commented on GitHub (Oct 21, 2019):

Are you using interfaces or front/rear ports?

@DanSheps commented on GitHub (Oct 21, 2019): Are you using interfaces or front/rear ports?
Author
Owner

@jeremystretch commented on GitHub (Oct 23, 2019):

Two thoughts. First, we should stick to comma-delimited values since that's the current convention. Second, we should be able to tweak parse_alphanumeric_range() to simply ignore values which don't specify a range and pass them through.

@jeremystretch commented on GitHub (Oct 23, 2019): Two thoughts. First, we should stick to comma-delimited values since that's the current convention. Second, we should be able to tweak `parse_alphanumeric_range()` to simply ignore values which don't specify a range and pass them through.
Author
Owner

@fser commented on GitHub (Oct 24, 2019):

Sorry for the delay!
@DanSheps : I asked my colleague, and he told me he uses interfaces because the "front/back" thing didn't exist at the time when they created the template. Does that answer your question?

@jeremystretch : I tried to tweak it using commas (by the way, why does the regex allow so many delimiter [?:,-] if only the coma is valid?) but I couldn't identify the case where expansion was required instead of enumeration. See my PR if that can be relevant.

Thanks anyway for the interest!

@fser commented on GitHub (Oct 24, 2019): Sorry for the delay! @DanSheps : I asked my colleague, and he told me he uses interfaces because the "front/back" thing didn't exist at the time when they created the template. Does that answer your question? @jeremystretch : I tried to tweak it using commas (by the way, why does the regex allow so many delimiter `[?:,-]` if only the coma is valid?) but I couldn't identify the case where expansion was required instead of enumeration. See my PR if that can be relevant. Thanks anyway for the interest!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2964