mirror of
https://github.com/Wojtek242/route0.git
synced 2024-11-25 08:15:25 +01:00
Add command-line arguments
This commit is contained in:
parent
a7af7c9e25
commit
e843347a36
25
route-0.py
25
route-0.py
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from mininet.net import Mininet
|
from mininet.net import Mininet
|
||||||
@ -7,7 +8,7 @@ from mininet.cli import CLI
|
|||||||
|
|
||||||
from router import Router
|
from router import Router
|
||||||
from topology.two_nodes.topo import NetTopo as TwoNodes
|
from topology.two_nodes.topo import NetTopo as TwoNodes
|
||||||
from scenario import Basic
|
from scenario import Basic, Plain
|
||||||
|
|
||||||
|
|
||||||
def start_deamon(node, daemon, conf_dir):
|
def start_deamon(node, daemon, conf_dir):
|
||||||
@ -62,4 +63,24 @@ def run(topo, scenario):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run(TwoNodes(), Basic())
|
topology = {
|
||||||
|
"two_nodes": TwoNodes,
|
||||||
|
}
|
||||||
|
|
||||||
|
scenario = {
|
||||||
|
"plain": Plain,
|
||||||
|
"basic": Basic,
|
||||||
|
}
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Launch a network scenario Mininet.')
|
||||||
|
parser.add_argument('--topology', type=str, required=True,
|
||||||
|
choices=topology.keys(),
|
||||||
|
help='the topology of the network')
|
||||||
|
parser.add_argument('--scenario', type=str, required=True,
|
||||||
|
choices=scenario.keys(),
|
||||||
|
help='the scenario to set up in the network')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
run(topology[args.topology](),
|
||||||
|
scenario[args.scenario]())
|
||||||
|
Loading…
Reference in New Issue
Block a user