Move dumpNetConnections to util() because it's useful!

This commit is contained in:
Bob Lantz
2012-03-23 18:17:49 -07:00
parent 74ea006d92
commit beb05a71c8
2 changed files with 27 additions and 13 deletions
+2 -13
View File
@@ -33,7 +33,7 @@ import sys
from mininet.log import info, output, error
from mininet.term import makeTerms
from mininet.util import quietRun, isShellBuiltin
from mininet.util import quietRun, isShellBuiltin, dumpNodeConnections
class CLI( Cmd ):
"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 ) ] )
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 ):
"List network connections."
for node in self.nodelist:
output( node.name, '<->' )
self.dump_connections( node )
output( '\n' )
dumpNodeConnections( self.nodelist )
def do_sh( self, line ):
"Run an external shell command"
+25
View File
@@ -187,6 +187,31 @@ def moveIntf( intf, node, printError=False, retries=3, delaySecs=0.001 ):
printError: if true, print error"""
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