Description
NetBox version
v4.1.7
Feature type
Change to existing functionality
Triage priority
I volunteer to perform this work (if approved)
Proposed functionality
The Event Rule condition only checks the objects data, not the value it had before. https://github.com/netbox-community/netbox/blob/develop/netbox/extras/events.py#L90. This proposal could save a lot of unnecessary Webhooks or Scripts, if the data, that the condition checks doesn't change.
Use case
I want to create a device 1x in an external application, if the device has status active.
- I create a device with status Planned.
- I update the device and set the status to active.
- I update the device and give it a description.
- I Update the device and set the status to Offline.
I create an Event Rule, on update
send a Webhook if the status of the device is active.
My Event Rule condition states:
{
"attr": "status.value",
"value": "active"
}
The event hook is sent on step 2 & 3. But on step 3 the webhook is executed unnecessary because the Device was created in step 2 in the external system.
Possible new condition syntax:
{
"and": [
{
"attr": "status.value",
"value": "active"
},
{
"attr": "snapshots.prechange.status.value",
"value": "snapshots.postchange.status.value",
"op": "eq",
"negate": true
}
]
}
or
{
"attr": "status.value",
"value": "active",
"changed": true
}
This rule should check if the status is active, and check if the value of the status has changed. Only if the status has been changed and set to active, the webhook is executed.
Database changes
None
External dependencies
None