mirror of
https://github.com/Wojtek242/route0.git
synced 2024-11-22 15:15:26 +01:00
Check if topology/scenario combination is supported before running
This commit is contained in:
parent
f992fc0426
commit
dd663e35c6
15
route-0.py
15
route-0.py
@ -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]())
|
||||||
|
Loading…
Reference in New Issue
Block a user