From ce9cd5bee531779c19b0b68a7300c4e5a45cfbf4 Mon Sep 17 00:00:00 2001 From: Brandon Heller Date: Mon, 5 Apr 2010 01:06:30 -0700 Subject: [PATCH] Add command to spawn an xterm --- mininet/cli.py | 13 +++++++++++++ mininet/xterm.py | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mininet/cli.py b/mininet/cli.py index 5418d69..8ea0345 100644 --- a/mininet/cli.py +++ b/mininet/cli.py @@ -34,6 +34,7 @@ from subprocess import call from cmd import Cmd from mininet.log import info, output, error +from mininet.xterm import makeXterms class CLI( Cmd ): @@ -162,6 +163,18 @@ class CLI( Cmd ): else: self.mn.configLinkStatus( *args ) + def do_xterm( self, args ): + "Spawn xterm for the given node." + args = args.split() + if not args: + error( 'please specify node list: xterm node1 node2 ...\n' ) + else: + for arg in args: + if arg not in self.nodemap: + error( 'arg not in network: %s\n' % arg ) + else: + self.mn.terms += makeXterms( [ self.nodemap[ arg ] ] ) + def do_exit( self, args ): "Exit" return 'exited by user command' diff --git a/mininet/xterm.py b/mininet/xterm.py index e493366..8883d83 100644 --- a/mininet/xterm.py +++ b/mininet/xterm.py @@ -9,7 +9,7 @@ import re from subprocess import Popen from mininet.util import quietRun -def makeXterm( node, title ): +def makeXterm( node, title = '' ): """Run screen on a node, and hook up an xterm. node: Node object title: base title @@ -34,7 +34,7 @@ def cleanUpScreens(): if m: quietRun( 'screen -S ' + m.group( 1 ) + ' -X kill' ) -def makeXterms( nodes, title ): +def makeXterms( nodes, title = '' ): """Create XTerms. nodes: list of Node objects title: base title for each