Reply

Using exclude with next_available_ip

RWiegand
Techie
Posts: 3
3878     1

This code works properly, so I'm using it as a starting point:

 

$curlcmd=$curl_base . $networkref;
$curl->setopt(CURLOPT_CUSTOMREQUEST, 'POST');
$curl->setopt(CURLOPT_URL, $curlcmd);
$curl->setopt(CURLOPT_POSTFIELDS, "_function=next_available_ip&num=3");
 
$networkref is a reference retrieved using a previous GET call. When I process this curl, I get the three IPs that I expect.
 
Next, I want to exclude specific IPs from the list. I tried setting this and it doesn't work:
 
$curl->setopt(CURLOPT_POSTFIELDS, "_function=next_available_ip&num=3&exclude=10.0.0.2");
 
I have also tried "exclude=(10.0.0.2)" or "exclude=('10.0.0.2')" and a couple other variants, but I'm not sure I'm doing it correctly. 

This is the error message that comes back:

 

$VAR1 = {
          'Error' => 'AdmConProtoError: List value expected for field: exclude',
          'text' => 'List value expected for field: exclude',
          'code' => 'Client.Ibap.Proto'
        };

Re: next_available_ip

user42
Techie
Posts: 35
3878     1
Hello, The function is named 'next_available_ip( )' and is part of the DHCP::Range object. This function can return the next available ipv4 address.Api documentation; https://ipam.illinois.edu/api/doc/Infoblox/DHCP/Range.html#next_available_ip___Best regards, Bregt

Re: Using exclude with next

Adviser
Posts: 63
3878     1

I also faced this kind of behaviour with curl and decided to Guzzle instead.

I published a little helper class on Github which should do the work, comments more than apreciated !

A small readme can be found at the repository's root.

Re: Using exclude with next

I-Team Employee
Employee
Posts: 186
3878     1

This looks like a bug. Can you file a ticket with support on it? 

Re: Using exclude with next

PLussier
Techie
Posts: 9
3878     1

Hi,

Has this been resolved ?  I'm trying to get this to work via the command line using curl and getting similar errors.  

I've tried the following:

 $ curl -k -u userSmiley Tongueasswd -X POST "https://192.168.1.1/wapi/v1.1/network/AbcDefGhiJklMnoPqrTuvWxyZ012345678901:192.168.20.0/23/default?...

curl: (3) [globbing] error: bad range specification after pos 145
 
{ "Error": "AdmConProtoError: List value expected for field: exclude", 
  "code": "Client.Ibap.Proto", 
  "text": "List value expected for field: exclude"
}
 
{ "Error": "AdmConProtoError: List value expected for field: exclude", 
  "code": "Client.Ibap.Proto", 
  "text": "List value expected for field: exclude"
}
 
{ "Error": "AdmConProtoError: List value expected for field: exclude", 
  "code": "Client.Ibap.Proto", 
  "text": "List value expected for field: exclude"
}

Also, is there some way to say "give me the next available IP after a certain one?  For example, we reserve the first 20 IPs for network gear and misc. temporary testing devices.  I'd really like to say _function=next_available_ip&starting_at=192.168.10.21 rather than having list all 20 IPs from .1-.20 in an exclude statement.

Thanks.

Re: Using exclude with next

RWiegand
Techie
Posts: 3
3878     1

Here's the solution I received from support:

 

Word back from the WAPI developers is that we needed to use json content-type in the URI header for the POST, and use the array-of-strings for the exclude parameter...

$ curl -k -u admin:infoblox -X GET https://10.64.41.6/wapi/v1.1/network?ipv4addr=10.144.2.0 [
{
"_ref": "network/ZG5zLm5ldHdvcmskMTAuMTQ0LjIuMC8yNC8w:10.144.2.0/24/default",
"comment": "PLCA McAllen TX",
"network": "10.144.2.0/24",
"network_view": "default"
}
]

$ curl -k -u admin:infoblox -X POST https://10.64.41.6/wapi/v1.1/network/ZG5zLm5ldHdvcmskMTAuMTQ0LjIuMC8yNC8... -H "Content-Type: application/json" -d '{"exclude": ["10.144.2.8", "10.144.2.10"], "num": 6}'
{
"ips": [
"10.144.2.2",
"10.144.2.3",
"10.144.2.9",
"10.144.2.11",
"10.144.2.12",
"10.144.2.16"
]
}

$ curl -k -u admin:infoblox -X POST https://10.64.41.6/wapi/v1.1/network/ZG5zLm5ldHdvcmskMTAuMTQ0LjIuMC8yNC8... -H "Content-Type: application/json" -d '{"exclude": ["10.144.2.11", "10.144.2.12"], "num": 6}'
{
"ips": [
"10.144.2.2",
"10.144.2.3",
"10.144.2.8",
"10.144.2.9",
"10.144.2.10",
"10.144.2.16"
]
}

Highlighted

Re: Using exclude with next

PLussier
Techie
Posts: 9
3878     1

Excellent! Thanks so much.

Any chance of getting a "start_at" parameter so we can just exclude an entire set of IPs below a specified number ?

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You