summaryrefslogtreecommitdiff
path: root/net/dns/linode/ddns.py
diff options
context:
space:
mode:
authorbrent s <bts@square-r00t.net>2020-05-10 08:32:49 -0400
committerbrent s <bts@square-r00t.net>2020-05-10 08:32:49 -0400
commitb638e58dc84bef5149ea463aaa03e9017028a542 (patch)
tree75c8beeeb1a810241f2d37a5564073a6c41729cf /net/dns/linode/ddns.py
parentb8592686e4785b8fd1c8616c12598b2246700133 (diff)
downloadOpTools-b638e58dc84bef5149ea463aaa03e9017028a542.tar.xz
think i need a small fix for this. it's not creating records it ought to.
Diffstat (limited to 'net/dns/linode/ddns.py')
-rwxr-xr-xnet/dns/linode/ddns.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/net/dns/linode/ddns.py b/net/dns/linode/ddns.py
index bfaa385..afa60ea 100755
--- a/net/dns/linode/ddns.py
+++ b/net/dns/linode/ddns.py
@@ -135,7 +135,8 @@ class Updater(object):
logger.error('Record {0} ({1}) is too long: {2}'.format(record, t, e))
continue
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
except dns.resolver.NoNameservers as e:
logger.error(('Could not failover to a non-broken resolver when resolving {0} ({1}): '
@@ -238,7 +239,7 @@ class Updater(object):
r_exists = False
if r_exists:
# 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)
if is_tty:
print(e)
@@ -263,19 +264,19 @@ class Updater(object):
else:
# Create the record.
logger.debug('Record {0} ({1}) does not exist; creating'.format(fqdn, ip))
- record = {'name': s,
- 'type': t,
- 'target': ip,
- 'ttl_sec': 300}
- create_url = '{0}/domains/{1}/records'.format(self.api_base, d_id)
- create_r = self.session.put(create_url,
- json = record)
- if not create_r.ok:
- e = 'Could not create record {0} ({1}); skipping'.format(fqdn, t)
- if is_tty:
- warnings.warn(e)
- logger.warning(e)
- continue
+ record = {'name': s,
+ 'type': t,
+ 'target': ip,
+ 'ttl_sec': 300}
+ create_url = '{0}/domains/{1}/records'.format(self.api_base, d_id)
+ create_r = self.session.post(create_url,
+ json = record)
+ if not create_r.ok:
+ e = 'Could not create record {0} ({1}); skipping'.format(fqdn, t)
+ if is_tty:
+ warnings.warn(e)
+ logger.warning(e)
+ continue
return()