mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Add list_zones to AutoArpa
- This makes it possible to use dynamic zone config with AutoArpa - Document what gotchas that entails - Add tests both with another source (for generating zones to populate) and without (no zones to populate)
This commit is contained in:
@ -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.
|
||||
|
@ -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
tests/config/dynamic-arpa-no-normal-source.yaml
Normal file
29
tests/config/dynamic-arpa-no-normal-source.yaml
Normal 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
tests/config/dynamic-arpa.yaml
Normal file
30
tests/config/dynamic-arpa.yaml
Normal 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
tests/config/dynamic-arpa/3.2.2.in-addr.arpa.yaml
Normal file
0
tests/config/dynamic-arpa/3.2.2.in-addr.arpa.yaml
Normal file
17
tests/config/dynamic-arpa/unit.tests.yaml
Normal file
17
tests/config/dynamic-arpa/unit.tests.yaml
Normal 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
|
@ -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')
|
||||
|
Reference in New Issue
Block a user