- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Getting the next available subnet and reserving it
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-03-2018 04:03 PM
Hi,
I have seen examples of how to get the next available IP and reserve it. However I am looking for a way to get the next available network and reserve it/mark it as used with comments if possible.
I can obtain the next available subnet via the following API call
curl -k1 -u admin -X POST 'https://infoblox.local/wapi/v2.7/network network=func:nextavailablenetwork:172.16.0.0/24,29'
However I'm not sure how to then reserve that entire subnet.
Many thanks.]
Solved! Go to Solution.
Re: Getting the next available subnet and reserving it
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-03-2018 11:17 PM
Hi,
You can use the nextavailablenetwork function while creating a network, as shown below. This will create/reserve the network and add a comment to indicate that it is used.
curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.7/network?_return_fields%2B=network,comment&_return_as_object=1" -d '{"network": "func:nextavailablenetwork:192.0.0.0/8,default,24","comment": "Used"}'
Sample output:
{ "result": { "_ref": "network/ZG5zLm5ldHdvcmskMTkyLjAuNS4wLzI0LzA:192.0.5.0/24/default", "comment": "Used", "network": "192.0.5.0/24", "network_view": "default" } }
Hope this is what you are looking for.
Re: Getting the next available subnet and reserving it
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-19-2020 05:13 PM
curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.7/network?_return_fields%2B=network,comment&_return_as_object=1" -d '{"network": "func:nextavailablenetwork:192.0.0.0/8,default,24","comment": "Used","network_view":"default"}'
Just to clarify, network_view is required if you don't want it falling into the default view.
Re: Getting the next available subnet and reserving it
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2020 06:20 PM
Would it be possible to get a python example for the solution ?
I'm trying get next available subnet by using the code below but getting the error
#!/usr/bin/python3 import requests requests.packages.urllib3.disable_warnings() url = "https://11.1.1.1/wapi/v2.11/network?_return_fields%2B=network&_return_as_object=1" work_view":"default"} querystring = {"network":{"_object_function":"next_available_network","_result_field":"networks","_object":"network","_object_parameters":{},"_parameters":{"cidr":24}},"net work_view":"default"} response = requests.request("POST", url, auth=('cloud-api', 'cloud'), params=querystring,verify=False) print(response.text)
{ "Error": "AdmConProtoError: Unknown object type ()",
"code": "Client.Ibap.Proto",
"text": "Unknown object type ()"
}
Re: Getting the next available subnet and reserving it
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-22-2020 10:50 PM
Hi,
Could you please try the following code:
import requests requests.packages.urllib3.disable_warnings() # Disable SSL warnings in requests # url = "https://grid-master/wapi/v2.11/network?_return_fields%2B=network&_return_as_object=1" payload = "{\"network\":{\"_object_function\":\"next_available_network\",\"_result_field\":\"networks\",\"_object\":\"network\",\"_parameters\":{\"cidr\":24}},\"network_view\":\"default\"}" headers = {'content-type': "application/json"} response = requests.request("POST", url, auth=('cloud-api', 'cloud'), data=payload, headers=headers, verify=False)
Regards,
Krishna Vasudevan