How to use the octodns.manager.Manager function in octodns

To help you get started, we’ve selected a few octodns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github github / octodns / tests / test_octodns_manager.py View on Github external
tc = Manager(get_config_filename('simple.yaml')) \
                .sync(dry_run=False, eligible_zones=['subzone.unit.tests.'])
            self.assertEquals(6, tc)

            # and finally the empty zone
            tc = Manager(get_config_filename('simple.yaml')) \
                .sync(dry_run=False, eligible_zones=['empty.'])
            self.assertEquals(0, tc)

            # Again with force
            tc = Manager(get_config_filename('simple.yaml')) \
                .sync(dry_run=False, force=True)
            self.assertEquals(21, tc)

            # Again with max_workers = 1
            tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \
                .sync(dry_run=False, force=True)
            self.assertEquals(21, tc)

            # Include meta
            tc = Manager(get_config_filename('simple.yaml'), max_workers=1,
                         include_meta=True) \
                .sync(dry_run=False, force=True)
            self.assertEquals(25, tc)

            # Cautious
            tc = Manager(get_config_filename('simple.yaml'), max_workers=1,
                         include_meta=True) \
                .sync(dry_run=False, cautious=True)
            # Same changes
            self.assertEquals(25, tc)
            # But we expect all of their TTLs to be 60s
github github / octodns / tests / test_octodns_manager.py View on Github external
def test_bad_provider_class_module(self):
        with self.assertRaises(Exception) as ctx:
            Manager(get_config_filename('bad-provider-class-module.yaml')) \
                .sync()
        self.assertTrue('Unknown provider class' in ctx.exception.message)
github github / octodns / tests / test_octodns_manager.py View on Github external
def test_missing_targets(self):
        with self.assertRaises(Exception) as ctx:
            Manager(get_config_filename('unknown-provider.yaml')) \
                .sync(['missing.targets.'])
        self.assertTrue('missing targets' in ctx.exception.message)
github github / octodns / tests / test_octodns_manager.py View on Github external
def test_validate_configs(self):
        Manager(get_config_filename('simple-validate.yaml')).validate_configs()

        with self.assertRaises(Exception) as ctx:
            Manager(get_config_filename('missing-sources.yaml')) \
                .validate_configs()
        self.assertTrue('missing sources' in ctx.exception.message)

        with self.assertRaises(Exception) as ctx:
            Manager(get_config_filename('unknown-provider.yaml')) \
                .validate_configs()
        self.assertTrue('unknown source' in ctx.exception.message)
github github / octodns / tests / test_octodns_manager.py View on Github external
def test_eligible_targets(self):
        with TemporaryDirectory() as tmpdir:
            environ['YAML_TMP_DIR'] = tmpdir.dirname
            # Only allow a target that doesn't exist
            tc = Manager(get_config_filename('simple.yaml')) \
                .sync(eligible_targets=['foo'])
            self.assertEquals(0, tc)
github github / octodns / tests / test_octodns_manager.py View on Github external
def test_unknown_source(self):
        with self.assertRaises(Exception) as ctx:
            Manager(get_config_filename('unknown-provider.yaml')) \
                .sync(['unknown.source.'])
        self.assertTrue('unknown source' in ctx.exception.message)
github github / octodns / tests / test_octodns_manager.py View on Github external
def test_missing_source(self):
        with self.assertRaises(Exception) as ctx:
            Manager(get_config_filename('unknown-provider.yaml')) \
                .sync(['missing.sources.'])
        self.assertTrue('missing sources' in ctx.exception.message)
github github / octodns / octodns / cmds / compare.py View on Github external
def main():
    parser = ArgumentParser(description=__doc__.split('\n')[1])

    parser.add_argument('--config-file', required=True,
                        help='The Manager configuration file to use')
    parser.add_argument('--a', nargs='+', required=True,
                        help='First source(s) to pull data from')
    parser.add_argument('--b', nargs='+', required=True,
                        help='Second source(s) to pull data from')
    parser.add_argument('--zone', default=None, required=True,
                        help='Zone to compare')

    args = parser.parse_args()

    manager = Manager(args.config_file)
    changes = manager.compare(args.a, args.b, args.zone)
    pprint(changes)
github github / octodns / octodns / cmds / report.py View on Github external
parser = ArgumentParser(description=__doc__.split('\n')[1])

    parser.add_argument('--config-file', required=True,
                        help='The Manager configuration file to use')
    parser.add_argument('--zone', required=True, help='Zone to dump')
    parser.add_argument('--source', required=True, default=[], action='append',
                        help='Source(s) to pull data from')
    parser.add_argument('--num-workers', default=4,
                        help='Number of background workers')
    parser.add_argument('--timeout', default=1,
                        help='Number seconds to wait for an answer')
    parser.add_argument('server', nargs='+', help='Servers to query')

    args = parser.parse_args()

    manager = Manager(args.config_file)

    log = getLogger('report')

    try:
        sources = [manager.providers[source] for source in args.source]
    except KeyError as e:
        raise Exception('Unknown source: {}'.format(e.args[0]))

    zone = Zone(args.zone, manager.configured_sub_zones(args.zone))
    for source in sources:
        source.populate(zone)

    print('name,type,ttl,{},consistent'.format(','.join(args.server)))
    resolvers = []
    ip_addr_re = re.compile(r'^[\d\.]+$')
    for server in args.server:
github github / octodns / octodns / cmds / sync.py View on Github external
help='Acknowledge that significant changes are being '
                        'made and do them')

    parser.add_argument('zone', nargs='*', default=[],
                        help='Limit sync to the specified zone(s)')

    # --sources isn't an option here b/c filtering sources out would be super
    # dangerous since you could easily end up with an empty zone and delete
    # everything, or even just part of things when there are multiple sources

    parser.add_argument('--target', default=[], action='append',
                        help='Limit sync to the specified target(s)')

    args = parser.parse_args()

    manager = Manager(args.config_file)
    manager.sync(eligible_zones=args.zone, eligible_targets=args.target,
                 dry_run=not args.doit, force=args.force)