THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

Delete a network container and reparent the subnets with WAPI

[ Edited ]
New Member
Posts: 1
3889     0

 

I'm doing some automation around around splitting networks into smaller networks and one of the requirements is to delete the network container and reparent the subnets that were in that container. I've found some documentation around deleting network containers but nothing about the options available. Does anyone know what the params are required to reparent subnets?

def delete_networkcontainer(self, networkcontainer):
"""
Implements IBA REST API call to delete DHCP network container object
:param networkcontainer: network container in CIDR format
"""
rest_url = 'https://' + self.iba_host + '/wapi/v' + self.iba_wapi_version + '/networkcontainer?network=' + networkcontainer + '&network_view=' + self.iba_network_view
try:
r = requests.get(url=rest_url, auth=(self.iba_user, self.iba_password), verify=self.iba_verify_ssl)
r_json = r.json()
if r.status_code == 200:
if len(r_json) > 0:
network_ref = r_json[0]['_ref']
if network_ref:
rest_url = 'https://' + self.iba_host + '/wapi/v' + self.iba_wapi_version + '/' + network_ref
r = requests.delete(url=rest_url, auth=(self.iba_user, self.iba_password),
verify=self.iba_verify_ssl)
if r.status_code == 200:
return
else:
if 'text' in r_json:
raise InfobloxGeneralException(r_json['text'])
else:
r.raise_for_status()
else:
raise InfobloxGeneralException(
"No network container reference received in IBA reply for network container: " + networkcontainer)
else:
raise InfobloxNotFoundException("No network container found: " + networkcontainer)
else:
if 'text' in r_json:
raise InfobloxGeneralException(r_json['text'])
else:
r.raise_for_status()
except ValueError:
raise Exception(r)
except Exception:
raise

 

Re: Delete a network container and reparent the subnets with WAPI

Adviser
Posts: 181
3890     0

Hi,

 

You can use the remove_subnets aguments available with the network container DELETE operation. This will retain the networks within the container.

 

Below is a sample curl call:

curl -k -u admin:infoblox -H 'content-type: application/json' -X DELETE "https://grid-master/wapi/v2.10/networkcontainer/ZG5zLm5ldHdvcmtfY29udGFpbmVyJDEwLjAuMC4wLzgvMA:10.0.0.0/8/default?remove_subnets=false"

You need to change your URL to:

rest_url = 'https://' + self.iba_host + '/wapi/v' + self.iba_wapi_version + '/' + network_ref + '?remove_subnets=false'

Hope this helps,

Krishna

Showing results for 
Search instead for 
Did you mean: 

Recommended for You