-
Hey everybody! So I'm trying to make use of NetBox to integrate configuration into my environment., to do this I'm using webhook and a Flask listener. What I'm trying to understand , is there a way to prompt Like let's say a user is adding a VLAN is to the NetBox and a webhook is triggered and a script is ran by the flask and let's say that it didn't work and the flask failed for some reason , like wrong Tag or something or one device didn't work. I can prompt a HTTP response by the Flask but is there a way for a user in the NetBox to see it ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Webhooks are queued and asynchronous, so Netbox will have returned to the next page already. You can see the results in Admin > Background tasks, but the admin section is only visible to "Staff" users. Alternatively, your webhook receiver could make a call back to the Netbox REST API to update some object, like setting a comment field on the relevant VLAN object. |
Beta Was this translation helpful? Give feedback.
Yes: your custom script can make outgoing connections (e.g. using requests or napalm), and it can use the Django ORM to make changes within Netbox. If it fails, then the database transaction will be rolled back, but it would be up to you to undo any changes you've already made in your external network.
You should beware that your processing shouldn't take too long, or you'll exceed the webserver timeout (and/or your users may navigate away). That was the reason for webhooks being converted to background tasks in the first place.
TBH, a background workflow with a state machine is a safer way of doing updates to your live network. You can divide the work into multiple steps; retry steps tha…