THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

exclude list for GET next_available_ip?

Authority
Posts: 7
2725     1

In Avoid reserved IPs when using 'get next available IP'  we learned we can send the POST method an exclusion list.  Is it possible to do the same with the GET method?  We want to get an IP address, ping it and maybe check for any EAs that it has before reserving it. So far what we have tried has not worked and we haven't found any documention that lists the exclude list (geven for the POST method which definitely works). Anyone know where we can find complete documetion would also help! Thanks!  //Russ

 

curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.8/request' -H "Content-Type: application/json" -d \
'[{
  "method":"POST",
  "object":"fixedaddress",
  "data": {
    "name": "host001",
    "comment": "This is a comment for Host 001",
    "mac": "AB:CD:00:11:22:33",
    "ipv4addr": {
      "_object_function": "next_available_ip",
      "_object": "network",
      "_object_parameters": {"network": "10.102.0.0/16"},
      "_result_field": "ips",
      "_parameters": {"exclude": ["10.102.0.1","10.102.0.2","10.102.0.3"]}
	  },
    "extattrs":{"Commit ID":{"value":"10124"}}
    }
  }
]'

Re: exclude list for GET next_available_ip?

Moderator
Moderator
Posts: 315
2725     1

Only the POST method can be used for function calls.

 

If you don't want to create a fixed address, you can run the function against an existing network _ref.  Just the address (or addresses) is returned, nothing is created.  Please note, this does not reserve the IP address, it simply returns the next available address.  A repeat call would return the same address.   It will not be reserved until an object is created with that address.

This example uses a multi-body request.  First body gets the network's _ref and the second body posts with the function call to return an address.

 

curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.11/request' -H "Content-Type: application/json" -d \
'[
  {
    "method":"GET",
    "object":"network",
    "data": {
  		"network": "10.20.30.0/24"
  	},
  	"assign_state": {"my_ref": "_ref" },
    "enable_substitution": true,
    "discard": true
  },
  {
    "method":"POST",
	"object": "##STATE:my_ref:##",
	"enable_substitution": true,
    "args":{"_function":"next_available_ip"}
  }
]'

returns a list of IP addresses.  Unless a num is specified, only one address is returned.

[
    {
        "ips": [
            "10.20.30.12"
        ]
    }
]

If you need multiple addreses returned, and/or need to exclude a list of addresses, use the data field in the post.

curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.11/request' -H "Content-Type: application/json" -d \
'[
  {
    "method":"GET",
    "object":"network",
    "data": {
  		"network": "10.20.30.0/24"
  	},
  	"assign_state": {"my_ref": "_ref" },
    "enable_substitution": true,
    "discard": true
  },
  {
    "method":"POST",
	"object": "##STATE:my_ref:##",
	"enable_substitution": true,
    "args":{"_function":"next_available_ip"},
    "data":{
    	"exclude":["10.20.30.1","10.20.30.2"],
    	"num":2
    }
  }
]'

which returns a list.

[
    {
        "ips": [
            "10.20.30.12", 
            "10.20.30.25"
        ]
    }
]

Re: exclude list for GET next_available_ip?

Authority
Posts: 7
2725     1

Thanks MRichard!  Just tested this out against our lab grid and it works!!  //Russ

Re: exclude list for GET next_available_ip?

New Member
Posts: 4
2726     1

Hi, 

 

How would I exclude a range of IPs like .1 to .10 ? Thanks!

Re: exclude list for GET next_available_ip?

[ Edited ]
Authority
Posts: 7
2726     1

You have to include each individual IP address you want to exclude. You can see an example with a couple IP addresses in the exluide list up above (second grey block from the bottom of MRichard's post).

Showing results for 
Search instead for 
Did you mean: 

Recommended for You