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

Ability to synchronize reports & scripts from a remote data source #11890

Closed
jeremystretch opened this issue Mar 2, 2023 · 2 comments
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@jeremystretch
Copy link
Member

NetBox version

v3.4.5

Feature type

New functionality

Proposed functionality

NetBox has long supported custom scripts and reports as ways of enhancing its functionality. Currently, these are Python modules and scripts which must be uploaded to the configured storage system for use, and manually updated whenever changes are needed.

NetBox v3.5 introduces the ability to synchronize arbitrary data from a remote source (see #11558). This FR proposes leveraging this new ability to automatically update custom scripts and reports from an external source, such as a git repository.

I see two potential options for implementation:

Option A: Replication to files on disk

This is the more lightweight approach. One or more remote data sources could be designated (through a mechanism to be determined) as containing NetBox scripts or reports. The DataFiles produced from this source would be automatically replicated to the local storage backend within the REPORTS_ROOT or SCRIPTS_ROOT path as appropriate.

Option B: Create reports & scripts as database objects

This approach would be more involved, effectively changing the manner in which we manage scripts and reports. Rather than being stored as files on disk, each report and script module would exist as a database object. Replicating content from a DataFile would then follow the same pattern as we've implemented for config templates and other models. However, I'm not sure how feasible this approach is; further exploration is needed.

Use case

The ability to automatically update custom scripts and reports will obviate the need to apply changes manually to files on disk, and greatly simplify their administration.

Database changes

Option A as outlined above requires no changes to the database. Option B would entail replacing the "fake" Report and Script models under extras with concrete models with actual database tables.

External dependencies

None

@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Mar 2, 2023
@ryanmerolle
Copy link
Contributor

I propose this for milestone 3.5. Objections?

@pycolas
Copy link

pycolas commented Mar 5, 2023

Nice feature.
I would imagine something like in Ansible Tower : create the script entry in Netbox where you manage when it runs, who can run it, etc, and the source code stored in a git repository.
https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Mar 16, 2023
@jeremystretch jeremystretch added this to the v3.5 milestone Mar 16, 2023
@jeremystretch jeremystretch self-assigned this Mar 23, 2023
jeremystretch added a commit that referenced this issue Mar 23, 2023
jeremystretch added a commit that referenced this issue Mar 25, 2023
* Initial work on #11890

* Consolidate get_scripts() and get_reports() functions

* Introduce proxy models for script & report modules

* Add add/delete views for reports & scripts

* Add deletion links for modules

* Enable resolving scripts/reports from module class

* Remove get_modules() utility function

* Show results in report/script lists

* Misc cleanup

* Fix file uploads

* Support automatic migration for submodules

* Fix module child ordering

* Template cleanup

* Remove ManagedFile views

* Move is_script(), is_report() into extras.utils

* Fix URLs for nested reports & scripts

* Misc cleanup
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants