- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Need som help with python and WAPI
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-18-2018 01:40 PM
Hey!
I'm creating some python functions to allocate next available network inside containers and have some problems getting it to work. Hopefully someone here can guide me.
The function i'm currently working with:
def create_network(): req_url = 'https://grid_ip/wapi/v2.7/networkcontainer/ZG...zA:10.124.12.0/22/default?_function=next_available_network&cidr=28&num=3' print(req_url) r = requests.post(url=req_url, auth=('user','pass'), verify=False) print(r) return r.json()
It seems to work since i get the following response:
<Response [200]> {'networks': ['10.124.12.0/28', '10.124.12.16/28', '10.124.12.32/28']}
But the container is still empty.
I have also tried the following with the same result:
def create_network(): req_url = 'https://grid_ip/wapi/v2.7/networkcontainer/ZG...zA:10.124.12.0/22/default?_function=next_available_network' post_data = {'cidr':28, 'num':3} print(req_url) r = requests.post(url=req_url, auth=('user','pass'), verify=False, data=json.dumps(post_data)) print(r) return r.json()
If i change the req_url to the following i get it to work:
https://grid_ip/wapi/v2.7/network?network=func:nextavailablenetwork:networkcontainer/ZG...zA:10.124.12.0/22/default,28
But that doesent really seem to match Infoblox API-documentation and i want to be able to create several networks in 1 POST and use this function for different network views. I have only been able to get func:nextavailbalenetwork to create in the default networ_view.
I have another Python function that searches the location of network containers and the result is used for the req_url. But when i use the following req_url with func:nextavailablenetwork the network is still created in network_view default:
https://grid_ip/wapi/v2.7/network?network=func:nextavailablenetwork:networkcontainer/ZG...8x:10.65.0.0/16/migrering,28
and the result:
network/ZG...zA:10.65.0.0/28/default'
I started with the Infoblox API today so my knowledge is very limited and i hope someone here can help me understand where i'm failing.
Solved! Go to Solution.

Re: Need som help with python and WAPI
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-18-2018 01:48 PM
Be sure to check out the Infoblox REST API Guide. You will find handy usage guidelines and examples for exactly what you are trying to do here. Most of the examples are using CURL, but can be adapted for other languages as well.
https://www.infoblox.com/wp-content/uploads/infoblox-deployment-infoblox-rest-api.pdf
Existing threads in the Infoblox community will also provide you with helpful examples. This includes:
https://community.infoblox.com/t5/Security/next-available-ip/m-p/920/
https://community.infoblox.com/t5/DNS-DHCP-IPAM/WAPI-Web-API-Sample-Code-for-NIOS/m-p/105