From 5aa8575127e1c7e8b80e0a81943246af376483a0 Mon Sep 17 00:00:00 2001 From: Gilles Grandou Date: Tue, 12 Nov 2019 12:20:50 +0100 Subject: [PATCH] ovh update fixes --- dyndomain | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/dyndomain b/dyndomain index fa4846e..215e425 100755 --- a/dyndomain +++ b/dyndomain @@ -158,13 +158,23 @@ def ovh_update_zone(domain, update_zone_list, delete_zone_list): result = client.get('/domain/zone/%s/record' % domain, fieldType=fieldtype, subDomain=host) - if len(result) == 0: - continue - id = result[0] - #print("Delete entry for %s %s %s" % (host, fieldtype, target)) - client.delete('/domain/zone/%s/record/%d' % (domain, id)) + 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,