Commit Graph

22 Commits

Author SHA1 Message Date
Arthur Hanson
ca63aed9ee
17061 add new models to docs (#17062)
* 17061 add new models to docs

* Reorder; remove CircuitGroupAssignment

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-08-02 10:00:51 -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
Jeremy Stretch
5b0b366b82 #9816: Promote IKE & IPSec proposals and policies to primary models 2023-12-04 09:28:29 -05:00
Jeremy Stretch
2ed261e9c2 Update developer model docs 2023-12-01 08:47:31 -05:00
Arthur Hanson
a38a38218b
14132 Add EventRule - change webhook and add in script processing to events (#14267)
---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2023-11-30 16:36:33 -05:00
jeremystretch
2c756873aa Fix broken links 2023-05-04 08:43:17 -04:00
Daniel Sheppard
9d709c84e7
Closes: #9047 - Add Provider Accounts (#12057)
* #9047 - ProviderAccount

* #9047 - Move to new selector types

* #9047 - Re-introduce provider FK to Circuit model

* #9047 - Fix broken tests

* Misc cleanup

* Revert errant change

* Fix tests

* Update circuit filter form

---------

Co-authored-by: jeremystretch <jstretch@netboxlabs.com>
2023-03-29 08:27:11 -04:00
jeremystretch
40572b543f Rename JobResult to Job and move to core 2023-03-27 14:20:13 -04:00
jeremystretch
574b5551a0 Clean up model & registry documentation 2023-02-19 20:09:52 -05:00
jeremystretch
4230162294 Add missing model documentation 2022-11-15 10:50:26 -05:00
jeremystretch
9059c09627 Refresh development docs 2022-08-18 13:40:44 -04:00
jeremystretch
f9fb2cc698 Finish features documentation 2022-08-11 15:29:26 -04:00
jeremystretch
9733cee3d2 Continued work on feature docs 2022-08-10 14:07:51 -04:00
jeremystretch
5da3cab4de Reorganize documentation 2022-08-04 14:11:52 -04:00
Daniel Sheppard
5b397a9827 Add docs 2022-06-30 08:29:08 -05:00
jeremystretch
806706ca1d Refresh development documentation 2021-12-15 16:31:06 -05:00
jeremystretch
fab1d3651b Add new models to developer docs 2021-11-05 13:10:27 -04:00
jeremystretch
cfb3897047 Add tags to organizational & nested group models 2021-10-21 10:51:02 -04:00
jeremystretch
036a068b83 Update extras documentation 2021-06-24 08:37:06 -04:00
Daniel Sheppard
744792452f
Closes: #5278 - Remove Secrets (#6397)
* Remove Secrets

* #5278: Remove secrets javascript from netbox core

* Remove userkey references

* Fix PEP8

* Remove a few more instances of secrets.  Rebundle

* Remove Secrets

Co-authored-by: checktheroads <matt@allroads.io>
2021-05-17 16:26:02 -04:00
jeremystretch
0fb8291b8b Documentation cleanup 2021-04-14 15:21:30 -04:00
jeremystretch
ea9e9d7273 Add the models index 2021-04-02 16:29:01 -04:00