Make the value of commit available in custom scripts #3396

Closed
opened 2025-12-29 18:28:42 +01:00 by adam · 2 comments
Owner

Originally created by @benjy44 on GitHub (Feb 24, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.5.1
  • NetBox version: 2.7.7

Proposed Functionality

Make the status of commit (True/False) available so it's possible to know if part of a script not directly tied to NetBox should be run or not.

Use Case

I have a script to create VMs in a certain way and I use it to update a text file that contains the IPs of the newly created VMs for external use.
While the script and the file is generated properly, I don't want my file to be updated if the VMs are not actually created, ie: when commit=False.

As a workaround proposed by @steffann I can use if '_commit' in self.request.POST which works fine but a cleaner way would be better.

Database Changes

Don't think so

External Dependencies

none

Originally created by @benjy44 on GitHub (Feb 24, 2020). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. 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.5.1 * NetBox version: 2.7.7 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Make the status of commit (True/False) available so it's possible to know if part of a script not directly tied to NetBox should be run or not. <!-- 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 I have a script to create VMs in a certain way and I use it to update a text file that contains the IPs of the newly created VMs for external use. While the script and the file is generated properly, I don't want my file to be updated if the VMs are not actually created, ie: when commit=False. As a workaround proposed by @steffann I can use `if '_commit' in self.request.POST` which works fine but a cleaner way would be better. <!-- 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 Don't think so <!-- 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:28:42 +01:00
adam closed this issue 2025-12-29 18:28:42 +01:00
Author
Owner

@samk-acw commented on GitHub (Feb 25, 2020):

Being able to hide/disable the commit checkbox would also be nice for scripts that don't make any changes (which is essential what reports are, but I believe the custom scripts feature is ultimately meant to replace reports)

@samk-acw commented on GitHub (Feb 25, 2020): Being able to hide/disable the commit checkbox would also be nice for scripts that don't make any changes (which is essential what reports are, but I believe the custom scripts feature is ultimately meant to replace reports)
Author
Owner

@jeremystretch commented on GitHub (Feb 25, 2020):

Implemented in 5000f7f8

@jeremystretch commented on GitHub (Feb 25, 2020): Implemented in 5000f7f8
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3396