Browse Source

Merge branch 'master' into etc-hosts-provider

pull/245/head
Ross McFarland 8 years ago
committed by GitHub
parent
commit
b01cc18706
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 15 deletions
  1. +1
    -1
      octodns/provider/base.py
  2. +9
    -0
      octodns/provider/ns1.py
  3. +17
    -9
      octodns/provider/route53.py
  4. +5
    -5
      tests/test_octodns_provider_ns1.py
  5. +17
    -0
      tests/test_octodns_provider_route53.py

+ 1
- 1
octodns/provider/base.py View File

@ -17,7 +17,7 @@ class BaseProvider(BaseSource):
delete_pcent_threshold=Plan.MAX_SAFE_DELETE_PCENT):
super(BaseProvider, self).__init__(id)
self.log.debug('__init__: id=%s, apply_disabled=%s, '
'update_pcent_threshold=%.2f'
'update_pcent_threshold=%.2f, '
'delete_pcent_threshold=%.2f',
id,
apply_disabled,


+ 9
- 0
octodns/provider/ns1.py View File

@ -189,6 +189,15 @@ class Ns1Provider(BaseProvider):
try:
nsone_zone = self._client.loadZone(zone.name[:-1])
records = nsone_zone.data['records']
# change answers for certain types to always be absolute
for record in records:
if record['type'] in ['ALIAS', 'CNAME', 'MX', 'NS', 'PTR',
'SRV']:
for i, a in enumerate(record['short_answers']):
if not a.endswith('.'):
record['short_answers'][i] = '{}.'.format(a)
geo_records = nsone_zone.search(has_geo=True)
exists = True
except ResourceException as e:


+ 17
- 9
octodns/provider/route53.py View File

@ -217,11 +217,14 @@ class Route53Provider(BaseProvider):
route53:
class: octodns.provider.route53.Route53Provider
# The AWS access key id (required)
# The AWS access key id
access_key_id:
# The AWS secret access key (required)
# The AWS secret access key
secret_access_key:
Alternatively, you may leave out access_key_id and secret_access_key,
this will result in boto3 deciding authentication dynamically.
In general the account used will need full permissions on Route53.
'''
SUPPORTS_GEO = True
@ -232,12 +235,14 @@ class Route53Provider(BaseProvider):
# health check config.
HEALTH_CHECK_VERSION = '0001'
def __init__(self, id, access_key_id, secret_access_key, max_changes=1000,
client_max_attempts=None, *args, **kwargs):
def __init__(self, id, access_key_id=None, secret_access_key=None,
max_changes=1000, client_max_attempts=None, *args, **kwargs):
self.max_changes = max_changes
_msg = 'access_key_id={}, secret_access_key=***'.format(access_key_id)
if access_key_id is None and secret_access_key is None:
_msg = 'auth=fallback'
self.log = logging.getLogger('Route53Provider[{}]'.format(id))
self.log.debug('__init__: id=%s, access_key_id=%s, '
'secret_access_key=***', id, access_key_id)
self.log.debug('__init__: id=%s, %s', id, _msg)
super(Route53Provider, self).__init__(id, *args, **kwargs)
config = None
@ -246,9 +251,12 @@ class Route53Provider(BaseProvider):
client_max_attempts)
config = Config(retries={'max_attempts': client_max_attempts})
self._conn = client('route53', aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
config=config)
if access_key_id is None and secret_access_key is None:
self._conn = client('route53', config=config)
else:
self._conn = client('route53', aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
config=config)
self._r53_zones = None
self._r53_rrsets = {}


+ 5
- 5
tests/test_octodns_provider_ns1.py View File

@ -133,12 +133,12 @@ class TestNs1Provider(TestCase):
}, {
'type': 'CNAME',
'ttl': 34,
'short_answers': ['foo.unit.tests.'],
'short_answers': ['foo.unit.tests'],
'domain': 'cname.unit.tests.',
}, {
'type': 'MX',
'ttl': 35,
'short_answers': ['10 mx1.unit.tests.', '20 mx2.unit.tests.'],
'short_answers': ['10 mx1.unit.tests.', '20 mx2.unit.tests'],
'domain': 'unit.tests.',
}, {
'type': 'NAPTR',
@ -151,18 +151,18 @@ class TestNs1Provider(TestCase):
}, {
'type': 'NS',
'ttl': 37,
'short_answers': ['ns1.unit.tests.', 'ns2.unit.tests.'],
'short_answers': ['ns1.unit.tests.', 'ns2.unit.tests'],
'domain': 'unit.tests.',
}, {
'type': 'SRV',
'ttl': 38,
'short_answers': ['12 30 30 foo-2.unit.tests.',
'10 20 30 foo-1.unit.tests.'],
'10 20 30 foo-1.unit.tests'],
'domain': '_srv._tcp.unit.tests.',
}, {
'type': 'NS',
'ttl': 39,
'short_answers': ['ns3.unit.tests.', 'ns4.unit.tests.'],
'short_answers': ['ns3.unit.tests.', 'ns4.unit.tests'],
'domain': 'sub.unit.tests.',
}, {
'type': 'CAA',


+ 17
- 0
tests/test_octodns_provider_route53.py View File

@ -167,6 +167,23 @@ class TestRoute53Provider(TestCase):
return (provider, stubber)
def _get_stubbed_fallback_auth_provider(self):
provider = Route53Provider('test')
# Use the stubber
stubber = Stubber(provider._conn)
stubber.activate()
return (provider, stubber)
def test_populate_with_fallback(self):
provider, stubber = self._get_stubbed_fallback_auth_provider()
got = Zone('unit.tests.', [])
with self.assertRaises(ClientError):
stubber.add_client_error('list_hosted_zones')
provider.populate(got)
def test_populate(self):
provider, stubber = self._get_stubbed_provider()


Loading…
Cancel
Save