mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00

* 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 commitdb591d4
. 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 in40572b5
. * 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 commitb17b2050df
. * Remove system background job This commit reverts commits4880d81
and0b15ecf
. 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 withfb75389
. The preceeding changes in257976d
did forget the management command. * Use regular imports for ScriptJob * Rename BackgroundJob to JobRunner --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
328 lines
15 KiB
YAML
328 lines
15 KiB
YAML
site_name: NetBox Documentation
|
|
site_dir: netbox/project-static/docs
|
|
site_url: https://docs.netbox.dev/
|
|
repo_name: netbox-community/netbox
|
|
repo_url: https://github.com/netbox-community/netbox
|
|
theme:
|
|
name: material
|
|
custom_dir: docs/_theme/
|
|
icon:
|
|
repo: fontawesome/brands/github
|
|
features:
|
|
- content.code.copy
|
|
- navigation.footer
|
|
palette:
|
|
- media: "(prefers-color-scheme: light)"
|
|
scheme: default
|
|
toggle:
|
|
icon: material/lightbulb-outline
|
|
name: Switch to Dark Mode
|
|
- media: "(prefers-color-scheme: dark)"
|
|
scheme: slate
|
|
toggle:
|
|
icon: material/lightbulb
|
|
name: Switch to Light Mode
|
|
plugins:
|
|
- search:
|
|
lang: en
|
|
- mkdocstrings:
|
|
handlers:
|
|
python:
|
|
setup_commands:
|
|
- import os
|
|
- import django
|
|
- os.chdir('netbox/')
|
|
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "netbox.settings")
|
|
- django.setup()
|
|
options:
|
|
heading_level: 3
|
|
members_order: source
|
|
show_root_heading: true
|
|
show_root_full_path: false
|
|
show_root_toc_entry: false
|
|
show_source: false
|
|
extra:
|
|
build_public: !ENV BUILD_PUBLIC
|
|
social:
|
|
- icon: fontawesome/brands/github
|
|
link: https://github.com/netbox-community/netbox
|
|
- icon: fontawesome/brands/slack
|
|
link: https://netdev.chat/
|
|
extra_css:
|
|
- extra.css
|
|
markdown_extensions:
|
|
- admonition
|
|
- attr_list
|
|
- footnotes
|
|
- pymdownx.emoji:
|
|
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
|
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
|
- pymdownx.superfences:
|
|
custom_fences:
|
|
- name: mermaid
|
|
class: mermaid
|
|
format: !!python/name:pymdownx.superfences.fence_code_format
|
|
- pymdownx.tabbed:
|
|
alternate_style: true
|
|
nav:
|
|
- Introduction: 'introduction.md'
|
|
- Features:
|
|
- Facilities: 'features/facilities.md'
|
|
- Devices & Cabling: 'features/devices-cabling.md'
|
|
- Power Tracking: 'features/power-tracking.md'
|
|
- IPAM: 'features/ipam.md'
|
|
- VLAN Management: 'features/vlan-management.md'
|
|
- L2VPN & Overlay: 'features/l2vpn-overlay.md'
|
|
- Circuits: 'features/circuits.md'
|
|
- Wireless: 'features/wireless.md'
|
|
- Virtualization: 'features/virtualization.md'
|
|
- VPN Tunnels: 'features/vpn-tunnels.md'
|
|
- Tenancy: 'features/tenancy.md'
|
|
- Contacts: 'features/contacts.md'
|
|
- Search: 'features/search.md'
|
|
- Context Data: 'features/context-data.md'
|
|
- Configuration Rendering: 'features/configuration-rendering.md'
|
|
- Synchronized Data: 'features/synchronized-data.md'
|
|
- Change Logging: 'features/change-logging.md'
|
|
- Journaling: 'features/journaling.md'
|
|
- Event Rules: 'features/event-rules.md'
|
|
- Background Jobs: 'features/background-jobs.md'
|
|
- Auth & Permissions: 'features/authentication-permissions.md'
|
|
- API & Integration: 'features/api-integration.md'
|
|
- Customization: 'features/customization.md'
|
|
- Installation & Upgrade:
|
|
- Installing NetBox: 'installation/index.md'
|
|
- 1. PostgreSQL: 'installation/1-postgresql.md'
|
|
- 2. Redis: 'installation/2-redis.md'
|
|
- 3. NetBox: 'installation/3-netbox.md'
|
|
- 4a. Gunicorn: 'installation/4a-gunicorn.md'
|
|
- 4b. uWSGI: 'installation/4b-uwsgi.md'
|
|
- 5. HTTP Server: 'installation/5-http-server.md'
|
|
- 6. LDAP (Optional): 'installation/6-ldap.md'
|
|
- Upgrading NetBox: 'installation/upgrading.md'
|
|
- Getting Started:
|
|
- Planning: 'getting-started/planning.md'
|
|
- Populating Data: 'getting-started/populating-data.md'
|
|
- Configuration:
|
|
- Configuring NetBox: 'configuration/index.md'
|
|
- Required Parameters: 'configuration/required-parameters.md'
|
|
- System: 'configuration/system.md'
|
|
- Security: 'configuration/security.md'
|
|
- Remote Authentication: 'configuration/remote-authentication.md'
|
|
- Data & Validation: 'configuration/data-validation.md'
|
|
- Default Values: 'configuration/default-values.md'
|
|
- Error Reporting: 'configuration/error-reporting.md'
|
|
- Plugins: 'configuration/plugins.md'
|
|
- Miscellaneous: 'configuration/miscellaneous.md'
|
|
- Development: 'configuration/development.md'
|
|
- Customization:
|
|
- Custom Fields: 'customization/custom-fields.md'
|
|
- Custom Links: 'customization/custom-links.md'
|
|
- Custom Validation: 'customization/custom-validation.md'
|
|
- Export Templates: 'customization/export-templates.md'
|
|
- Reports: 'customization/reports.md'
|
|
- Custom Scripts: 'customization/custom-scripts.md'
|
|
- Integrations:
|
|
- REST API: 'integrations/rest-api.md'
|
|
- GraphQL API: 'integrations/graphql-api.md'
|
|
- Webhooks: 'integrations/webhooks.md'
|
|
- Synchronized Data: 'integrations/synchronized-data.md'
|
|
- Prometheus Metrics: 'integrations/prometheus-metrics.md'
|
|
- Plugins:
|
|
- About Plugins: 'plugins/index.md'
|
|
- Installing a Plugin: 'plugins/installation.md'
|
|
- Removing a Plugin: 'plugins/removal.md'
|
|
- Developing Plugins:
|
|
- Getting Started: 'plugins/development/index.md'
|
|
- Models: 'plugins/development/models.md'
|
|
- Views: 'plugins/development/views.md'
|
|
- Navigation: 'plugins/development/navigation.md'
|
|
- Templates: 'plugins/development/templates.md'
|
|
- Tables: 'plugins/development/tables.md'
|
|
- Forms: 'plugins/development/forms.md'
|
|
- Filters & Filter Sets: 'plugins/development/filtersets.md'
|
|
- Search: 'plugins/development/search.md'
|
|
- Events: 'plugins/development/events.md'
|
|
- Data Backends: 'plugins/development/data-backends.md'
|
|
- REST API: 'plugins/development/rest-api.md'
|
|
- GraphQL API: 'plugins/development/graphql-api.md'
|
|
- Background Jobs: 'plugins/development/background-jobs.md'
|
|
- Dashboard Widgets: 'plugins/development/dashboard-widgets.md'
|
|
- Staged Changes: 'plugins/development/staged-changes.md'
|
|
- Exceptions: 'plugins/development/exceptions.md'
|
|
- Migrating to v4.0: 'plugins/development/migration-v4.md'
|
|
- Administration:
|
|
- Authentication:
|
|
- Overview: 'administration/authentication/overview.md'
|
|
- Microsoft Azure AD: 'administration/authentication/microsoft-azure-ad.md'
|
|
- Okta: 'administration/authentication/okta.md'
|
|
- Permissions: 'administration/permissions.md'
|
|
- Error Reporting: 'administration/error-reporting.md'
|
|
- Housekeeping: 'administration/housekeeping.md'
|
|
- Replicating NetBox: 'administration/replicating-netbox.md'
|
|
- NetBox Shell: 'administration/netbox-shell.md'
|
|
- Data Model:
|
|
- Circuits:
|
|
- Circuit: 'models/circuits/circuit.md'
|
|
- CircuitGroup: 'models/circuits/circuitgroup.md'
|
|
- CircuitGroupAssignment: 'models/circuits/circuitgroupassignment.md'
|
|
- Circuit Termination: 'models/circuits/circuittermination.md'
|
|
- Circuit Type: 'models/circuits/circuittype.md'
|
|
- Provider: 'models/circuits/provider.md'
|
|
- Provider Account: 'models/circuits/provideraccount.md'
|
|
- Provider Network: 'models/circuits/providernetwork.md'
|
|
- Core:
|
|
- DataFile: 'models/core/datafile.md'
|
|
- DataSource: 'models/core/datasource.md'
|
|
- Job: 'models/core/job.md'
|
|
- DCIM:
|
|
- Cable: 'models/dcim/cable.md'
|
|
- ConsolePort: 'models/dcim/consoleport.md'
|
|
- ConsolePortTemplate: 'models/dcim/consoleporttemplate.md'
|
|
- ConsoleServerPort: 'models/dcim/consoleserverport.md'
|
|
- ConsoleServerPortTemplate: 'models/dcim/consoleserverporttemplate.md'
|
|
- Device: 'models/dcim/device.md'
|
|
- DeviceBay: 'models/dcim/devicebay.md'
|
|
- DeviceBayTemplate: 'models/dcim/devicebaytemplate.md'
|
|
- DeviceRole: 'models/dcim/devicerole.md'
|
|
- DeviceType: 'models/dcim/devicetype.md'
|
|
- FrontPort: 'models/dcim/frontport.md'
|
|
- FrontPortTemplate: 'models/dcim/frontporttemplate.md'
|
|
- Interface: 'models/dcim/interface.md'
|
|
- InterfaceTemplate: 'models/dcim/interfacetemplate.md'
|
|
- InventoryItem: 'models/dcim/inventoryitem.md'
|
|
- InventoryItemRole: 'models/dcim/inventoryitemrole.md'
|
|
- InventoryItemTemplate: 'models/dcim/inventoryitemtemplate.md'
|
|
- Location: 'models/dcim/location.md'
|
|
- Manufacturer: 'models/dcim/manufacturer.md'
|
|
- Module: 'models/dcim/module.md'
|
|
- ModuleBay: 'models/dcim/modulebay.md'
|
|
- ModuleBayTemplate: 'models/dcim/modulebaytemplate.md'
|
|
- ModuleType: 'models/dcim/moduletype.md'
|
|
- Platform: 'models/dcim/platform.md'
|
|
- PowerFeed: 'models/dcim/powerfeed.md'
|
|
- PowerOutlet: 'models/dcim/poweroutlet.md'
|
|
- PowerOutletTemplate: 'models/dcim/poweroutlettemplate.md'
|
|
- PowerPanel: 'models/dcim/powerpanel.md'
|
|
- PowerPort: 'models/dcim/powerport.md'
|
|
- PowerPortTemplate: 'models/dcim/powerporttemplate.md'
|
|
- Rack: 'models/dcim/rack.md'
|
|
- RackReservation: 'models/dcim/rackreservation.md'
|
|
- RackRole: 'models/dcim/rackrole.md'
|
|
- RackType: 'models/dcim/racktype.md'
|
|
- RearPort: 'models/dcim/rearport.md'
|
|
- RearPortTemplate: 'models/dcim/rearporttemplate.md'
|
|
- Region: 'models/dcim/region.md'
|
|
- Site: 'models/dcim/site.md'
|
|
- SiteGroup: 'models/dcim/sitegroup.md'
|
|
- VirtualChassis: 'models/dcim/virtualchassis.md'
|
|
- VirtualDeviceContext: 'models/dcim/virtualdevicecontext.md'
|
|
- Extras:
|
|
- Bookmark: 'models/extras/bookmark.md'
|
|
- Branch: 'models/extras/branch.md'
|
|
- ConfigContext: 'models/extras/configcontext.md'
|
|
- ConfigTemplate: 'models/extras/configtemplate.md'
|
|
- CustomField: 'models/extras/customfield.md'
|
|
- CustomFieldChoiceSet: 'models/extras/customfieldchoiceset.md'
|
|
- CustomLink: 'models/extras/customlink.md'
|
|
- EventRule: 'models/extras/eventrule.md'
|
|
- ExportTemplate: 'models/extras/exporttemplate.md'
|
|
- ImageAttachment: 'models/extras/imageattachment.md'
|
|
- JournalEntry: 'models/extras/journalentry.md'
|
|
- Notification: 'models/extras/notification.md'
|
|
- NotificationGroup: 'models/extras/notificationgroup.md'
|
|
- SavedFilter: 'models/extras/savedfilter.md'
|
|
- StagedChange: 'models/extras/stagedchange.md'
|
|
- Subscription: 'models/extras/subscription.md'
|
|
- Tag: 'models/extras/tag.md'
|
|
- Webhook: 'models/extras/webhook.md'
|
|
- IPAM:
|
|
- ASN: 'models/ipam/asn.md'
|
|
- ASNRange: 'models/ipam/asnrange.md'
|
|
- Aggregate: 'models/ipam/aggregate.md'
|
|
- FHRPGroup: 'models/ipam/fhrpgroup.md'
|
|
- FHRPGroupAssignment: 'models/ipam/fhrpgroupassignment.md'
|
|
- IPAddress: 'models/ipam/ipaddress.md'
|
|
- IPRange: 'models/ipam/iprange.md'
|
|
- Prefix: 'models/ipam/prefix.md'
|
|
- RIR: 'models/ipam/rir.md'
|
|
- Role: 'models/ipam/role.md'
|
|
- RouteTarget: 'models/ipam/routetarget.md'
|
|
- Service: 'models/ipam/service.md'
|
|
- ServiceTemplate: 'models/ipam/servicetemplate.md'
|
|
- VLAN: 'models/ipam/vlan.md'
|
|
- VLANGroup: 'models/ipam/vlangroup.md'
|
|
- VRF: 'models/ipam/vrf.md'
|
|
- Tenancy:
|
|
- Contact: 'models/tenancy/contact.md'
|
|
- ContactGroup: 'models/tenancy/contactgroup.md'
|
|
- ContactRole: 'models/tenancy/contactrole.md'
|
|
- Tenant: 'models/tenancy/tenant.md'
|
|
- TenantGroup: 'models/tenancy/tenantgroup.md'
|
|
- Virtualization:
|
|
- Cluster: 'models/virtualization/cluster.md'
|
|
- ClusterGroup: 'models/virtualization/clustergroup.md'
|
|
- ClusterType: 'models/virtualization/clustertype.md'
|
|
- VMInterface: 'models/virtualization/vminterface.md'
|
|
- VirtualDisk: 'models/virtualization/virtualdisk.md'
|
|
- VirtualMachine: 'models/virtualization/virtualmachine.md'
|
|
- VPN:
|
|
- IKEPolicy: 'models/vpn/ikepolicy.md'
|
|
- IKEProposal: 'models/vpn/ikeproposal.md'
|
|
- IPSecPolicy: 'models/vpn/ipsecpolicy.md'
|
|
- IPSecProfile: 'models/vpn/ipsecprofile.md'
|
|
- IPSecProposal: 'models/vpn/ipsecproposal.md'
|
|
- L2VPN: 'models/vpn/l2vpn.md'
|
|
- L2VPNTermination: 'models/vpn/l2vpntermination.md'
|
|
- Tunnel: 'models/vpn/tunnel.md'
|
|
- TunnelGroup: 'models/vpn/tunnelgroup.md'
|
|
- TunnelTermination: 'models/vpn/tunneltermination.md'
|
|
- Wireless:
|
|
- WirelessLAN: 'models/wireless/wirelesslan.md'
|
|
- WirelessLANGroup: 'models/wireless/wirelesslangroup.md'
|
|
- WirelessLink: 'models/wireless/wirelesslink.md'
|
|
- Reference:
|
|
- Filtering: 'reference/filtering.md'
|
|
- Conditions: 'reference/conditions.md'
|
|
- Markdown: 'reference/markdown.md'
|
|
- Development:
|
|
- Introduction: 'development/index.md'
|
|
- Getting Started: 'development/getting-started.md'
|
|
- Style Guide: 'development/style-guide.md'
|
|
- Models: 'development/models.md'
|
|
- Adding Models: 'development/adding-models.md'
|
|
- Extending Models: 'development/extending-models.md'
|
|
- Signals: 'development/signals.md'
|
|
- Search: 'development/search.md'
|
|
- Application Registry: 'development/application-registry.md'
|
|
- User Preferences: 'development/user-preferences.md'
|
|
- Web UI: 'development/web-ui.md'
|
|
- Internationalization: 'development/internationalization.md'
|
|
- Translations: 'development/translations.md'
|
|
- Release Checklist: 'development/release-checklist.md'
|
|
- git Cheat Sheet: 'development/git-cheat-sheet.md'
|
|
- Release Notes:
|
|
- Summary: 'release-notes/index.md'
|
|
- Version 4.1: 'release-notes/version-4.1.md'
|
|
- Version 4.0: 'release-notes/version-4.0.md'
|
|
- Version 3.7: 'release-notes/version-3.7.md'
|
|
- Version 3.6: 'release-notes/version-3.6.md'
|
|
- Version 3.5: 'release-notes/version-3.5.md'
|
|
- Version 3.4: 'release-notes/version-3.4.md'
|
|
- Version 3.3: 'release-notes/version-3.3.md'
|
|
- Version 3.2: 'release-notes/version-3.2.md'
|
|
- Version 3.1: 'release-notes/version-3.1.md'
|
|
- Version 3.0: 'release-notes/version-3.0.md'
|
|
- Version 2.11: 'release-notes/version-2.11.md'
|
|
- Version 2.10: 'release-notes/version-2.10.md'
|
|
- Version 2.9: 'release-notes/version-2.9.md'
|
|
- Version 2.8: 'release-notes/version-2.8.md'
|
|
- Version 2.7: 'release-notes/version-2.7.md'
|
|
- Version 2.6: 'release-notes/version-2.6.md'
|
|
- Version 2.5: 'release-notes/version-2.5.md'
|
|
- Version 2.4: 'release-notes/version-2.4.md'
|
|
- Version 2.3: 'release-notes/version-2.3.md'
|
|
- Version 2.2: 'release-notes/version-2.2.md'
|
|
- Version 2.1: 'release-notes/version-2.1.md'
|
|
- Version 2.0: 'release-notes/version-2.0.md'
|