Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

API & Integration, DevOps,NetOps,SecOps

Reply

Single REST call for creating a host object

Authority
Posts: 9
2834     0

I have to make a generic call to create a record:host in networks with and without DHCP ranges defined.

 

I can do it with 2 separate calls and error detection like:

 

newhostname=newhost.test

oldhostname=oldhost.test

 

# For network WITH DHCP

curl -s --negotiate -u : -H "Content-Type: application/json" -X POST "https://ibx/wapi/v2.10.3/request" -d '[{"method": "GET", "object": "network", "data": {"contains_address":"'"$(dig $oldhostname +short)"'"},"assign_state": {"netw_name": "network"},"discard": true},{"method": "GET", "object": "range", "data": {"network": "##STATE:netw_name:##"},"assign_state": {"range_ref": "_ref"},"discard": true,"enable_substitution": true},{"method": "POST", "object": "##STATE:range_ref:##", "args": {"_function": "next_available_ip"}, "data":{"num":1},"enable_substitution": true,"assign_state": {"next": "ips[0]"},"discard": false},{"method": "POST", "object": "record:host", "data": {"name": "'"$newhostname"'", "ipv4addrs": [{"ipv4addr": "##STATE:next:##"}]}, "enable_substitution": true}]'

 

#For network WITHOUT DHCP

curl -s --negotiate -u : -H "Content-Type: application/json" -X POST "https://ibx/wapi/v2.10.3/request" -d '[{"method": "GET", "object": "network","data": {"contains_address":"'"$(dig $oldhostname +short)"'"},"assign_state": {"netw_ref": "_ref"},"discard": true},{"method": "POST","object": "##STATE:netw_ref:##","args": {"_function": "next_available_ip"}, "data":{"num":1},"enable_substitution": true,"assign_state": {"next": "ips[0]"},"discard": false},{"method": "POST", "object": "record:host", "data": {"name": "'"$newhostname"'", "ipv4addrs": [{"ipv4addr": "##STATE:next:##"}]}, "enable_substitution": true}]'

 

 

 

So question is, how to combine those calls to pick next available IP on the network where given host exists and make a record:host for it?

Re: Single REST call for creating a host object

Community Manager
Community Manager
Posts: 180
2835     0

Is your intention to create the host within the range, when one exists, or to avoid the range?

 

If you want to avoid the range, the next_available_ip function will already do that for you.  No need to look up the range, just run the next_available_ip function against the network.

 

 

 

Re: Single REST call for creating a host object

Authority
Posts: 9
2835     0

Want to be within the range. Look up the host, provision another one next to it.

Re: Single REST call for creating a host object

New Member
Posts: 1
2835     0

Great post. Thanks for the information

Re: Single REST call for creating a host object

Member
Posts: 1
2835     0

Great Information.Thanks for sharing

Showing results for 
Search instead for 
Did you mean: 

Recommended for You