Browse Source

Pull dup'd parsing logic into a helper func, doc a singular case

pull/333/head
Ross McFarland 7 years ago
parent
commit
cc9a1648d2
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
1 changed files with 13 additions and 6 deletions
  1. +13
    -6
      octodns/provider/route53.py

+ 13
- 6
octodns/provider/route53.py View File

@ -497,6 +497,11 @@ def _mod_keyer(mod):
return (action_order, 0, rrset['Name']) return (action_order, 0, rrset['Name'])
def _parse_pool_name(n):
# Parse the pool name out of _octodns-<pool-name>-pool...
return n.split('.', 1)[0][9:-5]
class Route53Provider(BaseProvider): class Route53Provider(BaseProvider):
''' '''
AWS Route53 Provider AWS Route53 Provider
@ -768,7 +773,7 @@ class Route53Provider(BaseProvider):
name = rrset['Name'] name = rrset['Name']
if '-pool.' in name: if '-pool.' in name:
# This is a pool rrset # This is a pool rrset
pool_name = name.split('.', 1)[0][9:-5]
pool_name = _parse_pool_name(name)
if pool_name == 'default': if pool_name == 'default':
# default becomes the base for the record and its # default becomes the base for the record and its
# value(s) will fill the non-dynamic values # value(s) will fill the non-dynamic values
@ -777,8 +782,8 @@ class Route53Provider(BaseProvider):
elif rrset['Failover'] == 'SECONDARY': elif rrset['Failover'] == 'SECONDARY':
# This is a failover record, we'll ignore PRIMARY, but # This is a failover record, we'll ignore PRIMARY, but
# SECONDARY will tell us what the pool's fallback is # SECONDARY will tell us what the pool's fallback is
fallback_name = rrset['AliasTarget']['DNSName'] \
.split('.', 1)[0][9:-5]
fallback_name = \
_parse_pool_name(rrset['AliasTarget']['DNSName'])
# Don't care about default fallbacks, anything else # Don't care about default fallbacks, anything else
# we'll record # we'll record
if fallback_name != 'default': if fallback_name != 'default':
@ -789,16 +794,18 @@ class Route53Provider(BaseProvider):
# We record rule index as the first part of set-id, the 2nd # We record rule index as the first part of set-id, the 2nd
# part just ensures uniqueness across geos and is ignored # part just ensures uniqueness across geos and is ignored
i = int(_id.split('-', 1)[0]) i = int(_id.split('-', 1)[0])
# Parse the pool name out of _octodns-<pool-name>-pool.
pool = rrset['AliasTarget']['DNSName'].split('.', 1)[0][9:-5]
target_pool = _parse_pool_name(rrset['AliasTarget']['DNSName'])
# Record the pool # Record the pool
rules[i]['pool'] = pool
rules[i]['pool'] = target_pool
# Record geo if we have one # Record geo if we have one
geo = self._parse_geo(rrset) geo = self._parse_geo(rrset)
if geo: if geo:
rules[i]['geos'].append(geo) rules[i]['geos'].append(geo)
else: else:
# These are the pool value(s) # These are the pool value(s)
# Grab the pool name out of the SetIdentifier, format looks
# like ...-000 where 000 is a zero-padded index for the value
# it's ignored only used to make sure the value is unique
pool_name = rrset['SetIdentifier'][:-4] pool_name = rrset['SetIdentifier'][:-4]
value = rrset['ResourceRecords'][0]['Value'] value = rrset['ResourceRecords'][0]['Value']
pools[pool_name]['values'].append({ pools[pool_name]['values'].append({


Loading…
Cancel
Save