Move dumpNetConnections to util() because it's useful!
This commit is contained in:
+2
-13
@@ -33,7 +33,7 @@ import sys
|
|||||||
|
|
||||||
from mininet.log import info, output, error
|
from mininet.log import info, output, error
|
||||||
from mininet.term import makeTerms
|
from mininet.term import makeTerms
|
||||||
from mininet.util import quietRun, isShellBuiltin
|
from mininet.util import quietRun, isShellBuiltin, dumpNodeConnections
|
||||||
|
|
||||||
class CLI( Cmd ):
|
class CLI( Cmd ):
|
||||||
"Simple command-line interface to talk to nodes."
|
"Simple command-line interface to talk to nodes."
|
||||||
@@ -109,21 +109,10 @@ class CLI( Cmd ):
|
|||||||
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 )
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def dump_connections( node ):
|
|
||||||
"Helper method: dump connections to node"
|
|
||||||
for intf in node.intfList():
|
|
||||||
if intf.link:
|
|
||||||
intfs = [ intf.link.intf1, intf.link.intf2 ]
|
|
||||||
intfs.remove( intf )
|
|
||||||
output( ' %s' % intfs[ 0 ].node )
|
|
||||||
|
|
||||||
def do_net( self, _line ):
|
def do_net( self, _line ):
|
||||||
"List network connections."
|
"List network connections."
|
||||||
for node in self.nodelist:
|
dumpNodeConnections( self.nodelist )
|
||||||
output( node.name, '<->' )
|
|
||||||
self.dump_connections( node )
|
|
||||||
output( '\n' )
|
|
||||||
|
|
||||||
def do_sh( self, line ):
|
def do_sh( self, line ):
|
||||||
"Run an external shell command"
|
"Run an external shell command"
|
||||||
|
|||||||
@@ -187,6 +187,31 @@ def moveIntf( intf, node, printError=False, retries=3, delaySecs=0.001 ):
|
|||||||
printError: if true, print error"""
|
printError: if true, print error"""
|
||||||
retry( retries, delaySecs, moveIntfNoRetry, intf, node, printError )
|
retry( retries, delaySecs, moveIntfNoRetry, intf, node, printError )
|
||||||
|
|
||||||
|
# Support for dumping network
|
||||||
|
|
||||||
|
def dumpNodeConnections( nodes ):
|
||||||
|
"Dump connections to/from nodes."
|
||||||
|
|
||||||
|
def dumpConnections( node ):
|
||||||
|
"Helper function: dump connections to node"
|
||||||
|
for intf in node.intfList():
|
||||||
|
output( ' %s:' % intf )
|
||||||
|
if intf.link:
|
||||||
|
intfs = [ intf.link.intf1, intf.link.intf2 ]
|
||||||
|
intfs.remove( intf )
|
||||||
|
output( intfs[ 0 ] )
|
||||||
|
else:
|
||||||
|
output( ' ' )
|
||||||
|
|
||||||
|
for node in nodes:
|
||||||
|
output( node.name )
|
||||||
|
dumpConnections( node )
|
||||||
|
output( '\n' )
|
||||||
|
|
||||||
|
def dumpNetConnections( net ):
|
||||||
|
"Dump connections in network"
|
||||||
|
nodes = net.controllers + net.switches + net.hosts
|
||||||
|
dumpNodeConnections( nodes )
|
||||||
|
|
||||||
# IP and Mac address formatting and parsing
|
# IP and Mac address formatting and parsing
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user