diff --git a/dyndomain b/dyndomain index b23e748..2fe376c 100755 --- a/dyndomain +++ b/dyndomain @@ -153,23 +153,6 @@ def ovh_update_zone(domain, update_zone_list, delete_zone_list): client = ovh.Client() - for host, fieldtype, target in update_zone_list: - result = client.get('/domain/zone/%s/record' % domain, - fieldType=fieldtype, - subDomain=host) - if len(result) == 0: - #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) - else: - id = result[0] - #print("Update entry for %s %s %s" % (host, fieldtype, target)) - client.put('/domain/zone/%s/record/%ld' % (domain, id), - target=target) - for host, fieldtype, target in delete_zone_list: result = client.get('/domain/zone/%s/record' % domain, fieldType=fieldtype, @@ -179,6 +162,15 @@ def ovh_update_zone(domain, update_zone_list, delete_zone_list): id = result[0] #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: + #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