From 9da63d4e85d44bcda3ac9be0aa7bc42e031150c9 Mon Sep 17 00:00:00 2001 From: Brandon Heller Date: Wed, 18 Aug 2010 01:45:36 -0700 Subject: [PATCH] Add dpctl command, which runs on all switches --- mininet/cli.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mininet/cli.py b/mininet/cli.py index a884316..a01f641 100644 --- a/mininet/cli.py +++ b/mininet/cli.py @@ -272,6 +272,20 @@ class CLI( Cmd ): error( 'error reading file %s\n' % args[ 0 ] ) self.inputFile = None + def do_dpctl( self, line ): + "Run dpctl command on all switches." + args = line.split() + if len(args) == 0: + error( 'usage: dpctl command [arg1] [arg2] ...\n' ) + return + if not self.mn.listenPort: + error( "can't run dpctl w/no passive listening port\n") + return + for sw in self.mn.switches: + output( '*** ' + sw.name + ' ' + ('-' * 72) + '\n' ) + output( sw.cmd( 'dpctl ' + ' '.join(args) + + ' tcp:127.0.0.1:%i' % sw.listenPort ) ) + def default( self, line ): """Called on an input line when the command prefix is not recognized. Overridden to run shell commands when a node is the first CLI argument.