Merge pull request #25200 from geneseven/develop

solve the issue of add_host. If the name had already one more recored…
This commit is contained in:
Thomas S Hatch 2015-07-07 12:26:10 -06:00
commit b781b595fa

View File

@ -159,27 +159,22 @@ def update(zone, name, ttl, rdtype, data, nameserver='127.0.0.1', replace=False,
rdtype = dns.rdatatype.from_text(rdtype)
rdata = dns.rdata.from_text(dns.rdataclass.IN, rdtype, data)
is_update = False
for rrset in answer.answer:
if rdata in rrset.items:
rr = rrset.items
if ttl == rrset.ttl:
if replace and (len(answer.answer) > 1
or len(rrset.items) > 1):
is_update = True
break
return None
is_update = True
break
keyring = _get_keyring(_config('keyfile', **kwargs))
keyname = _config('keyname', **kwargs)
keyalgorithm = _config('keyalgorithm', **kwargs) or 'HMAC-MD5.SIG-ALG.REG.INT'
is_exist = False
for rrset in answer.answer:
if rdata in rrset.items:
if ttl == rrset.ttl:
if len(answer.answer) >= 1 or len(rrset.items) >= 1:
is_exist = True
break
dns_update = dns.update.Update(zone, keyring=keyring, keyname=keyname, keyalgorithm=keyalgorithm)
if is_update:
if replace:
dns_update.replace(name, ttl, rdata)
else:
elif not is_exist:
dns_update.add(name, ttl, rdata)
answer = dns.query.udp(dns_update, nameserver)
if answer.rcode() > 0: