Reply
Highlighted

Getting the next available subnet and reserving it

Techie
Posts: 4
2837     0

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.]

 

Highlighted

Re: Getting the next available subnet and reserving it

Adviser
Posts: 149
2838     0

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.

Highlighted

Re: Getting the next available subnet and reserving it

Techie
Posts: 6
2838     0
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.

Highlighted

Re: Getting the next available subnet and reserving it

Techie
Posts: 3
2838     0

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 ()"
}
Highlighted

Re: Getting the next available subnet and reserving it

Adviser
Posts: 149
2838     0

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

Showing results for 
Search instead for 
Did you mean: 

Recommended for You