mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
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:
commit
b781b595fa
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user