think i need a small fix for this. it's not creating records it ought to.

This commit is contained in:
brent s. 2020-05-10 08:32:49 -04:00
parent b8592686e4
commit b638e58dc8
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
1 changed files with 16 additions and 15 deletions

View File

@ -135,7 +135,8 @@ class Updater(object):
logger.error('Record {0} ({1}) is too long: {2}'.format(record, t, e)) logger.error('Record {0} ({1}) is too long: {2}'.format(record, t, e))
continue continue
except dns.resolver.NoAnswer as e: except dns.resolver.NoAnswer as e:
logger.error('Record {0} ({1}) exists but has no content: {2}'.format(record, t, e)) # This is a debug instead of an error because that record type may not exist.
logger.debug('Record {0} ({1}) exists but has no content: {2}'.format(record, t, e))
continue continue
except dns.resolver.NoNameservers as e: except dns.resolver.NoNameservers as e:
logger.error(('Could not failover to a non-broken resolver when resolving {0} ({1}): ' logger.error(('Could not failover to a non-broken resolver when resolving {0} ({1}): '
@ -238,7 +239,7 @@ class Updater(object):
r_exists = False r_exists = False
if r_exists: if r_exists:
# Do nothing. # Do nothing.
e = 'Skipping adding {0} for {1}; already exists in API'.format(ip, fqdn) e = 'Skipping adding {0} for {1}; already exists in API and is correct'.format(ip, fqdn)
logger.info(e) logger.info(e)
if is_tty: if is_tty:
print(e) print(e)
@ -263,19 +264,19 @@ class Updater(object):
else: else:
# Create the record. # Create the record.
logger.debug('Record {0} ({1}) does not exist; creating'.format(fqdn, ip)) logger.debug('Record {0} ({1}) does not exist; creating'.format(fqdn, ip))
record = {'name': s, record = {'name': s,
'type': t, 'type': t,
'target': ip, 'target': ip,
'ttl_sec': 300} 'ttl_sec': 300}
create_url = '{0}/domains/{1}/records'.format(self.api_base, d_id) create_url = '{0}/domains/{1}/records'.format(self.api_base, d_id)
create_r = self.session.put(create_url, create_r = self.session.post(create_url,
json = record) json = record)
if not create_r.ok: if not create_r.ok:
e = 'Could not create record {0} ({1}); skipping'.format(fqdn, t) e = 'Could not create record {0} ({1}); skipping'.format(fqdn, t)
if is_tty: if is_tty:
warnings.warn(e) warnings.warn(e)
logger.warning(e) logger.warning(e)
continue continue
return() return()