Reply

Curl - Get Next Available IP

New Member
Posts: 1
2755     0

Hello,

 

We would like to use script to get the next available IP from a subnet "192.168.1.1". From the refernece guide, the script should be:

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://gridmaster/wapi/v2.11/network/ZG5zLm5ldHdvcmskMTcyLjIxLjEwLjAvMjQvMA:172.21.10.0/24/default?...
=next_available_ip&_return_as_object=1" -d '{"num":1}'

 

I know "ZG5zLm5ldHdvcmskMTcyLjIxLjEwLjAvMjQvMA:1921.168.1.1/24/default" is the object reference of the subnet 192.168.1.1.

 

However, how I can get this object reference and then pass as parameter to the above command? 

 

Great if anyone can share the sample for this.

 

Thanks.

 

Raymond.

 

 

 

Re: Curl - Get Next Available IP

Adviser
Posts: 181
2756     0

Hi,

 

You can combine multiple WAPI calls to achieve your requirement using the /request handler:

curl -X POST 'https://grid-master/wapi/v2.11/request' \
-k -u uname:pwd \
-H 'Content-Type: application/json' \
-d '[
    {
		"method": "GET",
		"object": "network",
        "data":
        {
            "network":"192.168.1.1/24"
        },
        "assign_state": 
		{
			"network_ref": "_ref"
		},
        "discard": true
	},
    {
		"method": "POST",
		"object": "##STATE:network_ref:##",
		"args": 
		{
			"_function": "next_available_ip"
		},
		"enable_substitution": true
    }
]'

Regards,

Krishna

Showing results for 
Search instead for 
Did you mean: 

Recommended for You