Merge pull request #37785 from Cloudtek/ddns-respect-trailing-dot

respect trailing dot in ddns name parameter
This commit is contained in:
Mike Place 2016-11-28 16:02:10 +02:00 committed by GitHub
commit e13a2488c8
2 changed files with 18 additions and 7 deletions

View file

@ -162,7 +162,12 @@ def update(zone, name, ttl, rdtype, data, nameserver='127.0.0.1',
salt ns1 ddns.update example.com host1 60 A 10.0.0.1
'''
name = str(name)
fqdn = '{0}.{1}'.format(name, zone)
if name[-1:] == '.':
fqdn = name
else:
fqdn = '{0}.{1}'.format(name, zone)
request = dns.message.make_query(fqdn, rdtype)
answer = dns.query.udp(request, nameserver)
@ -208,9 +213,13 @@ def delete(zone, name, rdtype=None, data=None, nameserver='127.0.0.1',
salt ns1 ddns.delete example.com host1 A
'''
name = str(name)
fqdn = '{0}.{1}'.format(name, zone)
request = dns.message.make_query(fqdn, (rdtype or 'ANY'))
if name[-1:] == '.':
fqdn = name
else:
fqdn = '{0}.{1}'.format(name, zone)
request = dns.message.make_query(fqdn, (rdtype or 'ANY'))
answer = dns.query.udp(request, nameserver)
if not answer.answer:
return None

View file

@ -37,8 +37,9 @@ def present(name, zone, ttl, data, rdtype='A', **kwargs):
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created, so make sure that
information is not duplicated in these two arguments.
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that information is not duplicated in these
two arguments.
zone
The zone to check/update
@ -95,8 +96,9 @@ def absent(name, zone, data=None, rdtype=None, **kwargs):
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created, so make sure that
information is not duplicated in these two arguments.
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that information is not duplicated in these
two arguments.
zone
The zone to check