fixed multiple entries ovh update

This commit is contained in:
Gilles Grandou 2019-10-09 08:13:42 +02:00
parent bdcf586a6c
commit 7599ec2684
1 changed files with 9 additions and 17 deletions

View File

@ -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