def main(fn: str): mn = json.loads(Path(f'{fn}.mn').read_text()) hosts = [i['opts']['hostname'] for i in mn['hosts']] switches = [i['opts']['hostname'] for i in mn['switches']] links = [(i['src'], i['dest'], i.get('opts', dict()).get('bw')) for i in mn['links']] Path(f'{fn}.json').write_text(json.dumps([hosts, switches, links])) renderer(fn)
def main(fn: str = 'clos5'): reset_iters() topo = create_topo() reset_iters() Path(f'{fn}.json').write_text(json.dumps(topo)) renderer(fn)
def main(fn: str = 'bigtopo'): reset_iters() datacenter = create_datacenter() reset_iters() Path(f'{fn}.json').write_text(json.dumps(datacenter)) renderer(fn)