ovh update fixes

This commit is contained in:
Gilles Grandou 2019-11-12 12:20:50 +01:00
parent 6894ee25d9
commit 5aa8575127

View File

@ -158,13 +158,23 @@ def ovh_update_zone(domain, update_zone_list, delete_zone_list):
result = client.get('/domain/zone/%s/record' % domain, result = client.get('/domain/zone/%s/record' % domain,
fieldType=fieldtype, fieldType=fieldtype,
subDomain=host) subDomain=host)
if len(result) == 0: for id in result:
continue r = client.get('/domain/zone/%s/record/%d' % (domain, id))
id = result[0] if r['fieldType'] == fieldtype and r['target'] == target:
#print("Delete entry for %s %s %s" % (host, fieldtype, target)) #print("Delete entry for %s %s %s" % (host, fieldtype, target))
client.delete('/domain/zone/%s/record/%d' % (domain, id)) client.delete('/domain/zone/%s/record/%d' % (domain, id))
for host, fieldtype, target in update_zone_list: 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)) #print("Create new entry for %s %s %s" % (host, fieldtype, target))
client.post('/domain/zone/%s/record' % domain, client.post('/domain/zone/%s/record' % domain,
fieldType=fieldtype, fieldType=fieldtype,