Skip to content
Snippets Groups Projects
Commit e3d07bc1 authored by Bob Lantz's avatar Bob Lantz
Browse files

Add 'x' command to open an X11 tunnel (and run a client)

fixes #142
parent f53866d0
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
import time import time
from mininet.log import info, output, error from mininet.log import info, output, error
from mininet.term import makeTerms from mininet.term import makeTerms, runX11
from mininet.util import quietRun, isShellBuiltin, dumpNodeConnections from mininet.util import quietRun, isShellBuiltin, dumpNodeConnections
class CLI( Cmd ): class CLI( Cmd ):
...@@ -241,6 +241,17 @@ def do_xterm( self, line, term='xterm' ): ...@@ -241,6 +241,17 @@ def do_xterm( self, line, term='xterm' ):
node = self.nodemap[ arg ] node = self.nodemap[ arg ]
self.mn.terms += makeTerms( [ node ], term = term ) self.mn.terms += makeTerms( [ node ], term = term )
def do_x( self, line ):
"""Create an X11 tunnel to the given node,
optionally starting a client."""
args = line.split()
if not args:
error( 'usage: x node [cmd args]...\n' )
else:
node = self.mn[ args[ 0 ] ]
cmd = args[ 1: ]
self.mn.terms += runX11( node, cmd )
def do_gterm( self, line ): def do_gterm( self, line ):
"Spawn gnome-terminal(s) for the given node(s)." "Spawn gnome-terminal(s) for the given node(s)."
self.do_xterm( line, term='gterm' ) self.do_xterm( line, term='gterm' )
......
...@@ -52,6 +52,12 @@ def makeTerm( node, title='Node', term='xterm', display=None ): ...@@ -52,6 +52,12 @@ def makeTerm( node, title='Node', term='xterm', display=None ):
term = node.popen( cmds[ term ] + [ display, '-e', 'env TERM=ansi bash'] ) term = node.popen( cmds[ term ] + [ display, '-e', 'env TERM=ansi bash'] )
return [ tunnel, term ] if tunnel else [ term ] return [ tunnel, term ] if tunnel else [ term ]
def runX11( node, cmd ):
"Run an X11 client on a node"
display, tunnel = tunnelX11( node )
popen = node.popen( cmd )
return [ tunnel, popen ]
def cleanUpScreens(): def cleanUpScreens():
"Remove moldy socat X11 tunnels." "Remove moldy socat X11 tunnels."
errRun( "pkill -9 -f mnexec.*socat" ) errRun( "pkill -9 -f mnexec.*socat" )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment