Problem:
You have to make a few API calls to gather this information. First, you have to make an API call to return the container to get the “_ref” and then a 2nd to query “get the network”.
Solution:
We are going to use Infoblox WAPI’s “/request”, this object allows you to make more than one API calls and pass data between HTTP methods (GET, PUT, DELETE and POST).
Docs Note:
https://[gm]/wapidoc/objects/request.html
First API call:
We are looking for a “Network Container” with an “Extensible Attribute” equal to “RED” (hopefully there is just one).
curl -X GET \ ‘https://[gm]/wapi/v2.7/networkcontainer?_return_fields+=extattrs&*Country:=RED‘ \
First Results:
[
{
“_ref”: “networkcontainer/ZG5zLm5ldHdvcmtfY29udGFpbmVyJDEwLjAuMC4wLzE2LzQ1:10.0.0.0/16/Dell”,
“extattrs”: {
“Country”: {
“value”: “RED”
},
“Paul EA”: {
“value”: “A”
}
},
“network”: “10.0.0.0/16“,
“network_view”: “Dell”
}
]
Second API call:
Now that we have some useful information we can use that to form the 2nd API call
Going to get the next available network /24 passing the “network” and “network view” from the previous call and update the comment with Used
curl -X POST \
‘https://[gm]/wapi/v2.7/network?_return_fields+=network,comment&_return_as_object=1&_return_fields%2B=network,comment’ \
-H ‘content-type: application/json’ \
-d ‘{
“network”: “func:nextavailablenetwork:172.16.0.0/16,Dell,24″,
“network_view”: “Dell”,
“comment”: “Used”
}’
Second Results:
{
“result”: {
“_ref”: “network/ZG5zLm5ldHdvcmskMTcyLjE2LjUuMC8yNC80NQ:172.16.5.0/24/Dell”,
“comment”: “Used“,
“network”: “172.16.5.0/24“,
“network_view”: “Dell”
}
}
Request Call:
Now let’s look at using Request to create our own Automation process
First call in the request is a “GET” for the object “networkcontainer”, passing in the data points “network_view” is “Dell” and EA “*Country” equals to “RED” asking to return “Extensible Attributes”
curl -X POST \ https://[gm]/wapi/v2.7/request \ -d '[ { "method": "GET", "object": "networkcontainer", "data": { "network_view": "Dell", "*Country": "RED" }, "args": { "_return_fields+": "extattrs" }, "assign_state": { "net_ref": "network", "net_view": "network_view" } }, "discard": true }, { "method": "POST", "object": "network", "enable_substitution": true, "data": { "network": "func:nextavailablenetwork:##STATE:net_ref:##,##STATE:sif_view:##,24", "network_view": "##STATE:sif_view:##", "comment": "Used" } } ]
Request Results:
[
“network/ZG5zLm5ldHdvcmskMTAuMC4zMC4wLzI0LzQ1:10.0.30.0/24/Dell”
]