Browse Source

Merge pull request #1128 from baest/list_zones_for_autoarpa

Add list_zones to AutoArpa
pull/1132/head
Ross McFarland 2 years ago
committed by GitHub
parent
commit
30f8b4f5f5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 118 additions and 0 deletions
  1. +19
    -0
      docs/auto_arpa.md
  2. +3
    -0
      octodns/processor/arpa.py
  3. +29
    -0
      tests/config/dynamic-arpa-no-normal-source.yaml
  4. +30
    -0
      tests/config/dynamic-arpa.yaml
  5. +0
    -0
      tests/config/dynamic-arpa/3.2.2.in-addr.arpa.yaml
  6. +0
    -0
      tests/config/dynamic-arpa/b.e.f.f.f.d.1.8.f.2.6.0.1.2.e.0.0.5.0.4.4.6.0.1.0.6.2.ip6.arpa.yaml
  7. +17
    -0
      tests/config/dynamic-arpa/unit.tests.yaml
  8. +20
    -0
      tests/test_octodns_manager.py

+ 19
- 0
docs/auto_arpa.md View File

@ -100,3 +100,22 @@ fileserver:
### Notes
Automatic `PTR` generation requires a "complete" picture of records and thus cannot be done during partial syncs. Thus syncing `arpa.` zones will throw an error any time filtering of zones, targets, or sources is being done.
#### AutoArpa and Dynamic Zone Config
The AutoArpa provider works with Dynamic Zone Config, but only in the sense that it doesn't stop it from working. It requires another provider to actually generate the list of zones. It could be the Yaml provider like so:
```yaml
example.com.:
sources:
- config
targets:
- ...
"*.arpa.":
sources:
- config
- auto-arpa
targets:
- ...
```
That would take all the relevant records from example.com and add them as PTR records for the arpa zones in the same place as the 'config' source specifies.

+ 3
- 0
octodns/processor/arpa.py View File

@ -72,3 +72,6 @@ class AutoArpa(BaseProcessor):
self.log.info(
'populate: found %s records', len(zone.records) - before
)
def list_zones(self):
return set()

+ 29
- 0
tests/config/dynamic-arpa-no-normal-source.yaml View File

@ -0,0 +1,29 @@
manager:
max_workers: 2
auto_arpa:
populate_should_replace: True
ttl: 1800
providers:
in:
class: octodns.provider.yaml.YamlProvider
directory: tests/config/dynamic-arpa
supports_root_ns: False
strict_supports: False
dump:
class: octodns.provider.yaml.YamlProvider
directory: env/YAML_TMP_DIR
default_ttl: 999
supports_root_ns: False
strict_supports: False
zones:
unit.tests.:
sources:
- in
targets:
- dump
"*.arpa.":
sources:
- auto-arpa
targets:
- dump

+ 30
- 0
tests/config/dynamic-arpa.yaml View File

@ -0,0 +1,30 @@
manager:
max_workers: 2
auto_arpa:
populate_should_replace: True
ttl: 1800
providers:
in:
class: octodns.provider.yaml.YamlProvider
directory: tests/config/dynamic-arpa
supports_root_ns: False
strict_supports: False
dump:
class: octodns.provider.yaml.YamlProvider
directory: env/YAML_TMP_DIR
default_ttl: 999
supports_root_ns: False
strict_supports: False
zones:
unit.tests.:
sources:
- in
targets:
- dump
"*.arpa.":
sources:
- in
- auto-arpa
targets:
- dump

+ 0
- 0
tests/config/dynamic-arpa/3.2.2.in-addr.arpa.yaml View File


+ 0
- 0
tests/config/dynamic-arpa/b.e.f.f.f.d.1.8.f.2.6.0.1.2.e.0.0.5.0.4.4.6.0.1.0.6.2.ip6.arpa.yaml View File


+ 17
- 0
tests/config/dynamic-arpa/unit.tests.yaml View File

@ -0,0 +1,17 @@
---
aaaa:
ttl: 600
type: AAAA
value: 2601:644:500:e210:62f8:1dff:feb8:947a
not-a-zone-file:
ttl: 300
type: A
value: 3.3.3.6
www:
ttl: 300
type: A
value: 2.2.3.6
www.sub:
ttl: 300
type: A
value: 2.2.3.7

+ 20
- 0
tests/test_octodns_manager.py View File

@ -1099,6 +1099,26 @@ class TestManager(TestCase):
# should sync everything across all zones, total of 32 records
self.assertEqual(32, manager.sync(dry_run=False))
def test_dynamic_config_with_arpa(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
manager = Manager(get_config_filename('dynamic-arpa.yaml'))
# should sync everything across all zones, total of 7 records
# 4 normal records and 3 arpa records generated
self.assertEqual(4 + 3, manager.sync(dry_run=False))
def test_dynamic_config_with_arpa_no_normal_source(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
manager = Manager(
get_config_filename('dynamic-arpa-no-normal-source.yaml')
)
# should sync everything across all zones, total of 4 records
# 4 normal records and 0 arpa records generated since no zones to populate was found
self.assertEqual(4, manager.sync(dry_run=False))
def test_dynamic_config_unsupported_zone(self):
manager = Manager(
get_config_filename('dynamic-config-no-list-zones.yaml')


Loading…
Cancel
Save