SSO Login is being implemented on this site. Existing users: Your existing password must be reset the first time you login using SSO. Click here to reset your password first before login. Your new username will be your email.

API & Integration, DevOps,NetOps,SecOps

Reply

Multiple IPs and Subnet Object Ref

Member
Posts: 2
299     1

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

Authority
Posts: 17
300     1

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

Member
Posts: 2
300     1

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

Authority
Posts: 17
300     1

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"
  ]
}

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin