def main(): get_options() if debug: print "prefix: " + opt['prefix'] print "count: " + str(opt['count_start']) print "digits: " + str(opt['digits']) print "domains:" for i in opt['domain']: print ' ' + i i = InfobloxAPI( '10.69.15.170', opt['uid'], opt['passwd'], # verbose=verbose, debug=debug, verify=False) verify=False) cnt = opt['count_start'] end = 10**opt['digits'] while cnt < end: hostname = "{0:s}{1:s}".format(opt['prefix'], str(cnt).zfill(opt['digits'])) if verbose: print "Checking {0:s}".format(hostname), available = True for d in opt['domain']: fqdn = hostname + '.' + d if verbose: print " .{0:s}".format(d), # Test DNS try: socket.gethostbyname(fqdn) available = False break except: pass # Test record:a if i.ra_exists(fqdn): if verbose: print "Infoblox record:a" available = False break # Test record:host if i.rh_exists(fqdn): if verbose: print "Infoblox record:host" available = False break if verbose: print "" if available: if verbose: print "Available!" print hostname return 0 cnt += 1 return 1
def main(): get_options() if debug: print "prefix: " + opt["prefix"] print "count: " + str(opt["count_start"]) print "digits: " + str(opt["digits"]) print "domains:" for i in opt["domain"]: print " " + i i = InfobloxAPI( "10.69.15.170", opt["uid"], opt["passwd"], # verbose=verbose, debug=debug, verify=False) verify=False, ) cnt = opt["count_start"] end = 10 ** opt["digits"] while cnt < end: hostname = "{0:s}{1:s}".format(opt["prefix"], str(cnt).zfill(opt["digits"])) if verbose: print "Checking {0:s}".format(hostname), available = True for d in opt["domain"]: fqdn = hostname + "." + d if verbose: print " .{0:s}".format(d), # Test DNS try: socket.gethostbyname(fqdn) available = False break except: pass # Test record:a if i.ra_exists(fqdn): if verbose: print "Infoblox record:a" available = False break # Test record:host if i.rh_exists(fqdn): if verbose: print "Infoblox record:host" available = False break if verbose: print "" if available: if verbose: print "Available!" print hostname return 0 cnt += 1 return 1