Changed 'args' to 'line' and fixed iperfudp.

This commit is contained in:
Bob Lantz
2010-04-12 18:56:50 -07:00
parent caf024bc98
commit 2a554ae33c
+27 -26
View File
@@ -95,18 +95,18 @@ class CLI( Cmd ):
' mininet> xterm h2\n\n' ' mininet> xterm h2\n\n'
) )
def do_help( self, args ): def do_help( self, line ):
"Describe available CLI commands." "Describe available CLI commands."
Cmd.do_help( self, args ) Cmd.do_help( self, line )
if args is '': if line is '':
output( self.helpStr ) output( self.helpStr )
def do_nodes( self, args ): def do_nodes( self, line ):
"List all nodes." "List all nodes."
nodes = ' '.join( [ node.name for node in sorted( self.nodelist ) ] ) nodes = ' '.join( [ node.name for node in sorted( self.nodelist ) ] )
output( 'available nodes are: \n%s\n' % nodes ) output( 'available nodes are: \n%s\n' % nodes )
def do_net( self, args ): def do_net( self, line ):
"List network connections." "List network connections."
for switch in self.mn.switches: for switch in self.mn.switches:
output( switch.name, '<->' ) output( switch.name, '<->' )
@@ -115,18 +115,18 @@ class CLI( Cmd ):
output( ' %s' % name ) output( ' %s' % name )
output( '\n' ) output( '\n' )
def do_sh( self, args ): def do_sh( self, line ):
"Run an external shell command" "Run an external shell command"
call( args, shell=True ) call( line, shell=True )
# do_py() needs to catch any exception during eval() # do_py() needs to catch any exception during eval()
# pylint: disable-msg=W0703 # pylint: disable-msg=W0703
def do_py( self, args ): def do_py( self, line ):
"""Evaluate a Python expression. """Evaluate a Python expression.
Node names may be used, e.g.: h1.cmd('ls')""" Node names may be used, e.g.: h1.cmd('ls')"""
try: try:
result = eval( args, globals(), self.nodemap ) result = eval( line, globals(), self.nodemap )
if not result: if not result:
return return
elif isinstance( result, str ): elif isinstance( result, str ):
@@ -138,37 +138,38 @@ class CLI( Cmd ):
# pylint: enable-msg=W0703 # pylint: enable-msg=W0703
def do_pingall( self, args ): def do_pingall( self, line ):
"Ping between all hosts." "Ping between all hosts."
self.mn.pingAll() self.mn.pingAll()
def do_pingpair( self, args ): def do_pingpair( self, line ):
"Ping between first two hosts, useful for testing." "Ping between first two hosts, useful for testing."
self.mn.pingPair() self.mn.pingPair()
def do_iperf( self, args ): def do_iperf( self, line ):
"Simple iperf TCP test between two hosts." "Simple iperf TCP test between two hosts."
self.mn.iperf() self.mn.iperf()
def do_iperfudp( self, args ): def do_iperfudp( self, line ):
"Simple iperf UDP test between two hosts." "Simple iperf UDP test between two hosts."
args = line.split()
udpBw = args[ 0 ] if len( args ) else '10M' udpBw = args[ 0 ] if len( args ) else '10M'
self.mn.iperfUdp( udpBw ) self.mn.iperfUdp( udpBw )
def do_intfs( self, args ): def do_intfs( self, line ):
"List interfaces." "List interfaces."
for node in self.nodelist: for node in self.nodelist:
output( '%s: %s\n' % output( '%s: %s\n' %
( node.name, ' '.join( sorted( node.intfs.values() ) ) ) ) ( node.name, ' '.join( sorted( node.intfs.values() ) ) ) )
def do_dump( self, args ): def do_dump( self, line ):
"Dump node info." "Dump node info."
for node in self.nodelist: for node in self.nodelist:
output( '%s\n' % node ) output( '%s\n' % node )
def do_link( self, args ): def do_link( self, line ):
"Bring link(s) between two nodes up or down." "Bring link(s) between two nodes up or down."
args = args.split() args = line.split()
if len(args) != 3: if len(args) != 3:
error( 'invalid number of args: link end1 end2 [up down]\n' ) error( 'invalid number of args: link end1 end2 [up down]\n' )
elif args[ 2 ] not in [ 'up', 'down' ]: elif args[ 2 ] not in [ 'up', 'down' ]:
@@ -176,9 +177,9 @@ class CLI( Cmd ):
else: else:
self.mn.configLinkStatus( *args ) self.mn.configLinkStatus( *args )
def do_xterm( self, args, term='xterm' ): def do_xterm( self, line, term='xterm' ):
"Spawn xterm(s) for the given node(s)." "Spawn xterm(s) for the given node(s)."
args = args.split() args = line.split()
if not args: if not args:
error( 'usage: %s node1 node2 ...\n' % term ) error( 'usage: %s node1 node2 ...\n' % term )
else: else:
@@ -189,22 +190,22 @@ class CLI( Cmd ):
node = self.nodemap[ arg ] node = self.nodemap[ arg ]
self.mn.terms += makeTerms( [ node ], term = term ) self.mn.terms += makeTerms( [ node ], term = term )
def do_gterm( self, args ): 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( args, term='gterm' ) self.do_xterm( line, term='gterm' )
def do_exit( self, args ): def do_exit( self, line ):
"Exit" "Exit"
return 'exited by user command' return 'exited by user command'
def do_quit( self, args ): def do_quit( self, line ):
"Exit" "Exit"
return self.do_exit( args ) return self.do_exit( line )
def do_EOF( self, args ): def do_EOF( self, line ):
"Exit" "Exit"
output( '\n' ) output( '\n' )
return self.do_exit( args ) return self.do_exit( line )
def isatty( self ): def isatty( self ):
"Is our standard input a tty?" "Is our standard input a tty?"