Check if topology/scenario combination is supported before running

This commit is contained in:
Wojciech Kozlowski 2019-04-06 19:28:19 +02:00
parent f992fc0426
commit dd663e35c6

View File

@ -79,6 +79,11 @@ if __name__ == "__main__":
"isis": Isis, "isis": Isis,
} }
supported = {
"one_node": set(["plain", "basic"]),
"two_nodes": set(["plain", "basic", "isis"]),
}
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Launch a network scenario Mininet.') description='Launch a network scenario Mininet.')
parser.add_argument('--topology', type=str, required=True, parser.add_argument('--topology', type=str, required=True,
@ -87,7 +92,11 @@ if __name__ == "__main__":
parser.add_argument('--scenario', type=str, required=True, parser.add_argument('--scenario', type=str, required=True,
choices=scenario.keys(), choices=scenario.keys(),
help='the scenario to set up in the network') help='the scenario to set up in the network')
ARGS = parser.parse_args()
args = parser.parse_args() if ARGS.scenario not in supported[ARGS.topology]:
run(topology[args.topology](), raise ValueError("Scenario \"{}\" is not supported for topology \"{}\""
scenario[args.scenario]()) .format(ARGS.scenario, ARGS.topology))
run(topology[ARGS.topology](),
scenario[ARGS.scenario]())