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


Help to create script to change multiple dhcp ranges member assignment at once

Posts: 13
6350     0

I have two DHCP members – both in HA.  Both DHCP members are serving different networks without any failover association configured.


If one DHCP member completely fails – meaning both HA nodes go down – I need to quickly assign the DHCP ranges for those networks to the other DHCP member.  I am not great in the programming area and would like some assistance in to:

  1. Needing to retrieve the grid member that has all dhcp ranges assigned to that grid member
  2. If it is one member, change it to the other member

Re: Help to create script to change multiple dhcp ranges member assignment at once

Posts: 112
6351     0

You actually don't need any scripting or programming to accomplish this. The CSV Job Manager makes this easy to accomplish.


  1. Use the CSV Job Manager to export all of your networks and ranges.You can find this in the vertical toolbar on the right-hand side of the page on any screen under the Data Management tab.
  2. Remove all of the columns that you do not need (any required columns are noted with an asterisk).
  3. Update the dhcp_members and member columns. If using DHCP Failover, update the failover_association column. Save this to a new file.
  4. Using the CSV Job Manager, create a new CSV import job with the job type set to override.
  5. Browse to the updated CSV file.
  6. Optional: Set the "On error" action to "Skip to the next row and continue".
  7. Run the import.
  8. Restart services once the import is complete.

Note: If all your doing is changing the member assignment, the CSV syntax will look like the following:




If you only have a single Network View, that column can be ommitted. If in doubt or you have multiple Network Views, include it and specify the Network View for the networks and ranges you want to update. Navigate to Administration -> Network Views to review any existing Network Views. The Network View is selected using a dropdown menu found at the top left-hand side of your Grid Manager GUI window.


Good luck!



Re: Help to create script to change multiple dhcp ranges member assignment at once

Posts: 13
6351     0

Sweet!  I don't use the export function all that much and had forgotten about it.  I tried this on a test dhcp range and it worked.  Thank you, that's exactly what I was looking for.

Re: Help to create script to change multiple dhcp ranges member assignment at once

New Member
Posts: 1
6351     0

Hi Tony,


i have 100 of network configured , but not associated with DHCP grid members . I want to associate all networks to grid members , is it possible to add grid members using csv , one by one i can do from GUI.

Re: Help to create script to change multiple dhcp ranges member assignment at once

Posts: 224
6351     0

Yes you do this with an "override" CSV job. The CSV file should only have the columns needed to identify which networks are being changed, and the setting being changed.


You will also need to change the ranges within the network, and assign them to a member or a failover association.


For example with a single member:






Or for a failover association:






Practice on a lab appliance if you have one.  Otherwise just do one network first to make sure you're happy with the results.

Re: Help to create script to change multiple dhcp ranges member assignment at once

Posts: 1
6351     0

Is there a way to find all DHCP-ranges in single view ? Problem is I can only find DHCP-range view within a subnet. " Data Management > DHCP > Networks > Networks " is not showing all DHCP ranges.

Re: Help to create script to change multiple dhcp ranges member assignment at once

Posts: 224
6351     0

If you mean in a single pane in the web interface?  Unfortunately no.


If you mean getting a list of all ranges within a Network View, you can do a global CSV export for all ranges.  It will generate a CSV file with everything, and then you can use filters in Excel to filter by Network View.

Re: Help to create script to change multiple dhcp ranges member assignment at once

Posts: 82
6351     0

Hello Manikastuv,


Going forward, please consider creating a new community post for new use-cases/questions rather than posting it under an old/different post. This would increase the chances of your question to be noticed quickly & may also attract more answers. 


To address your question, you have 3 options :


1) Like what Matt said, CSV export followed by manipulations within excel.


2) WebAPI - you could put in the following string to your browser & get the data needed as an XML. From there you may copy/extract to get a list of all ranges.




3) Use the Python Script attached below & you would get a result similar to this :




     **List of DHCP ranges under default view**


Range 1 : -
Range 2 : -




# Find the list of ranges within a specific network view

import requests
import urllib3
import json
from os import system, name

def clear():
    if name == 'nt':
        _ = system('cls')
        _ = system('clear')


gm_ip = input("\n\nEnter Grid master IP :")
gm_user = input("\nEnter user name :")
gm_password = input("\nEnter password :")

continue_check = "y"

while continue_check == 'y':
    network_view_name = input("\nEnter the exact name of Network view to be inspected :")
    urL = 'https://' + gm_ip + '/wapi/v2.9/range?network_view=' + network_view_name + "&_return_fields=start_addr,end_addr"
    response = requests.get(urL, auth=(gm_user, gm_password), verify=False)
    mid_value = response.content
    response_native = json.loads(mid_value)
    format_output_data = json.dumps(response_native, indent=1)

    if response.status_code == 200:
        print(f"\n\n\t**List of DHCP ranges under {network_view_name} view**\n")
        string_temp = ""
        count = 1
        for line in format_output_data.splitlines():
            end_string = "end_addr"
            start_string = "start_addr"
            if end_string in line:
                after_value = line[line.index(end_string)+11:]
                string_temp += after_value
            if start_string in line:
                start_value = line[line.index(start_string)+13:]
                string_temp = start_value + "-" +string_temp
                print(f"Range {count} : {string_temp}".replace('"', ' ').replace(',',''))
                string_temp = ""
                count += 1

        print("\n\nHTTP response code : " + str(
            response.status_code) + ". Error encountered")
    continue_check = input("\n\nTo try another view type 'y'. Else anything to escape :")


Please note that the WAPI version used in my solutions are both 2.9. Please adjust this if necessary. Hope this would be helpful.


Best regards,

Mohammed Alman

Showing results for 
Search instead for 
Did you mean: 

Recommended for You