Browse Source

Merge branch 'master' into ignored-record-support

pull/56/head
Ross McFarland 9 years ago
committed by GitHub
parent
commit
80b06b726c
5 changed files with 59 additions and 2 deletions
  1. +7
    -1
      octodns/manager.py
  2. +4
    -1
      octodns/provider/route53.py
  3. +20
    -0
      tests/config/always-dry-run.yaml
  4. +8
    -0
      tests/test_octodns_manager.py
  5. +20
    -0
      tests/test_octodns_provider_route53.py

+ 7
- 1
octodns/manager.py View File

@ -273,12 +273,18 @@ class Manager(object):
for target, plan in plans:
plan.raise_if_unsafe()
if dry_run or config.get('always-dry-run', False):
if dry_run:
return 0
total_changes = 0
self.log.debug('sync: applying')
zones = self.config['zones']
for target, plan in plans:
zone_name = plan.existing.name
if zones[zone_name].get('always-dry-run', False):
self.log.info('sync: zone=%s skipping always-dry-run',
zone_name)
continue
total_changes += target.apply(plan)
self.log.info('sync: %d total changes', total_changes)


+ 4
- 1
octodns/provider/route53.py View File

@ -253,10 +253,13 @@ class Route53Provider(BaseProvider):
_data_for_PTR = _data_for_single
_data_for_CNAME = _data_for_single
_fix_semicolons = re.compile(r'(?<!\\);')
def _data_for_quoted(self, rrset):
return {
'type': rrset['Type'],
'values': [rr['Value'][1:-1] for rr in rrset['ResourceRecords']],
'values': [self._fix_semicolons.sub('\;', rr['Value'][1:-1])
for rr in rrset['ResourceRecords']],
'ttl': int(rrset['TTL'])
}


+ 20
- 0
tests/config/always-dry-run.yaml View File

@ -0,0 +1,20 @@
providers:
in:
class: octodns.provider.yaml.YamlProvider
directory: tests/config
dump:
class: octodns.provider.yaml.YamlProvider
directory: env/YAML_TMP_DIR
zones:
unit.tests.:
always-dry-run: true
sources:
- in
targets:
- dump
subzone.unit.tests.:
always-dry-run: false
sources:
- in
targets:
- dump

+ 8
- 0
tests/test_octodns_manager.py View File

@ -88,6 +88,14 @@ class TestManager(TestCase):
.sync(['not.targetable.'])
self.assertTrue('does not support targeting' in ctx.exception.message)
def test_always_dry_run(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
tc = Manager(get_config_filename('always-dry-run.yaml')) \
.sync(dry_run=False)
# only the stuff from subzone, unit.tests. is always-dry-run
self.assertEquals(3, tc)
def test_simple(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname


+ 20
- 0
tests/test_octodns_provider_route53.py View File

@ -1217,3 +1217,23 @@ class TestRoute53Provider(TestCase):
with self.assertRaises(Exception) as ctx:
provider.apply(plan)
self.assertTrue('modifications' in ctx.exception.message)
def test_semicolon_fixup(self):
provider = Route53Provider('test', 'abc', '123')
self.assertEquals({
'type': 'TXT',
'ttl': 30,
'values': [
'abcd\\; ef\\;g',
'hij\\; klm\\;n',
],
}, provider._data_for_quoted({
'ResourceRecords': [{
'Value': '"abcd; ef;g"',
}, {
'Value': '"hij\\; klm\\;n"',
}],
'TTL': 30,
'Type': 'TXT',
}))

Loading…
Cancel
Save