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

How to improve the efficiency of large amount IP allocation

New Member
Posts: 11
6335     0

I'm experiencing such a problem.

 

user scenario:

 

We have some predefined networks, e.g 172.16.1.0/24, 172.16.2.0/24.
Some IP may already been allocated. Our customer request 300 IPs at a time.

.

 

our current solution

call WAPI to create fixedaddress with func:nextavailableip:{network} 
300 times to reserve all these 300 IPs. We also need to handle the exception, in case any of the network is used up.

300 WAPI calls take too much time, so what we want is

1. get network the available IP count
2. use the _function=next_available_ip + num ={count}  to list all the available IPs
3. call "request" api once to reserve all these IPs. 
e.g
[
  {
    "method": "POST",
    "object": "fixedaddress",
    "data": {
      "ipv4addr": "172.16.1.254",
      "mac": "00:00:00:00:00:00"
    }
  },
  {
    "method": "POST",
    "object": "fixedaddress",
    "data": {
      "ipv4addr": "172.16.2.1",
      "mac": "00:00:00:00:00:00"
    }
  },
  ........
]

if it works, we can reduce the WAPI call to 3 times

but I can't find a way to get the network's available IP amount.

any solutions?

 

Thanks

Re: How to improve the efficiency of large amount IP allocation

Moderator
Moderator
Posts: 318
6335     0

I would break up the work into two calls. 

 

First you need to identify a network which can support the number of addresses you want to assign.  Perhaps the best attribute to use is the utilization, wich is given as a percentage * 1000.  Knowing the percentage and network size, we can calculate the number of available addresses in each network:

 

curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.8/network'  -d '_return_fields=utilization'

 

 

returns:  (just a subset, and notice they're not in any particular order)

 

[
...
    {
        "_ref": "network/ZG5zLm5ldHdvcmskMTAuMTAzLjAuMC8xNi8w:10.103.0.0/16/default", 
        "utilization": 0
    }, 
    {
        "_ref": "network/ZG5zLm5ldHdvcmskMTAuMTA0LjAuMC8xNi8w:10.104.0.0/16/default", 
        "utilization": 0
    }, 
    {
        "_ref": "network/ZG5zLm5ldHdvcmskMTAuMTAyLjAuMC8xNi8w:10.102.0.0/16/default", 
        "utilization": 1
    }, 
...
]

Note the documentation sometimes says it's a percentage, but elsewhere describes it as a percentage * 1000. That keeps it as an integer but with more precision.

 

Once you find a network to use, we can start allocating addresses.

 

The second call will create multiple fixed addresses.  I don't know offhand if you can create 300 in a single call, I'm sure there's a finite limit somewhere.

 

As you suggested, you can indeed create the fixed addresses with a multiple body request.  If you have hostames, or comments, or extensible attributes, you can also build them into the requests.  I added more options than you might need for this example, where I create three fixed addresses.

 

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": "00:00:00:00:00:00",
      "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"]}
      },
      "extattrs":{"Commit ID":{"value":"10124"}}
    }
  },
  {
    "method":"POST",
    "object":"fixedaddress",
    "data": {
      "name": "host002",
      "comment": "This is a comment for Host 002",
      "mac": "00:00:00:00:00:00",
      "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"]}
      },
     "extattrs":{"Commit ID":{"value":"10125"}}
    }
  },
  {
    "method":"POST",
    "object":"fixedaddress",
    "data": {
      "name": "host003",
      "comment": "This is a comment for Host 003",
      "mac": "00:00:00:00:00:00",
      "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"]}
      },
     "extattrs":{"Commit ID":{"value":"10126"}}
    }
  }
]'

 

And the respone is the ref for each created object:

 

[
    "fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTAyLjAuMTIuMC4u:10.102.0.12/default", 
    "fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTAyLjAuMTMuMC4u:10.102.0.13/default", 
    "fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTAyLjAuMTQuMC4u:10.102.0.14/default"
]

 

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You