Merge pull request #379 from cdburkard/devel/show_ports
adding 'ports' command to cli
This commit is contained in:
+6
-1
@@ -36,7 +36,8 @@ import atexit
|
||||
|
||||
from mininet.log import info, output, error
|
||||
from mininet.term import makeTerms, runX11
|
||||
from mininet.util import quietRun, isShellBuiltin, dumpNodeConnections
|
||||
from mininet.util import ( quietRun, isShellBuiltin, dumpNodeConnections,
|
||||
dumpPorts )
|
||||
|
||||
class CLI( Cmd ):
|
||||
"Simple command-line interface to talk to nodes."
|
||||
@@ -127,6 +128,10 @@ class CLI( Cmd ):
|
||||
nodes = ' '.join( sorted( self.mn ) )
|
||||
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 ):
|
||||
"List network connections."
|
||||
dumpNodeConnections( self.mn.values() )
|
||||
|
||||
@@ -234,6 +234,15 @@ def dumpNetConnections( net ):
|
||||
nodes = net.controllers + net.switches + net.hosts
|
||||
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
|
||||
|
||||
def _colonHex( val, bytecount ):
|
||||
|
||||
Reference in New Issue
Block a user