Infoblox Exchange Cybersecurity Roadshow 2020 – Join us!
North America | Europe | Middle East/Africa | Asia-Pacific

API & Integration

Reply
Accepted Solution

Some questions regarding function nextavailableip in WAPI

xoanmi
Techie
Posts: 7
3858     0

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:

  1. We have to delete manually the fixedaddress reservation after host creation to avoid unecessary objects
  2. When we create a fixed address reservation service restart is required before apply all changes
  3. 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!

Re: Some questions regarding function nextavailableip in WAPI

GHorne Community Manager
Community Manager
Posts: 248
3859     0

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

xoanmi
Techie
Posts: 7
3859     0

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"
}

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You