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

Add custom scripting #3423

Merged
merged 33 commits into from
Aug 26, 2019
Merged

Add custom scripting #3423

merged 33 commits into from
Aug 26, 2019

Conversation

jeremystretch
Copy link
Member

Closes: #3415

Introduces the ability to run arbitrary custom scripts with data provided via the NetBox UI

@lampwins
Copy link
Contributor

I am really liking this. In my testing I found a couple of things:

  • We should gracefully handle a script failing to import. Currently, the dynamic import logic has no error handling, which results in generic 500 responses. E.g., failing to from extras.scripts import Script :)
  • Changelog entries (and presumably webhooks) are being generated regardless of the DB transaction commit state. I fear this will not be easy to overcome, given our fancy object change middleware.
  • In the spirit of the changelog, I wonder if it would be worth creating a new type of change in the changelog to allow logging that a script was run. This would allow the changelog request ID to be tracked back to a script execution event. Given my thoughts on the previous item, I am not sure how feasible this would be to implement.
  • Several of the models that users are likely to interact with use slug fields, so I was thinking it might be nice to add a slug boolean argument to the StringVar that uses a prebuilt and consistent regex value.
  • Along those same lines, we may also want to support a JSONVar to make handling of potential Config Context data easier.
  • I noticed the ObjectVar does not use the Select2 widget. This will surely become a pain point for users, but I admit the logic to make this happen is not likely to be trivial.
  • I also see a use case for a static choice variable type. This can be used to mimic static choice fields in NetBox core, but also for use case specific choice limiting.
  • I find the UI to be a bit inconsistent due to the fact we use bootstrap pannels for all other forms.

In all though, I am very excited about the prospects of this feature. Well done @jeremystretch!

@jeremystretch
Copy link
Member Author

Changelog entries (and presumably webhooks) are being generated regardless of the DB transaction commit state.

Good catch! This should be fixed in 9a9660a. I've introduced a new signal that can be used to purge cached changes to be logged. It's still a bit hacky at the moment, since deletion ObjectChanges are currently written immediately rather than cached, but I think I have a better approach for that as well (out of scope for this PR).

@jeremystretch jeremystretch merged commit 03ac272 into develop Aug 26, 2019
@jeremystretch jeremystretch deleted the 3415-custom-scripts branch August 26, 2019 18:06
@lock lock bot locked as resolved and limited conversation to collaborators Jan 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support custom scripts for automatically manipulating objects
3 participants