Rename cliinfo debug level to output
This commit is contained in:
@@ -178,10 +178,10 @@ class MininetRunner( object ):
|
|||||||
"Setup and validate environment."
|
"Setup and validate environment."
|
||||||
|
|
||||||
# set logging verbosity
|
# set logging verbosity
|
||||||
if LEVELS[self.options.verbosity] > LEVELS['cliinfo']:
|
if LEVELS[self.options.verbosity] > LEVELS['output']:
|
||||||
print ( '*** WARNING: selected verbosity level (%s) will hide CLI '
|
print ( '*** WARNING: selected verbosity level (%s) will hide CLI '
|
||||||
'output!\n'
|
'output!\n'
|
||||||
'Please restart Mininet with -v [debug, info, cliinfo].' )
|
'Please restart Mininet with -v [debug, info, output].' )
|
||||||
lg.setLogLevel( self.options.verbosity )
|
lg.setLogLevel( self.options.verbosity )
|
||||||
|
|
||||||
# validate environment setup
|
# validate environment setup
|
||||||
|
|||||||
+7
-7
@@ -38,7 +38,7 @@ Bugs/limitations:
|
|||||||
from subprocess import call
|
from subprocess import call
|
||||||
from cmd import Cmd
|
from cmd import Cmd
|
||||||
|
|
||||||
from mininet.log import info, cliinfo
|
from mininet.log import info, output
|
||||||
|
|
||||||
class CLI( Cmd ):
|
class CLI( Cmd ):
|
||||||
"Simple command-line interface to talk to nodes."
|
"Simple command-line interface to talk to nodes."
|
||||||
@@ -84,16 +84,16 @@ class CLI( Cmd ):
|
|||||||
def do_nodes( self, args ):
|
def do_nodes( self, args ):
|
||||||
"List all nodes."
|
"List all nodes."
|
||||||
nodes = ' '.join( [ node.name for node in sorted( self.nodelist ) ] )
|
nodes = ' '.join( [ node.name for node in sorted( self.nodelist ) ] )
|
||||||
cliinfo( 'available nodes are: \n%s\n' % nodes )
|
output( 'available nodes are: \n%s\n' % nodes )
|
||||||
|
|
||||||
def do_net( self, args ):
|
def do_net( self, args ):
|
||||||
"List network connections."
|
"List network connections."
|
||||||
for switch in self.mn.switches:
|
for switch in self.mn.switches:
|
||||||
cliinfo( switch.name, '<->' )
|
output( switch.name, '<->' )
|
||||||
for intf in switch.intfs.values():
|
for intf in switch.intfs.values():
|
||||||
name = switch.connection[ intf ][ 1 ]
|
name = switch.connection[ intf ][ 1 ]
|
||||||
cliinfo( ' %s' % name )
|
output( ' %s' % name )
|
||||||
cliinfo( '\n' )
|
output( '\n' )
|
||||||
|
|
||||||
def do_sh( self, args ):
|
def do_sh( self, args ):
|
||||||
"Run an external shell command"
|
"Run an external shell command"
|
||||||
@@ -138,13 +138,13 @@ class CLI( Cmd ):
|
|||||||
def do_intfs( self, args ):
|
def do_intfs( self, args ):
|
||||||
"List interfaces."
|
"List interfaces."
|
||||||
for node in self.nodelist:
|
for node in self.nodelist:
|
||||||
cliinfo( '%s: %s\n' %
|
output( '%s: %s\n' %
|
||||||
( node.name, ' '.join( sorted( node.intfs.values() ) ) ) )
|
( node.name, ' '.join( sorted( node.intfs.values() ) ) ) )
|
||||||
|
|
||||||
def do_dump( self, args ):
|
def do_dump( self, args ):
|
||||||
"Dump node info."
|
"Dump node info."
|
||||||
for node in self.nodelist:
|
for node in self.nodelist:
|
||||||
cliinfo( '%s\n' % node )
|
output( '%s\n' % node )
|
||||||
|
|
||||||
def do_exit( self, args ):
|
def do_exit( self, args ):
|
||||||
"Exit"
|
"Exit"
|
||||||
|
|||||||
+9
-9
@@ -8,11 +8,11 @@ import types
|
|||||||
# the output of the commands they execute, plus any errors or warnings. This
|
# the output of the commands they execute, plus any errors or warnings. This
|
||||||
# level is in between info and warning. CLI info-level commands should not be
|
# level is in between info and warning. CLI info-level commands should not be
|
||||||
# printed during regression tests.
|
# printed during regression tests.
|
||||||
CLIINFO = 25
|
OUTPUT = 25
|
||||||
|
|
||||||
LEVELS = { 'debug': logging.DEBUG,
|
LEVELS = { 'debug': logging.DEBUG,
|
||||||
'info': logging.INFO,
|
'info': logging.INFO,
|
||||||
'cliinfo': CLIINFO,
|
'output': OUTPUT,
|
||||||
'warning': logging.WARNING,
|
'warning': logging.WARNING,
|
||||||
'error': logging.ERROR,
|
'error': logging.ERROR,
|
||||||
'critical': logging.CRITICAL }
|
'critical': logging.CRITICAL }
|
||||||
@@ -131,18 +131,18 @@ class MininetLogger( Logger, object ):
|
|||||||
# Not sure why this is occurring - this function definitely gets called.
|
# Not sure why this is occurring - this function definitely gets called.
|
||||||
|
|
||||||
# See /usr/lib/python2.5/logging/__init__.py; modified from warning()
|
# See /usr/lib/python2.5/logging/__init__.py; modified from warning()
|
||||||
def cliinfo( self, msg, *args, **kwargs ):
|
def output( self, msg, *args, **kwargs ):
|
||||||
"""Log 'msg % args' with severity 'CLIINFO'.
|
"""Log 'msg % args' with severity 'OUTPUT'.
|
||||||
|
|
||||||
To pass exception information, use the keyword argument exc_info
|
To pass exception information, use the keyword argument exc_info
|
||||||
with a true value, e.g.
|
with a true value, e.g.
|
||||||
|
|
||||||
logger.warning("Houston, we have a %s", "cli output", exc_info=1)
|
logger.warning("Houston, we have a %s", "cli output", exc_info=1)
|
||||||
"""
|
"""
|
||||||
if self.manager.disable >= CLIINFO:
|
if self.manager.disable >= OUTPUT:
|
||||||
return
|
return
|
||||||
if self.isEnabledFor( CLIINFO ):
|
if self.isEnabledFor( OUTPUT ):
|
||||||
self._log( CLIINFO, msg, args, kwargs )
|
self._log( OUTPUT, msg, args, kwargs )
|
||||||
|
|
||||||
# pylint: enable-msg=E0202
|
# pylint: enable-msg=E0202
|
||||||
|
|
||||||
@@ -170,6 +170,6 @@ def makeListCompatible( fn ):
|
|||||||
setattr( newfn, '__doc__', fn.__doc__ )
|
setattr( newfn, '__doc__', fn.__doc__ )
|
||||||
return newfn
|
return newfn
|
||||||
|
|
||||||
info, cliinfo, warn, error, debug = lg.info, lg.cliinfo, lg.warn, lg.error, \
|
info, output, warn, error, debug = lg.info, lg.output, lg.warn, lg.error, \
|
||||||
lg.debug = [ makeListCompatible( f ) for f in lg.info, lg.cliinfo, lg.warn,
|
lg.debug = [ makeListCompatible( f ) for f in lg.info, lg.output, lg.warn,
|
||||||
lg.error, lg.debug ]
|
lg.error, lg.debug ]
|
||||||
|
|||||||
+9
-9
@@ -89,7 +89,7 @@ import signal
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from mininet.cli import CLI
|
from mininet.cli import CLI
|
||||||
from mininet.log import info, error, debug, cliinfo
|
from mininet.log import info, error, debug, output
|
||||||
from mininet.node import Host, UserSwitch, KernelSwitch, Controller
|
from mininet.node import Host, UserSwitch, KernelSwitch, Controller
|
||||||
from mininet.node import ControllerParams
|
from mininet.node import ControllerParams
|
||||||
from mininet.util import quietRun, fixLimits
|
from mininet.util import quietRun, fixLimits
|
||||||
@@ -402,9 +402,9 @@ class Mininet( object ):
|
|||||||
ploss = None
|
ploss = None
|
||||||
if not hosts:
|
if not hosts:
|
||||||
hosts = self.hosts
|
hosts = self.hosts
|
||||||
cliinfo( '*** Ping: testing ping reachability\n' )
|
output( '*** Ping: testing ping reachability\n' )
|
||||||
for node in hosts:
|
for node in hosts:
|
||||||
cliinfo( '%s -> ' % node.name )
|
output( '%s -> ' % node.name )
|
||||||
for dest in hosts:
|
for dest in hosts:
|
||||||
if node != dest:
|
if node != dest:
|
||||||
result = node.cmd( 'ping -c1 ' + dest.IP() )
|
result = node.cmd( 'ping -c1 ' + dest.IP() )
|
||||||
@@ -416,10 +416,10 @@ class Mininet( object ):
|
|||||||
node.cmdPrint( 'route' )
|
node.cmdPrint( 'route' )
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
lost += sent - received
|
lost += sent - received
|
||||||
cliinfo( ( '%s ' % dest.name ) if received else 'X ' )
|
output( ( '%s ' % dest.name ) if received else 'X ' )
|
||||||
cliinfo( '\n' )
|
output( '\n' )
|
||||||
ploss = 100 * lost / packets
|
ploss = 100 * lost / packets
|
||||||
cliinfo( "*** Results: %i%% dropped (%d/%d lost)\n" %
|
output( "*** Results: %i%% dropped (%d/%d lost)\n" %
|
||||||
( ploss, lost, packets ) )
|
( ploss, lost, packets ) )
|
||||||
return ploss
|
return ploss
|
||||||
|
|
||||||
@@ -456,8 +456,8 @@ class Mininet( object ):
|
|||||||
else:
|
else:
|
||||||
assert len( hosts ) == 2
|
assert len( hosts ) == 2
|
||||||
host0, host1 = hosts
|
host0, host1 = hosts
|
||||||
cliinfo( '*** Iperf: testing ' + l4Type + ' bandwidth between ' )
|
output( '*** Iperf: testing ' + l4Type + ' bandwidth between ' )
|
||||||
cliinfo( "%s and %s\n" % ( host0.name, host1.name ) )
|
output( "%s and %s\n" % ( host0.name, host1.name ) )
|
||||||
host0.cmd( 'killall -9 iperf' )
|
host0.cmd( 'killall -9 iperf' )
|
||||||
iperfArgs = 'iperf '
|
iperfArgs = 'iperf '
|
||||||
bwArgs = ''
|
bwArgs = ''
|
||||||
@@ -476,7 +476,7 @@ class Mininet( object ):
|
|||||||
result = [ self._parseIperf( server ), self._parseIperf( client ) ]
|
result = [ self._parseIperf( server ), self._parseIperf( client ) ]
|
||||||
if l4Type == 'UDP':
|
if l4Type == 'UDP':
|
||||||
result.insert( 0, udpBw )
|
result.insert( 0, udpBw )
|
||||||
cliinfo( '*** Results: %s\n' % result )
|
output( '*** Results: %s\n' % result )
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def iperfUdp( self, udpBw='10M' ):
|
def iperfUdp( self, udpBw='10M' ):
|
||||||
|
|||||||
Reference in New Issue
Block a user