adding 'ports' command to cli

This commit is contained in:
cody burkard
2014-09-15 15:33:58 -07:00
parent cde6c3aaf4
commit 08643fe679
2 changed files with 15 additions and 1 deletions
+6 -1
View File
@@ -36,7 +36,8 @@ import atexit
from mininet.log import info, output, error from mininet.log import info, output, error
from mininet.term import makeTerms, runX11 from mininet.term import makeTerms, runX11
from mininet.util import quietRun, isShellBuiltin, dumpNodeConnections from mininet.util import ( quietRun, isShellBuiltin, dumpNodeConnections,
dumpPorts )
class CLI( Cmd ): class CLI( Cmd ):
"Simple command-line interface to talk to nodes." "Simple command-line interface to talk to nodes."
@@ -127,6 +128,10 @@ class CLI( Cmd ):
nodes = ' '.join( sorted( self.mn ) ) nodes = ' '.join( sorted( self.mn ) )
output( 'available nodes are: \n%s\n' % nodes ) output( 'available nodes are: \n%s\n' % nodes )
def do_ports( self, line ):
"display ports and interfaces for each switch"
dumpPorts( self.mn.switches )
def do_net( self, _line ): def do_net( self, _line ):
"List network connections." "List network connections."
dumpNodeConnections( self.mn.values() ) dumpNodeConnections( self.mn.values() )
+9
View File
@@ -237,6 +237,15 @@ def dumpNetConnections( net ):
nodes = net.controllers + net.switches + net.hosts nodes = net.controllers + net.switches + net.hosts
dumpNodeConnections( nodes ) dumpNodeConnections( nodes )
def dumpPorts( switches ):
"dump interface to openflow port mappings for each switch"
for switch in switches:
output( '%s ' % switch.name )
for intf in switch.intfList():
port = switch.ports[ intf ]
output( '%s:%d ' % ( intf, port ) )
output( '\n' )
# IP and Mac address formatting and parsing # IP and Mac address formatting and parsing
def _colonHex( val, bytecount ): def _colonHex( val, bytecount ):