- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Multiple IPs and Subnet Object Ref
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-25-2022 03:43 PM
The following Python code works to reserve the next available IP excluding a list of IPs (though I would prefer to use a range vs individual IPs).
What doesn't work is having it reserve\return multiple IPs. I believe I am adding the Num: parameter in the correct place, but it still only reserves 1.
I am also curious how this call might actually return the subnet ref object name, so I could use that to grab the router, dns, and other option info in a subesquent call.
Thanks for any help!
Code -
ibx_ip_request_url ...../record:host?_return_fields%2B=name,ipv4addrs
)
body={
'name': host_name,
'ipv4addrs':[{
'ipv4addr': {
'_object_function': 'next_available_ip',
'_parameters':{
'num': 5,
'exclude': exclude_ip,},
'_result_field': 'ips',
'_object' : 'network',
'_object_parameters':{
'network': request_subnet,}
}
}]
}
requests.post(ibx_ip_request_url, auth=(ibx_user, ibx_pass), json=body, headers=ibx_headers, verify=False
Re: Multiple IPs and Subnet Object Ref
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-31-2022 12:28 PM
It looks like you are trying to run the function against a Host object. "nextavailableip" is a function of the network object. And I believe the "exclude" parameter needs to be an array (list) of IP addresses. Regardless of how many IP addresses you request, the result should be an array (list) that looks like this:
ips: [
"1.1.1.1",
"1.1.1.2",
"1.1.13"
]
aRe: Multiple IPs and Subnet Object Ref
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-04-2022 09:37 AM
Thanks for the reply. I should have written it better. The script works for everything but getting multiple IPs. I'm passing in the host name, exclude list (which is a list of 20 IPs), requested subnet, wapi url and headers.
The primary question I have is where to put the "num" parameter to get more than one IP for a given host. In its current form I get no error and do get the next IP in the subnet after the exclusion list.
Examples of the objects I'm passing in for clarity
host_name = 'server01.domain.com'
exclude_ip = ['192.168.0.1','192.168.0.2']
network = '192.168.0.0/24'
Returns '192.168.0.3'
should return 192.168.0.3, - .7
Re: aRe: Multiple IPs and Subnet Object Ref
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-05-2022 07:50 AM
The 'num' should be part of the parameter, so your original code should work. The following curl command works for me (swap out xxxx with your network reference):
$ curl -k -u admin:infoblox -H 'Content-Type:application/json' -X POST \
'https://192.168.1.2/wapi/v2.10/network/xxxx?_function=next_available_ip&num=5'
{
"ips": [
"172.31.198.3",
"172.31.198.4",
"172.31.198.5",
"172.31.198.8",
"172.31.198.9"
]
}