- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Delete a network container and reparent the subnets with WAPI
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2020 01:46 PM - edited 07-24-2020 01:47 PM
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
Solved! Go to Solution.
Re: Delete a network container and reparent the subnets with WAPI
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020 06:01 AM
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