Commit Graph

22 Commits

Author SHA1 Message Date
Jeremy Stretch
75417c9cd5 Closes #17587: Add release_track attribute to PluginConfig 2025-02-03 13:54:52 -05:00
Jeremy Stretch
3ee951b0d0 Fix missing/incorrect documentation links 2024-11-26 10:45:30 -05:00
Arthur Hanson
b9c6def8ab
15093 Allow plugins to register events pipeline (#17717)
* 15093 add events_pipeline registration to plugins

* 15093 use list

* 15093 add documentation

* Update docs/configuration/index.md

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* Update docs/configuration/miscellaneous.md

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* 15093 review changes

* 15093 review changes

* Formatting & readability

* 15093 review changes

* 15093 add test

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-10-18 12:47:16 -04:00
Alexander Haase
d3a3a6ba46
15692: Introduce background jobs (#16927)
* Introduce reusable BackgroundJob framework

A new abstract class can be used to implement job function classes. It
handles the necessary logic for starting and stopping jobs, including
exception handling and rescheduling of recurring jobs.

This commit also includes the migration of data source jobs to the new
framework.

* Restore using import_string for jobs

Using the 'import_string()' utility from Django allows the job script
class to be simplified, as module imports no longer need to avoid loops.
This should make it easier to queue and maintain jobs.

* Use SyncDataSourceJob for management command

Instead of maintaining two separate job execution logics, the same job
is now used for both background and interactive execution.

* Implement BackgroundJob for running scripts

The independent implementations of interactive and background script
execution have been merged into a single BackgroundJob implementation.

* Fix documentation of model features

* Ensure consitent code style

* Introduce reusable ScheduledJob

A new abstract class can be used to implement job function classes that
specialize in scheduling. These use the same logic as regular
BackgroundJobs, but ensure that they are only scheduled once at any given
time.

* Introduce reusable SystemJob

A new abstract class can be used to implement job function classes that
specialize in system background tasks (e.g. synchronization or
housekeeping). In addition to the features of the BackgroundJob and
ScheduledJob classes, these implement additional logic to not need to be
bound to an existing NetBox object and to setup job schedules on plugin
load instead of an interactive request.

* Add documentation for jobs framework

* Revert "Use SyncDataSourceJob for management"

This partially reverts commit db591d4. The 'run_now' parameter of
'enqueue()' remains, as its being used by following commits.

* Merge enqueued status into JobStatusChoices

* Fix logger for ScriptJob

* Remove job name for scripts

Because scripts are already linked through the Job Instance field, the
name is displayed twice. Removing this reduces redundancy and opens up
the possibility of simplifying the BackgroundJob framework in future
commits.

* Merge ScheduledJob into BackgroundJob

Instead of using separate classes, the logic of ScheduledJob is now
merged into the generic BackgroundJob class. This allows reusing the
same logic, but dynamically deciding whether to enqueue the same job
once or multiple times.

* Add name attribute for BackgroundJob

Instead of defining individual names on enqueue, BackgroundJob classes
can now set a job name in their meta class. This is equivalent to other
Django classes and NetBox scripts.

* Drop enqueue_sync_job() method from DataSource

* Import ScriptJob directly

* Relax requirement for Jobs to reference a specific object

* Rename 'run_now' arg on Job.enqueue() to 'immediate'

* Fix queue lookup in Job enqueue

* Collapse SystemJob into BackgroundJob

* Remove legacy JobResultStatusChoices

ChoiceSet was moved to core in 40572b5.

* Use queue 'low' for system jobs by default

System jobs usually perform low-priority background tasks and therefore
can use a different queue than 'default', which is used for regular jobs
related to specific objects.

* Add test cases for BackgroundJob handling

* Fix enqueue interval jobs

As the job's name is set by enqueue(), it must not be passed in handle()
to avoid duplicate kwargs with the same name.

* Honor schedule_at for job's enqueue_once

Not only can a job's interval change, but so can the time at which it is
scheduled to run. If a specific scheduled time is set, it will also be
checked against the current job schedule. If there are any changes, the
job is rescheduled with the new time.

* Switch BackgroundJob to regular methods

Instead of using a class method for run(), a regular method is used for
this purpose. This gives the possibility to add more convenience methods
in the future, e.g. for interacting with the job object or for logging,
as implemented for scripts.

* Fix background tasks documentation

* Test enqueue in combination with enqueue_once

* Rename background jobs to tasks (to differentiate from RQ)

* Touch up docs

* Revert "Use queue 'low' for system jobs by default"

This reverts commit b17b2050df.

* Remove system background job

This commit reverts commits 4880d81 and 0b15ecf. Using the database
'connection_created' signal for job registration feels a little wrong at
this point, as it would trigger registration very often. However, the
background job framework is prepared for this use case and can be used
by plugins once the auto-registration of jobs is solved.

* Fix runscript management command

Defining names for background jobs was disabled with fb75389. The
preceeding changes in 257976d did forget the management command.

* Use regular imports for ScriptJob

* Rename BackgroundJob to JobRunner

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-07-30 13:31:21 -04:00
Arthur Hanson
8d11f8aa7c
14121 update plugin development docs for pyproject.toml (#15952)
* 14121 update plugin development docs for pyproject.toml

* 14121 review feedback

* Update docs/plugins/development/index.md

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* 14121 remove setup.py references

* 14121 add cookiecutter reference

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-05-09 15:06:19 -04:00
Jeremy Stretch
46bd62fdc9 Merge branch 'develop' into feature 2024-04-22 13:23:42 -04:00
Jeff Gehlbach
f4c8f5f5b6 Add link to plugin certification program details in Plugin module of docs. Fixes #15769 2024-04-19 08:49:13 -04:00
Jeremy Stretch
7bedf48a97 Closes #14638: Drop support for Python 3.8 and 3.9 2024-01-03 13:33:00 -05:00
Jeremy Stretch
c1ff74894c #14036: Update import paths in example plugin code 2023-12-29 09:21:06 -05:00
Jeremy Stretch
30ce9edf1c
Closes #13381: Enable plugins to register custom data backends (#14095)
* Initial work on #13381

* Fix backend type display in table column

* Fix data source type choices during bulk edit

* Misc cleanup

* Move backend utils from core app to netbox

* Move backend type validation from serializer to model
2023-10-24 11:35:53 -04:00
jeremystretch
13afc52617 Closes #10543: Introduce get_plugin_config() utility function 2022-11-03 13:18:58 -04:00
Arthur Hanson
ffce5d968d
8927 plugin search (#10489)
* #7016 base search classes

* 7016 add search indexes

* 7016 add search indexes

* 7016 add search indexes

* 7016 add search indexes

* 7016 add search indexes

* 7016 add search indexes

* 8927 refactor search

* 8927 refactor search

* 8927 refactor search

* 8927 refactor search

* 8927 get search choices working

* 8927 cleanup - optimize

* 8927 use backend search function

* 8927 fix for plugin search

* 8927 add docs

* Move search app to a module under netbox/

* Utilize global registry to register model search classes

* Build search form options from registry

* Determine search categories from model app by default

* Enable dynamic search registration for plugins

* Update docs & improve plugin support

* Clean up search backend class

* Docs for #8927

Co-authored-by: jeremystretch <jstretch@ns1.com>
2022-10-10 14:00:59 -04:00
jeremystretch
c481a1b6a2 Merge branch 'develop' into feature 2022-10-05 10:28:48 -04:00
jeremystretch
cf062b5b6a Closes #10346: Document how to access plugin config parameters 2022-10-03 13:56:46 -04:00
jeremystretch
0607295081 Docs cleanup 2022-09-30 17:18:12 -04:00
Jonathan Senecal
d4a7af8a89 Update plugins development docs 2022-09-30 17:18:12 -04:00
jeremystretch
ed0c19807a Link to plugin tutorial in development docs 2022-03-18 13:43:58 -04:00
jeremystretch
6d05a4117a Update plugins documentation 2022-03-11 15:47:52 -05:00
jeremystretch
28f7b411ed Revise plugins documentation 2022-03-08 15:44:35 -05:00
jeremystretch
03ea257711 Initial work on GraphQL 2022-02-04 15:06:58 -05:00
jeremystretch
497afcc1e4 Rearrange plugins documentation 2022-01-25 13:53:31 -05:00
jeremystretch
dd55226455 Draft documentation for model features 2022-01-19 16:47:41 -05:00