Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

API & Integration, DevOps,NetOps,SecOps

Reply

Custom Logic for IP Allocation

[ Edited ]
Member
Posts: 1
89     0

Hello,

 

We have a custom infoblox plugin for vRA that we have developed which uses internal business logic when selecting an IP address.  We assign IP addresses based on different criteria depending on the details of the VM request.  For example, we have builds that...

 

  • Assign random available IP in subnet
  • Assign next available IP from a subset of IP's within the subnet.  We call these IP Pools, and they are defined by putting a host record with the name "reserved" against each IP in the pool, and then assigning a poolName extensible attribute to the host record so that we can search for IP's in the pool by using the poolName EA as our search criteria.
  • Assign reserved IP matching the name of the server being built.

There are some others as well, but those are the main 3 types of assignments we make.  Our scripts currently do the following...

  1. Query the Infoblox API to find all addresses matching the required search criteria
  2. Select one of the returned IP's at random
  3. Add a host record for the VM to that IP

The problem is that if someone submits many simultaneous requests then we sometimes see that the same IP is used for multiple builds since there is no way to make vRA run the IP Allocation process in series.  As a result, if there are multiple allocations running at the exact same time then they will sometimes see the same IP as available, which then causes one of the VM builds to fail due to the IP conflict.  I've tried injecting some random sleep intervals in our IP allocation code, and it has improved things, but its still not perfect and I do still observe this happening from time to time.

 

In researching this, I have found that there is a way to offload IP selection to Infoblox using the "_next_available_ip" function, for example...

POST  https://infoblox.net.local/wapi/v2.6/record:host

Body:  

{
    "name": "carlosTestHostRecord",
    "ipv4addrs": [
        {
            "ipv4addr": {
                "_object_function": "next_available_ip",
                "_result_field": "ips",
                "_object": "network",
                "_object_parameters": {
                    "network": "10.1.2.0/24"
                }
            }
        }
    ],
    "configure_for_dns": false
}

 

I have tested this, and this works great for scenarios where we just want the next available IP in a subnet with no additional criteria.  However, this does not solve the need for selecting an IP from an IP Pool within the subnet.

 

So I have the following questions...

  • Is it possible to add more search params to the above operation?  Specifically, we'd want to search for IP's in the specified subnet, with a host record named "reserved", which also have a specific value for the poolName EA.
  • Can we write our own functions that we can consume via the API, so that we can insert our own business logic?
  • If we can write custom functions, then how would we pass parameters to those functions?
  • Is there perhaps a better way to segregate multiple blocks of IP's within a single subnet aside from the host record with extensible attribute option that we are already using?

Many thanks.

Carlos

 
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