From 79eb79f46c0ba12f255293ca6bad038dcb04466a Mon Sep 17 00:00:00 2001 From: Gilles Grandou Date: Tue, 12 Nov 2019 12:23:26 +0100 Subject: [PATCH] catch ovh_update errors --- dyndomain | 64 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/dyndomain b/dyndomain index 215e425..f53c8bf 100755 --- a/dyndomain +++ b/dyndomain @@ -152,39 +152,43 @@ def ovh_update_zone(domain, update_zone_list, delete_zone_list): if not len(update_zone_list) and not len(delete_zone_list): return False - client = ovh.Client() + try: + client = ovh.Client() - for host, fieldtype, target in delete_zone_list: - result = client.get('/domain/zone/%s/record' % domain, - fieldType=fieldtype, - subDomain=host) - for id in result: - r = client.get('/domain/zone/%s/record/%d' % (domain, id)) - if r['fieldType'] == fieldtype and r['target'] == target: - #print("Delete entry for %s %s %s" % (host, fieldtype, target)) - client.delete('/domain/zone/%s/record/%d' % (domain, id)) + for host, fieldtype, target in delete_zone_list: + result = client.get('/domain/zone/%s/record' % domain, + fieldType=fieldtype, + subDomain=host) + for id in result: + r = client.get('/domain/zone/%s/record/%d' % (domain, id)) + if r['fieldType'] == fieldtype and r['target'] == target: + #print("Delete entry for %s %s %s" % (host, fieldtype, target)) + client.delete('/domain/zone/%s/record/%d' % (domain, id)) - for host, fieldtype, target in update_zone_list: - result = client.get('/domain/zone/%s/record' % domain, - fieldType=fieldtype, - subDomain=host) - skip = False - for id in result: - r = client.get('/domain/zone/%s/record/%d' % (domain, id)) - if r['fieldType'] == fieldtype and r['target'] == target: - skip = True - if skip: - continue - #print("Create new entry for %s %s %s" % (host, fieldtype, target)) - client.post('/domain/zone/%s/record' % domain, - fieldType=fieldtype, - subDomain=host, - target=target, - ttl=60) + for host, fieldtype, target in update_zone_list: + result = client.get('/domain/zone/%s/record' % domain, + fieldType=fieldtype, + subDomain=host) + skip = False + for id in result: + r = client.get('/domain/zone/%s/record/%d' % (domain, id)) + if r['fieldType'] == fieldtype and r['target'] == target: + skip = True + if skip: + continue + #print("Create new entry for %s %s %s" % (host, fieldtype, target)) + client.post('/domain/zone/%s/record' % domain, + fieldType=fieldtype, + subDomain=host, + target=target, + ttl=60) - #print("Refresh zone %s" % domain) - client.post('/domain/zone/%s/refresh' % domain) - return True + #print("Refresh zone %s" % domain) + client.post('/domain/zone/%s/refresh' % domain) + return True + except: + print('OVH update error\n') + return False def send_update_mail(mail_to, mail_from, zone_domain, update_zone_list, delete_zone_list, mail_ignore_list, wan):