Merge branch 'master' into rel0.10

This commit is contained in:
Thomas Waldmann 2014-11-15 17:56:26 +01:00
commit 37a0396186

View File

@ -132,7 +132,8 @@ def add(fqdn, ipaddr, ttl=60):
def delete(fqdn, rdtype=None): def delete(fqdn, rdtype=None):
""" """
dns deleter intelligent dns deleter - first does a lookup on the master server to find
out whether there is a dns entry and only send a 'del' if there is an entry.
:param fqdn: fully qualified domain name (FQDN) :param fqdn: fully qualified domain name (FQDN)
:param rdtype: 'A', 'AAAA' or None (deletes 'A' and 'AAAA') :param rdtype: 'A', 'AAAA' or None (deletes 'A' and 'AAAA')
@ -144,6 +145,14 @@ def delete(fqdn, rdtype=None):
else: else:
rdtypes = ['A', 'AAAA'] rdtypes = ['A', 'AAAA']
for rdtype in rdtypes: for rdtype in rdtypes:
try:
# check if we have a DNS entry
query_ns(fqdn, rdtype)
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
# no dns entry, it is already deleted
pass
else:
# there is a DNS entry, send a del
update_ns(fqdn, rdtype, action='del') update_ns(fqdn, rdtype, action='del')