feat: Integrate maintenance events with NetBox event system#20
Merged
1 commit merged intoJun 11, 2026
Merged
Conversation
- Register custom event types (maintenance_due, maintenance_scheduled, maintenance_completed) in NetBox registry - Implement core events module to dispatch events safely within/outside HTTP request contexts - Fire events automatically when a MaintenanceExecution is scheduled or completed - Add CheckMaintenanceJob and check_maintenance command to periodically detect overdue plans and fire events - Track last notified date on MaintenancePlan to prevent duplicate events - Implement filter forms for MaintenancePlan and MaintenanceExecution
Owner
|
Tested locally on a clean NetBox v4.6.2 instance (Docker, PostgreSQL 16) with the plugin installed from this branch — thanks @petersonbasso, the event system integration works well. Verification performed:
Two compatibility issues were found during testing; they are fixed in a follow-up commit that will be included in the merge:
Merging manually with the fixes included. |
diegogodoy06
approved these changes
Jun 11, 2026
2430107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request integrates the maintenance planner and execution tracking with NetBox's native event system. With this integration, users can configure Event Rules, Webhooks, custom Scripts and Notifications triggered by the lifecycle of maintenance plans and executions.
Key Features & Changes
maintenance_due,maintenance_scheduled, andmaintenance_completed) into the central NetBox registry (registry['event_types']) during the plugin initialization innetbox_maintenance_device/__init__.py.events.pywith a robustfire_eventhelper. It automatically handles enqueuing events in the current request queue (to respect database transaction commits) or immediately flushing events when executed outside the HTTP request cycle (e.g., from management commands or background system jobs).MaintenanceExecution.save()to automatically fire events:maintenance_scheduledwhen an execution is set to the Scheduled state.maintenance_completedwhen an execution is completed.last_notified_datefield to theMaintenancePlanmodel via migrations to track due date alerts.CheckMaintenanceJob(using@system_job) and a Django management commandcheck_maintenanceto periodically scan active plans, identify overdue schedules, and fire themaintenance_dueevent while avoiding duplicate notifications.MaintenancePlanFilterFormandMaintenanceExecutionFilterForminforms.pyto support UI search and filtering (by device, virtual machine, tags, active status, etc.).