manage multiple domains

This commit is contained in:
Gitouche 2021-01-09 16:02:14 +01:00
parent 8c1ae5abdd
commit cd1def40e1

View file

@ -94,25 +94,28 @@ def main(force_update, verbosity):
if verbosity: if verbosity:
print("verbosity turned on - not implemented by now") print("verbosity turned on - not implemented by now")
for key, value in config.dnsentries.items():
config.domain = key
config.subdomains = value
#get zone ID from Account #get zone ID from Account
uuid = get_uuid() uuid = get_uuid()
#compare dynIP and DNS IP #compare dynIP and DNS IP
dynIP = get_dynip(config.ifconfig) dynIP = get_dynip(config.ifconfig)
dnsIP = get_dnsip(uuid) dnsIP = get_dnsip(uuid)
if force_update: if force_update:
print("Going to update/create the DNS Records for the subdomains") print("Going to update/create the DNS Records for the subdomains")
for sub in config.subdomains:
update_records(uuid, dynIP, sub)
else:
if dynIP == dnsIP:
print("IP Address Match - no further action")
else:
print("IP Address Mismatch - going to update the DNS Records for the subdomains with new IP", dynIP)
for sub in config.subdomains: for sub in config.subdomains:
update_records(uuid, dynIP, sub) update_records(uuid, dynIP, sub)
else:
if dynIP == dnsIP:
print("IP Address Match - no further action")
else:
print("IP Address Mismatch - going to update the DNS Records for the subdomains with new IP", dynIP)
for sub in config.subdomains:
update_records(uuid, dynIP, sub)
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -120,11 +123,4 @@ if __name__ == "__main__":
parser.add_argument('-f', '--force', help="force an update/create", action="store_true") parser.add_argument('-f', '--force', help="force an update/create", action="store_true")
args = parser.parse_args() args = parser.parse_args()
main(args.force, args.verbose) main(args.force, args.verbose)