Allow ReportResults to save/track and present a report file #2431

Closed
opened 2025-12-29 17:26:02 +01:00 by adam · 1 comment
Owner

Originally created by @Grokzen on GitHub (Mar 5, 2019).

Environment

  • Python version: 3.6.x
  • NetBox version: 2.5.7

Proposed Functionality & Use Case

The current reports is really good for people that sit and work inside Netbox on a regular basis as they can view them and act to solve any issues that you can detect through that solution. However this feature is not suited for people that is not tech savvy (managers for example), or a situation where you do not want to present the entire Netbox to a customer so you want to produce a kind of report or dump file that you can send to some other party.

The feature i propose is to add a new set of helper methods to the Report class that enables the author of the report to save a file inside Netbox and inside the json data blob of the ReportResult object instance. Then it this file would be served as a static file from inside Netbox. Example image below:

screenshot from 2019-03-05 14-11-59_2

Currently the only solution that is possible to write these dump/report files is to either make a separate script that either talks to the API or directly with the code through the management command or via direct code imports. But this is not optimal as the report code already exists and outputs/calculates all success/fail/warning/info messages and data, currently the code has to be duplicated in different forms to get a dump file out.

There currently is a post_run method implemented that could possibly help to server this case, but the only good option that can be used here is to either upload the file to some external service like a FTP or windows share or another linux server, or to send it out via e-mail on a scheduled basis. With this feature implemented you can avoid having to spam e-mail inboxes with dumps that people probably and eventually would filter out and remove/label as spam.

If accepted we have the majority of work already implemented in our fork to support this feature. There is a few main questions and possibly changes that would have to be fixed before a merge would be acceptable.

  • Should it be limited to a set of supported output formats? or be generic to save any type of output file. For example either implement these 2 methods write_csv_file/write_json_file or just simply implement write_file and let the user write anything.
  • Should it only allow to save one file or multiple files from each report method? Currently we only support one as each report method only outputs one set of data.

Database Changes

None as this data would be saved in the already existing json data blob of the report result.

External Dependencies

None

Originally created by @Grokzen on GitHub (Mar 5, 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.6.x <!-- Example: 3.5.4 --> * NetBox version: 2.5.7 <!-- Example: 2.3.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 & Use Case The current reports is really good for people that sit and work inside Netbox on a regular basis as they can view them and act to solve any issues that you can detect through that solution. However this feature is not suited for people that is not tech savvy (managers for example), or a situation where you do not want to present the entire Netbox to a customer so you want to produce a kind of report or dump file that you can send to some other party. The feature i propose is to add a new set of helper methods to the Report class that enables the author of the report to save a file inside Netbox and inside the json data blob of the ReportResult object instance. Then it this file would be served as a static file from inside Netbox. Example image below: ![screenshot from 2019-03-05 14-11-59_2](https://user-images.githubusercontent.com/892309/53807962-50ae1e80-3f51-11e9-8d19-1f040fb59f48.png) Currently the only solution that is possible to write these dump/report files is to either make a separate script that either talks to the API or directly with the code through the management command or via direct code imports. But this is not optimal as the report code already exists and outputs/calculates all success/fail/warning/info messages and data, currently the code has to be duplicated in different forms to get a dump file out. There currently is a `post_run` method implemented that could possibly help to server this case, but the only good option that can be used here is to either upload the file to some external service like a FTP or windows share or another linux server, or to send it out via e-mail on a scheduled basis. With this feature implemented you can avoid having to spam e-mail inboxes with dumps that people probably and eventually would filter out and remove/label as spam. If accepted we have the majority of work already implemented in our fork to support this feature. There is a few main questions and possibly changes that would have to be fixed before a merge would be acceptable. - Should it be limited to a set of supported output formats? or be generic to save any type of output file. For example either implement these 2 methods `write_csv_file/write_json_file` or just simply implement `write_file` and let the user write anything. - Should it only allow to save one file or multiple files from each report method? Currently we only support one as each report method only outputs one set of data. <!-- 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 as this data would be saved in the already existing json data blob of the report result. <!-- 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 closed this issue 2025-12-29 17:26:02 +01:00
Author
Owner

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

It's already possible to generate a file from a report; it just requires the author to handle everything manually. Also, with the recent introduction of custom scripts, there's a lot of overlap between scripts and reports. If the primary purpose of a report is to generate external content, it's probably better implemented as a custom script.

@jeremystretch commented on GitHub (Oct 15, 2019): It's already possible to generate a file from a report; it just requires the author to handle everything manually. Also, with the recent introduction of custom scripts, there's a lot of overlap between scripts and reports. If the primary purpose of a report is to generate external content, it's probably better implemented as a custom script.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2431