Reply

Single REST call for creating a host object

hobz
Techie
Posts: 7
190     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

Adviser
Posts: 96
191     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

hobz
Techie
Posts: 7
191     0

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

tRe: Single REST call for creating a host object

[ Edited ]
brashetreysha
Techie
Posts: 2
191     0

am looking for that Speed Test Scrabble Word Finder Solitaire

Showing results for 
Search instead for 
Do you mean 

Recommended for You