cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1295
Views
0
Helpful
3
Replies

How do I delete a netbox entry when I remove the service from a device?

RobinKhn
Level 1
Level 1

I have a python-and-template service which simply creates a loopback interface on a device. The IP-Address for the Loopback-Interface is taken from an IP-Address-Pool on netbox. So when I apply the service to a device, a new entry in the netbox database is created. But when I remove the service from the device with the 'no'-command, the entry in netbox is (of course) not deleted, which means the IP-Address is still shown as if it would've been in use. I do all of this in the cb_create method in the python script with the help of pynetbox, but is there a similar method like cb_delete for example when a service gets removed from a device? Because if there were such a method, it would be really easy then, because then I just could post my code for the removal of the netbox entry there.

 

So is there a way to automatically remove the netbox entry for when the service gets removed from the device? What I want to accomplish is basically the reverse of what I do in the cb_create method. There I reserve an IP-Address in netbox when a service is deployed, and when I remove that service I want to free that IP-Address again.

 

Any help would be greatly appreciated, best regards,

 

Robin

3 Replies 3

vleijon
Cisco Employee
Cisco Employee
For an external resource allocator like netbox you need to implement something like this example: https://github.com/NSO-developer/external-id-allocation

In a brownfield environment at some point you need to do service reconciliation. I wonder how this would be possible with such a allocation service. Do you think it might be possible to pass the current ID to the allocation service? Only in the event there is no current ID it should allocate one.

Yes, quite possible! The resource manager that is available as an NSO package already supports this pattern.
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: