def run_test(fname, local_defaults="topology-defaults.yml"): topology = read_topology.load(fname, local_defaults, "../topology-defaults.yml") common.exit_on_error() augment.main.transform(topology) common.exit_on_error() return topology
def main(): args = parse() topology = read_topology.load(args.topology,None,args.defaults) common.exit_on_error() augment.main.transform(topology) common.exit_on_error() dfname = args.xpand or ("exp-"+args.topology) create_expected_results_file(topology,dfname)
def setup(topo, defaults): common.null_to_string(topo.addressing) addrs = setup_pools(defaults.addressing + topo.addressing, defaults) common.print_verbose("Addressing\n=================") common.print_verbose(addrs.to_yaml()) validate_pools(addrs) common.exit_on_error() topo.pools = create_pool_generators(addrs) topo.addressing = addrs common.exit_on_error()
def setup(topo, defaults={}): addrs = topo.get('addressing', {}) addrs = common.merge_defaults(addrs, defaults.get('addressing')) addrs = setup_pools(addrs, defaults) topo['addressing'] = addrs common.print_verbose("Addressing\n=================") common.print_verbose(yaml.dump(addrs)) validate_pools(addrs) common.exit_on_error() topo['pools'] = create_pool_generators(addrs) common.exit_on_error()
def main(): args = parse() topology = read_topology.load(args.topology, None, args.defaults) common.exit_on_error() augment.main.transform(topology) common.exit_on_error() result = utils.transformation_results_yaml(topology) expected = pathlib.Path('exp-' + args.topology).read_text() if result == expected: print("Results match") else: print('\n'.join( list( difflib.unified_diff(expected.split('\n'), result.split('\n'), fromfile='expected', tofile='actual'))))
def transform(topology): topology.setdefault('defaults', {}) augment.topology.check_required_elements(topology) augment.topology.adjust_global_parameters(topology) common.exit_on_error() topology.nodes = augment.nodes.adjust_node_list(topology.nodes) common.exit_on_error() if 'links' in topology: topology.links = augment.links.adjust_link_list(topology.links) common.exit_on_error() addressing.setup(topology, topology.defaults) adjust_modules(topology) ndict = augment.nodes.transform(topology, topology.defaults, topology.pools) common.exit_on_error() if 'links' in topology: augment.links.transform(topology.links, topology.defaults, ndict, topology.pools) common.exit_on_error() del topology.pools
def augment(topology): check_required_elements(topology) topology['nodes'] = adjust_node_list(topology['nodes']) common.exit_on_error() if 'links' in topology: topology['links'] = adjust_link_list(topology['links']) common.exit_on_error() if not 'defaults' in topology: topology['defaults'] = {} addressing.setup(topology, topology['defaults']) ndict = augment_nodes(topology, topology['defaults'], topology['pools']) common.exit_on_error() if 'links' in topology: augment_links(topology['links'], topology['defaults'], ndict, topology['pools']) common.exit_on_error() del topology['pools']