Browse Source

Refactor out zone pre-processing so it can be shared with other methods

pull/1026/head
Ross McFarland 2 years ago
parent
commit
2c2d16b2cb
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
1 changed files with 31 additions and 21 deletions
  1. +31
    -21
      octodns/manager.py

+ 31
- 21
octodns/manager.py View File

@ -496,27 +496,12 @@ class Manager(object):
return sources
def sync(
self,
eligible_zones=[],
eligible_sources=[],
eligible_targets=[],
dry_run=True,
force=False,
plan_output_fh=stdout,
):
self.log.info(
'sync: eligible_zones=%s, eligible_targets=%s, dry_run=%s, '
'force=%s, plan_output_fh=%s',
eligible_zones,
eligible_targets,
dry_run,
force,
getattr(plan_output_fh, 'name', plan_output_fh.__class__.__name__),
)
zones = self.config['zones']
def _preprocess_zones(self, zones, eligible_sources):
'''
This may modify the passed in zone object, it should be ignored after
the call and the zones returned from this function should be used
instead.
'''
for name, config in list(zones.items()):
if not name.startswith('*'):
continue
@ -545,6 +530,31 @@ class Manager(object):
# remove the dynamic config element so we don't try and populate it
del zones[name]
return zones
def sync(
self,
eligible_zones=[],
eligible_sources=[],
eligible_targets=[],
dry_run=True,
force=False,
plan_output_fh=stdout,
):
self.log.info(
'sync: eligible_zones=%s, eligible_targets=%s, dry_run=%s, '
'force=%s, plan_output_fh=%s',
eligible_zones,
eligible_targets,
dry_run,
force,
getattr(plan_output_fh, 'name', plan_output_fh.__class__.__name__),
)
zones = self.config['zones']
zones = self._preprocess_zones(zones, eligible_sources)
if eligible_zones:
zones = IdnaDict({n: zones.get(n) for n in eligible_zones})


Loading…
Cancel
Save