Browse Source

octodns-dump support all zones, including dynamic-config

pull/1026/head
Ross McFarland 2 years ago
parent
commit
49bdf9e4df
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
3 changed files with 40 additions and 10 deletions
  1. +4
    -1
      octodns/cmds/dump.py
  2. +19
    -8
      octodns/manager.py
  3. +17
    -1
      tests/test_octodns_manager.py

+ 4
- 1
octodns/cmds/dump.py View File

@ -39,7 +39,10 @@ def main():
default=False,
help='Split the dumped zone into a YAML file per record',
)
parser.add_argument('zone', help='Zone to dump')
parser.add_argument(
'zone',
help="Zone to dump, '*' (single quoted to avoid expansion) for all configured zones",
)
parser.add_argument('source', nargs='+', help='Source(s) to pull data from')
args = parser.parse_args()


+ 19
- 8
octodns/manager.py View File

@ -851,14 +851,25 @@ class Manager(object):
clz = SplitYamlProvider
target = clz('dump', output_dir)
zone = self.get_zone(zone)
for source in sources:
source.populate(zone, lenient=lenient)
plan = target.plan(zone)
if plan is None:
plan = Plan(zone, zone, [], False)
target.apply(plan)
zones = self.config['zones']
zones = self._preprocess_zones(zones, [s.id for s in sources])
if '*' in zone:
# we want to do everything, just need the names though
zones = zones.keys()
else:
# we want to do a specific zone
zones = [zone]
for zone in zones:
zone = self.get_zone(zone)
for source in sources:
source.populate(zone, lenient=lenient)
plan = target.plan(zone)
if plan is None:
plan = Plan(zone, zone, [], False)
target.apply(plan)
def validate_configs(self):
# TODO: this code can probably be shared with stuff in sync


+ 17
- 1
tests/test_octodns_manager.py View File

@ -2,7 +2,7 @@
#
#
from os import environ
from os import environ, listdir
from os.path import dirname, isfile, join
from unittest import TestCase
from unittest.mock import MagicMock, patch
@ -371,12 +371,28 @@ class TestManager(TestCase):
)
self.assertEqual('Unknown source: nope', str(ctx.exception))
# specific zone
manager.dump(
zone='unit.tests.',
output_dir=tmpdir.dirname,
split=True,
sources=['in'],
)
self.assertEqual(['unit.tests.'], listdir(tmpdir.dirname))
# all configured zones
manager.dump(
zone='*', output_dir=tmpdir.dirname, split=True, sources=['in']
)
self.assertEqual(
[
'empty.',
'sub.txt.unit.tests.',
'subzone.unit.tests.',
'unit.tests.',
],
sorted(listdir(tmpdir.dirname)),
)
# make sure this fails with an ManagerException and not a KeyError
# when trying to find sub zones


Loading…
Cancel
Save