mirror of
https://github.com/Wojtek242/route0.git
synced 2024-11-22 15:15:26 +01:00
Run mininet from top-level directory
This commit is contained in:
parent
44379cbfdc
commit
83204c6584
@ -1,26 +1,16 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
|
|
||||||
from mininet.net import Mininet
|
from mininet.net import Mininet
|
||||||
from mininet.cli import CLI
|
from mininet.cli import CLI
|
||||||
|
|
||||||
topo_dir = os.path.join(
|
|
||||||
os.path.dirname(os.path.realpath(__file__)),
|
|
||||||
'../..')
|
|
||||||
sys.path.append(topo_dir)
|
|
||||||
from topo import NetTopo
|
|
||||||
|
|
||||||
root_dir = os.path.join(
|
|
||||||
os.path.dirname(os.path.realpath(__file__)),
|
|
||||||
'../../../..')
|
|
||||||
sys.path.append(root_dir)
|
|
||||||
from router import Router
|
from router import Router
|
||||||
|
from topology.two_nodes.topo import NetTopo as TwoNodes
|
||||||
|
|
||||||
|
|
||||||
def scenario():
|
def run(topo):
|
||||||
"""Start the network scenario.
|
"""Start a network scenario.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
os.system("rm -f /tmp/R*.log /tmp/R*.pid /tmp/R*.out")
|
os.system("rm -f /tmp/R*.log /tmp/R*.pid /tmp/R*.out")
|
||||||
@ -28,27 +18,27 @@ def scenario():
|
|||||||
os.system("mn -c >/dev/null 2>&1")
|
os.system("mn -c >/dev/null 2>&1")
|
||||||
os.system("killall -9 zebra staticd > /dev/null 2>&1")
|
os.system("killall -9 zebra staticd > /dev/null 2>&1")
|
||||||
|
|
||||||
net = Mininet(topo=NetTopo(), switch=Router)
|
net = Mininet(topo=topo(), switch=Router)
|
||||||
net.start()
|
net.start()
|
||||||
|
|
||||||
for node in net.switches:
|
for node in net.switches:
|
||||||
# Start Zebra (routing table daemon)
|
# Start Zebra (routing table daemon)
|
||||||
node.cmd("/usr/lib/frr/zebra"
|
node.cmd("/usr/lib/frr/zebra"
|
||||||
" -f two-nodes/zebra/%s.conf"
|
" -f %s/zebra/%s.conf"
|
||||||
" -d"
|
" -d"
|
||||||
" -i /tmp/%s-zebra.pid"
|
" -i /tmp/%s-zebra.pid"
|
||||||
" > /tmp/%s-zebra.out 2>&1"
|
" > /tmp/%s-zebra.out 2>&1"
|
||||||
% (node.name, node.name, node.name))
|
% (topo.topo_dir, node.name, node.name, node.name))
|
||||||
node.waitOutput()
|
node.waitOutput()
|
||||||
|
|
||||||
if node.name.startswith('h'):
|
if node.name.startswith('h'):
|
||||||
# Start static route daemon
|
# Start static route daemon
|
||||||
node.cmd("/usr/lib/frr/staticd"
|
node.cmd("/usr/lib/frr/staticd"
|
||||||
" -f two-nodes/staticd/%s.conf"
|
" -f %s/staticd/%s.conf"
|
||||||
" -d"
|
" -d"
|
||||||
" -i /tmp/%s-staticd.pid"
|
" -i /tmp/%s-staticd.pid"
|
||||||
" > /tmp/%s-staticd.out 2>&1"
|
" > /tmp/%s-staticd.out 2>&1"
|
||||||
% (node.name, node.name, node.name))
|
% (topo.topo_dir, node.name, node.name, node.name))
|
||||||
node.waitOutput()
|
node.waitOutput()
|
||||||
|
|
||||||
if node.name.startswith('R'):
|
if node.name.startswith('R'):
|
||||||
@ -66,4 +56,4 @@ def scenario():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
scenario()
|
run(TwoNodes)
|
0
topology/__init__.py
Normal file
0
topology/__init__.py
Normal file
0
topology/two_nodes/__init__.py
Normal file
0
topology/two_nodes/__init__.py
Normal file
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
|
|
||||||
|
|
||||||
@ -7,6 +9,8 @@ class NetTopo(Topo):
|
|||||||
"""The network topology.
|
"""The network topology.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
topo_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Add default members to class.
|
# Add default members to class.
|
||||||
super(NetTopo, self).__init__()
|
super(NetTopo, self).__init__()
|
||||||
|
Loading…
Reference in New Issue
Block a user