Files
mininet/examples/xterms.py
T
Bob Lantz 42ba5d92c3 Added sshd example, which starts up sshd on each host, allowing host access via ssh.
(It also adds a route from the root namespace to the data network via
the first OpenFlow switch, so when you ssh in you go through OpenFlow!)

Modified Network() to optionally decouple starting the network, running
tests, and stopping the network. This allows multiple tests to be run
(or additional modifications to be made to the network before actually
starting the switches and controller.)

Still tweaking xterms - it sort of works but the screen sessions are not
cleaned up, which leads to nasty garbage.
2009-12-11 02:34:21 -08:00

43 lines
1.1 KiB
Python
Executable File

#!/usr/bin/python
"Create a network and run an xterm (connected via screen) on each host."
import os
from subprocess import Popen
from mininet import init, TreeNet, Cli, quietRun
def makeXterm( node, title ):
"Run screen on a node, and hook up an xterm."
node.cmdPrint( 'screen -dmS ' + node.name )
title += ': ' + node.name
if not node.inNamespace:
title += ' (root ns)'
cmd = [ 'xterm', '-title', title ]
cmd += [ '-e', 'screen', '-D', '-RR', '-S', node.name ]
return Popen( cmd )
def makeXterms( nodes, title ):
terms = []
for node in nodes:
if not node.execed:
terms += [ makeXterm( node, title ) ]
return terms
def xterms( controllers, switches, hosts ):
terms = []
terms += makeXterms( controllers, 'controller' )
terms += makeXterms( switches, 'switch' )
terms += makeXterms( hosts, 'host' )
# Wait for completion
for term in terms:
os.waitpid( term.pid, 0 )
def treeXterms():
print "Running xterms on", os.environ[ 'DISPLAY' ]
network = TreeNet( depth=2, fanout=2, kernel=True )
network.run( xterms )
if __name__ == '__main__':
init()
treeXterms()