11-22-2017 05:58 AM - edited 11-22-2017 05:59 AM
Is there a easy/fast way to delete all records related to a network when deleting the network itself?
When we close a site, we need to cleanup all related IPAM data. So containers, networks, DHCP scopes and all records + discovered data. This all works as expected for the networks and DHCP scopes when deleting a container. But all records and discovered data remain.
The only way to do a cleanup I found was fetching all IPs from all networks for that site where the status is USED and then delete every single IP one by one which also cleans out all PTR, A and host records. Because we assigning /18 subnets to a site, this leaves us with about 8191 (=50% of 16382) IPs to delete which takes ages to complete.
I would expect this to be an option when deleting a network, instead of having to do such things manually...
11-27-2017 10:02 AM
DNS data belongs to the DNS zone, and would not automatically be remove from the DHCP network when the DHCP network is removed.
Caution should be used, because some records (such as host objects) may contain addresses in this network and other networks not being deleted.
You could script this by searching for all addresses within a network, which will also return any records associated with each address:
curl -k -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v1.2/ipv4address' -d 'network=172.16.16.0/24'
When that list is returned, you would then loop throught each IP address and remove any appropriate records.
11-27-2017 11:21 PM
Well, what you describe is the way I do it now. But as indicated, that very slow.
I was wondering if there is a better way. Because, from an IPAM point of view, if you delete a subnet, all related things should go away. The way it works now leaves you with a lot of potentially stale records.
09-18-2018 09:24 AM
Facing the same issue here, and I agree that it's not very convenient...
One solution is to find every host belonging to the network you want to delete and send a `/request` query with `"method": "DELETE"` and a `"_ref"` pointing at each host you want to delete. Still it will require to make multiple queries to the API for what should be a simple deletion, in addition to ask for some data processing before creating the request body, but it looks like it's the best we could do