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

Some questions regarding function nextavailableip in WAPI
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-31-2016 01:31 AM
Dear all,
We are automatization our infrastructure deployments with ansible. One of the steps is asign an IP and DNS hostname to the server and we are using the Infoblox WAPI for this (we created a custom ansible module for this: ansible-module-infoblox).
In a firts iteration we try to use the IP as a part of the hostname pattern (ip-10-1-1-1.internal). In this point we noticed that we can't use the function nextavailableip directly to create a host as follow:
POST /wapi/v1.2/record:host Content-Type: application/json { "name":"¿?¿?¿?¿?", "ipv4addrs":[ { "ipv4addr":"func:nextavailableip:10.1.1.0/24" } ] }
In a second iteration we create a fixed address reservation to know before the host creation the IP assigned in order to generate the desired hostname:
POST /wapi/v1.2/record:host Content-Type: application/json { "name":"temporal", "ipv4addrs":[ { "ipv4addr":"func:nextavailableip:10.1.1.0/24", "mac":"aa:bb:cc:11:22:21" } ] }
And then create the hostname:
POST /wapi/v1.2/record:host Content-Type: application/json { "name":"ip-10-1-1-100.internal", "ipv4addrs":[ { "ipv4addr":"10.1.1.100" } ] }
In this way we found some funky behaivors:
- We have to delete manually the fixedaddress reservation after host creation to avoid unecessary objects
- When we create a fixed address reservation service restart is required before apply all changes
- If we deploy simultaniously hundreds of devices how the nextavailableip function will work. The WAPI's requests are secuential? If not, the nextavailableip have some tipe of protection to avoid lease the same API two times?
What should be the correct workflow to create hosts whith hostname pattern like: ip-10-1-1-1.internal with the nextavailableip function?
Thanks!
Solved! Go to Solution.

Re: Some questions regarding function nextavailableip in WAPI
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-31-2016 07:05 AM
the /request object lets you chain a sequence of wapi calls and avoid some next-ip collisions. But it wont help you in this case because you need to format a custom hostname based on the ip address, which can only be done with the api client script.
so, you just have to make 2 calls, and can do this in 2 ways
A)
call /network?_function=nextavailableip , get the next ip address
call /record:host creating a hostname based on the result of the nextip call
B)
call /record:host with ipv4addr:func:nextavailableip, but use a temp hostname
call /record:host/_ref... To get the host with the address
edit the host to change the hostname based on the address
this is just your second iteration, but you dont need to create the fixed address or restart dhcp services
and you use the returned _ref to locate the host you just created
..
the first option is cleaner, but risks next address collisions
the second option requires a unique temp hostname to avoid name collisions
Re: Some questions regarding function nextavailableip in WAPI
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-31-2016 11:44 PM
Hi GHorne,
I'll try as follow:
POST https://.../record:host?_return_fields=ipv4addrs Content-Type: application/json { "name": "temporalhostname", "ipv4addrs": [ { "ipv4addr": "func:nextavailableip:10.1.1.0/24" } ] }
This returns the host _ref and the ipvaddrs assigned. Then:
PUT https://.../<_ref> Content-Type: application/json { "name": "ip-10-1-1-100.env" }