SSO Login is being implemented on this site. Existing users: Your existing password must be reset the first time you login using SSO. Click here to reset your password first before login. Your new username will be your email.

API & Integration, DevOps,NetOps,SecOps


Check if DNS authoritative zones have been disabled

Posts: 1
698     0


I wrote a python script that via API disables a list of DNS autoritative zones; in order to double check if the disable operation was successfull, I would like to know how to retrieve the disable field for a list of zones (either given the fqdn or the _ref) via API

thanks in advance


Re: Check if DNS authoritative zones have been disabled

Posts: 62
699     0

Hello Robert,


I've attcahed a python script for your use-case, down below. Please note that I've specified the WAPI version to be 2.10.1 & you may need to adjust that if your NIOS version doesn't support this version. 


IMPORTANT NOTE : I haven't scaled this to refine the runtime complexity. If you have N number of domains to be checked, this code would login atleast N number of times to the grid before giving you the result. That definitely means a higher time-complexity & shall hit the concurrent login sessions to the grid. You may fix this by getting the results from the grid in one shot as a single JSON content(pull everything for /zone_auth onetime & then search the contents based on the entries inside your checkfile). I wrote this quickly & didn't consider this aspect then. I'll post a modified version later as possible. Ignore this note in case if this is more like a one-time use-case & the number of domains in your check list is low. 


"""Script to inspect "Disable" flag of specific set of domains added under a List file file(no need to specify path if in same location, else specify the path+filename) as shown below
   List content example -->
   example of listname to be entered-->

import requests
import urllib3
import json



list_name=input("\nEnter the name of the List file :")
gm_ip= input("Enter Grid master IP :")
gm_user=input("Enter user name :")
gm_password=input("Enter password :")
print("\n\nChecking for *Active* domains from the list...\n")

fileB=open(list_name, 'r')
count = 0
urL = 'https://'+gm_ip+'/wapi/v2.10.1/zone_auth?_return_fields=fqdn,disable&fqdn='
for line in readFqdns:
    count += 1
    reqResponse= requests.get(urL+line.strip(), auth=(gm_user, gm_password), verify=False)
    #print("The result : " + str(reqResponse.content))
    response_native = json.loads(writable_value)
    for resp in response_native:
      if resp.get('disable') == False:
        help_value= resp.get("fqdn")

print("Inspection complete & the *Active* domains from the list are as follows(If any):- \n")

for active_domain in resultsToClient:

Hope this helps!


Best regards,

Mohammed Alman

Showing results for 
Search instead for 
Did you mean: 

Recommended for You