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.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() )
|
||||||
|
|||||||
@@ -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 ):
|
||||||
|
|||||||
Reference in New Issue
Block a user