[PR #16927] [MERGED] 15692: Introduce background jobs #14950

Closed
opened 2025-12-30 00:19:05 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/16927
Author: @alehaa
Created: 7/16/2024
Status: Merged
Merged: 7/30/2024
Merged by: @jeremystretch

Base: featureHead: 15692-background-jobs


📝 Commits (10+)

  • 5fab8e4 Introduce reusable BackgroundJob framework
  • 957bc3d Restore using import_string for jobs
  • db591d4 Use SyncDataSourceJob for management command
  • 53a4420 Implement BackgroundJob for running scripts
  • 7fb1875 Fix documentation of model features
  • 212262d Ensure consitent code style
  • 9dc6099 Introduce reusable ScheduledJob
  • 4880d81 Introduce reusable SystemJob
  • d78ddfc Add documentation for jobs framework
  • fd8d537 Merge branch 'feature' into 15692-background-jobs

📊 Changes

23 files changed (+597 additions, -314 deletions)

View changed files

📝 docs/development/models.md (+1 -1)
docs/plugins/development/background-jobs.md (+97 -0)
docs/plugins/development/background-tasks.md (+0 -30)
📝 docs/plugins/development/index.md (+1 -0)
📝 docs/plugins/development/models.md (+2 -0)
📝 mkdocs.yml (+1 -1)
📝 netbox/core/api/views.py (+7 -1)
📝 netbox/core/choices.py (+6 -0)
📝 netbox/core/jobs.py (+16 -16)
netbox/core/migrations/0012_job_object_type_optional.py (+24 -0)
📝 netbox/core/models/data.py (+1 -18)
📝 netbox/core/models/jobs.py (+25 -6)
📝 netbox/core/views.py (+7 -1)
📝 netbox/extras/api/views.py (+4 -5)
📝 netbox/extras/choices.py (+0 -29)
📝 netbox/extras/events.py (+3 -3)
netbox/extras/jobs.py (+107 -0)
📝 netbox/extras/management/commands/runscript.py (+26 -80)
📝 netbox/extras/scripts.py (+1 -119)
📝 netbox/extras/views.py (+3 -4)

...and 3 more files

📄 Description

Fixes: #15692

This PR includes three new background job class to be used in NetBox and by NetBox plugins. They handle the necessary logic for starting and stopping jobs, including exception handling and rescheduling of recurring jobs.

This PR also implements the use of this framework for existing data source and script jobs, eliminating duplicate code and ensuring consistency.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/16927 **Author:** [@alehaa](https://github.com/alehaa) **Created:** 7/16/2024 **Status:** ✅ Merged **Merged:** 7/30/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `15692-background-jobs` --- ### 📝 Commits (10+) - [`5fab8e4`](https://github.com/netbox-community/netbox/commit/5fab8e48396e050bdb0cfd4c6091c8d0a1dff53c) Introduce reusable BackgroundJob framework - [`957bc3d`](https://github.com/netbox-community/netbox/commit/957bc3d3de908722f3ce6d3ee7e4124021267f20) Restore using import_string for jobs - [`db591d4`](https://github.com/netbox-community/netbox/commit/db591d422a78c3cd292a84bf1759c0fe173d292d) Use SyncDataSourceJob for management command - [`53a4420`](https://github.com/netbox-community/netbox/commit/53a4420bc3c7a2c42f793c5f36c8f446928f1b0b) Implement BackgroundJob for running scripts - [`7fb1875`](https://github.com/netbox-community/netbox/commit/7fb1875c21623a0aca3ea0fba0b8318aa163fce0) Fix documentation of model features - [`212262d`](https://github.com/netbox-community/netbox/commit/212262dc7d16e8fcb8ecfa19a6a886da34b2a347) Ensure consitent code style - [`9dc6099`](https://github.com/netbox-community/netbox/commit/9dc6099eaf3be9c6e808610b93b060104bd4eec4) Introduce reusable ScheduledJob - [`4880d81`](https://github.com/netbox-community/netbox/commit/4880d8132e715021a2f17d0145e6323748f115bb) Introduce reusable SystemJob - [`d78ddfc`](https://github.com/netbox-community/netbox/commit/d78ddfcffb740ad982dd1dd2a75b42846e27c738) Add documentation for jobs framework - [`fd8d537`](https://github.com/netbox-community/netbox/commit/fd8d5378cf860901cc9d57fc8199333952b63ff7) Merge branch 'feature' into 15692-background-jobs ### 📊 Changes **23 files changed** (+597 additions, -314 deletions) <details> <summary>View changed files</summary> 📝 `docs/development/models.md` (+1 -1) ➕ `docs/plugins/development/background-jobs.md` (+97 -0) ➖ `docs/plugins/development/background-tasks.md` (+0 -30) 📝 `docs/plugins/development/index.md` (+1 -0) 📝 `docs/plugins/development/models.md` (+2 -0) 📝 `mkdocs.yml` (+1 -1) 📝 `netbox/core/api/views.py` (+7 -1) 📝 `netbox/core/choices.py` (+6 -0) 📝 `netbox/core/jobs.py` (+16 -16) ➕ `netbox/core/migrations/0012_job_object_type_optional.py` (+24 -0) 📝 `netbox/core/models/data.py` (+1 -18) 📝 `netbox/core/models/jobs.py` (+25 -6) 📝 `netbox/core/views.py` (+7 -1) 📝 `netbox/extras/api/views.py` (+4 -5) 📝 `netbox/extras/choices.py` (+0 -29) 📝 `netbox/extras/events.py` (+3 -3) ➕ `netbox/extras/jobs.py` (+107 -0) 📝 `netbox/extras/management/commands/runscript.py` (+26 -80) 📝 `netbox/extras/scripts.py` (+1 -119) 📝 `netbox/extras/views.py` (+3 -4) _...and 3 more files_ </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #15692 <!-- Please include a summary of the proposed changes below. --> This PR includes three new background job class to be used in NetBox and by NetBox plugins. They handle the necessary logic for starting and stopping jobs, including exception handling and rescheduling of recurring jobs. This PR also implements the use of this framework for existing data source and script jobs, eliminating duplicate code and ensuring consistency. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:19:05 +01:00
adam closed this issue 2025-12-30 00:19:05 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14950