Spacing tweaks for pep8 checker

This commit is contained in:
Bob Lantz
2014-12-08 15:10:32 -08:00
parent ccd6b5cd7d
commit 7a3159c9af
28 changed files with 104 additions and 95 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ BIN = $(MN)
PYSRC = $(MININET) $(TEST) $(EXAMPLES) $(BIN) PYSRC = $(MININET) $(TEST) $(EXAMPLES) $(BIN)
MNEXEC = mnexec MNEXEC = mnexec
MANPAGES = mn.1 mnexec.1 MANPAGES = mn.1 mnexec.1
P8IGN = E251,E201,E302,E202 P8IGN = E251,E201,E302,E202,E126,E127,E203,E226
BINDIR = /usr/bin BINDIR = /usr/bin
MANDIR = /usr/share/man/man1 MANDIR = /usr/share/man/man1
DOCDIRS = doc/html doc/latex DOCDIRS = doc/html doc/latex
+5 -2
View File
@@ -206,7 +206,9 @@ class MininetRunner( object ):
opts.add_option( '--custom', action='callback', opts.add_option( '--custom', action='callback',
callback=self.custom, callback=self.custom,
type='string', type='string',
help='read custom classes or params from .py file(s)' ) help='read custom classes or params from .py file(s)'
)
opts.add_option( '--test', type='choice', choices=TESTS, opts.add_option( '--test', type='choice', choices=TESTS,
default=TESTS[ 0 ], default=TESTS[ 0 ],
help='|'.join( TESTS ) ) help='|'.join( TESTS ) )
@@ -344,7 +346,8 @@ class MininetRunner( object ):
listenPort=listenPort ) listenPort=listenPort )
if self.options.ensure_value( 'nat', False ): if self.options.ensure_value( 'nat', False ):
nat = mn.addNAT( *self.options.nat_args, **self.options.nat_kwargs ) nat = mn.addNAT( *self.options.nat_args,
**self.options.nat_kwargs )
nat.configDefault() nat.configDefault()
if self.options.pre: if self.options.pre:
+10 -9
View File
@@ -254,8 +254,10 @@ class RemoteMixin( object ):
def addIntf( self, *args, **kwargs ): def addIntf( self, *args, **kwargs ):
"Override: use RemoteLink.moveIntf" "Override: use RemoteLink.moveIntf"
return super( RemoteMixin, self).addIntf( *args, return super( RemoteMixin,
moveIntfFn=RemoteLink.moveIntf, **kwargs ) self).addIntf( *args,
moveIntfFn=RemoteLink.moveIntf,
**kwargs )
def cleanup( self ): def cleanup( self ):
"Help python collect its garbage." "Help python collect its garbage."
@@ -277,7 +279,9 @@ class RemoteHost( RemoteNode ):
class RemoteOVSSwitch( RemoteMixin, OVSSwitch ): class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
"Remote instance of Open vSwitch" "Remote instance of Open vSwitch"
OVSVersions = {} OVSVersions = {}
def isOldOVS( self ): def isOldOVS( self ):
"Is remote switch using an old OVS version?" "Is remote switch using an old OVS version?"
cls = type( self ) cls = type( self )
@@ -291,9 +295,7 @@ class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
StrictVersion( '1.10' ) ) StrictVersion( '1.10' ) )
class RemoteLink( Link ): class RemoteLink( Link ):
"A RemoteLink is a link between nodes which may be on different servers" "A RemoteLink is a link between nodes which may be on different servers"
def __init__( self, node1, node2, **kwargs ): def __init__( self, node1, node2, **kwargs ):
@@ -561,7 +563,7 @@ class HostSwitchBinPlacer( Placer ):
scount = len( self.servers ) scount = len( self.servers )
self.hbin = max( int( len( self.hosts ) / scount ), 1 ) self.hbin = max( int( len( self.hosts ) / scount ), 1 )
self.sbin = max( int( len( self.switches ) / scount ), 1 ) self.sbin = max( int( len( self.switches ) / scount ), 1 )
self.cbin = max( int( len( self.controllers ) / scount ) , 1 ) self.cbin = max( int( len( self.controllers ) / scount ), 1 )
info( 'scount:', scount ) info( 'scount:', scount )
info( 'bins:', self.hbin, self.sbin, self.cbin, '\n' ) info( 'bins:', self.hbin, self.sbin, self.cbin, '\n' )
self.servdict = dict( enumerate( self.servers ) ) self.servdict = dict( enumerate( self.servers ) )
@@ -589,7 +591,6 @@ class HostSwitchBinPlacer( Placer ):
return server return server
# The MininetCluster class is not strictly necessary. # The MininetCluster class is not strictly necessary.
# However, it has several purposes: # However, it has several purposes:
# 1. To set up ssh connection sharing/multiplexing # 1. To set up ssh connection sharing/multiplexing
@@ -667,7 +668,8 @@ class MininetCluster( Mininet ):
result |= code result |= code
if result: if result:
error( '*** Server precheck failed.\n' error( '*** Server precheck failed.\n'
'*** Make sure that the above ssh command works correctly.\n' '*** Make sure that the above ssh command works'
' correctly.\n'
'*** You may also need to run mn -c on all nodes, and/or\n' '*** You may also need to run mn -c on all nodes, and/or\n'
'*** use sudo -E.\n' ) '*** use sudo -E.\n' )
sys.exit( 1 ) sys.exit( 1 )
@@ -679,7 +681,6 @@ class MininetCluster( Mininet ):
kwargs[ 'splitInit' ] = True kwargs[ 'splitInit' ] = True
return Mininet.addHost( *args, **kwargs ) return Mininet.addHost( *args, **kwargs )
def placeNodes( self ): def placeNodes( self ):
"""Place nodes on servers (if they don't have a server), and """Place nodes on servers (if they don't have a server), and
start shell processes""" start shell processes"""
@@ -695,7 +696,7 @@ class MininetCluster( Mininet ):
for node in nodes: for node in nodes:
config = self.topo.nodeInfo( node ) config = self.topo.nodeInfo( node )
# keep local server name consistent accross nodes # keep local server name consistent accross nodes
if 'server' in config.keys() and config[ 'server' ] == None: if 'server' in config.keys() and config[ 'server' ] is None:
config[ 'server' ] = 'localhost' config[ 'server' ] = 'localhost'
server = config.setdefault( 'server', placer.place( node ) ) server = config.setdefault( 'server', placer.place( node ) )
if server: if server:
-1
View File
@@ -88,7 +88,6 @@ class ClusterCLI( CLI ):
else: else:
output( 'All nodes are still running.\n' ) output( 'All nodes are still running.\n' )
def do_placement( self, _line ): def do_placement( self, _line ):
"Describe node placement" "Describe node placement"
mn = self.mn mn = self.mn
-1
View File
@@ -20,4 +20,3 @@ def demo():
if __name__ == '__main__': if __name__ == '__main__':
setLogLevel( 'info' ) setLogLevel( 'info' )
demo() demo()
+2 -1
View File
@@ -5,7 +5,8 @@ This example shows how to add an interface (for example a real
hardware interface) to a network after the network is created. hardware interface) to a network after the network is created.
""" """
import re, sys import re
import sys
from mininet.cli import CLI from mininet.cli import CLI
from mininet.log import setLogLevel, info, error from mininet.log import setLogLevel, info, error
+1 -1
View File
@@ -140,7 +140,7 @@ class customOvs(OVSSwitch):
"Customized OVS switch" "Customized OVS switch"
def __init__( self, name, failMode='secure', datapath='kernel', **params ): def __init__( self, name, failMode='secure', datapath='kernel', **params ):
OVSSwitch.__init__( self, name, failMode=failMode, datapath=datapath, **params ) OVSSwitch.__init__( self, name, failMode=failMode, datapath=datapath,**params )
self.switchIP = None self.switchIP = None
def getSwitchIP(self): def getSwitchIP(self):
+1 -1
View File
@@ -61,7 +61,7 @@ def testPortNumbering():
if not intfs.name == "lo": if not intfs.name == "lo":
info( intfs, ': ', s1.ports[intfs], info( intfs, ': ', s1.ports[intfs],
'\n' ) '\n' )
info ( 'Validating that', intfs, info( 'Validating that', intfs,
'is actually on port', s1.ports[intfs], '... ' ) 'is actually on port', s1.ports[intfs], '... ' )
if validatePort( s1, intfs ): if validatePort( s1, intfs ):
info( 'Validated.\n' ) info( 'Validated.\n' )
+1 -1
View File
@@ -89,7 +89,7 @@ def cleanup():
info( "*** Killing stale mininet node processes\n" ) info( "*** Killing stale mininet node processes\n" )
killprocs( 'mininet:' ) killprocs( 'mininet:' )
info ( "*** Shutting down stale tunnels\n" ) info( "*** Shutting down stale tunnels\n" )
killprocs( 'Tunnel=Ethernet' ) killprocs( 'Tunnel=Ethernet' )
killprocs( '.ssh/mn') killprocs( '.ssh/mn')
sh( 'rm -f ~/.ssh/mn/*' ) sh( 'rm -f ~/.ssh/mn/*' )
+3 -2
View File
@@ -357,7 +357,7 @@ class CLI( Cmd ):
return return
sw = args[ 0 ] sw = args[ 0 ]
command = args[ 1 ] command = args[ 1 ]
if sw not in self.mn or self.mn.get( sw ) not in self.mn.switches : if sw not in self.mn or self.mn.get( sw ) not in self.mn.switches:
error( 'invalid switch: %s\n' % args[ 1 ] ) error( 'invalid switch: %s\n' % args[ 1 ] )
else: else:
sw = args[ 0 ] sw = args[ 0 ]
@@ -367,7 +367,8 @@ class CLI( Cmd ):
elif command == 'stop': elif command == 'stop':
self.mn.get( sw ).stop( deleteIntfs=False ) self.mn.get( sw ).stop( deleteIntfs=False )
else: else:
error( 'invalid command: switch <switch name> {start, stop}\n' ) error( 'invalid command: '
'switch <switch name> {start, stop}\n' )
def default( self, line ): def default( self, line ):
"""Called on an input line when the command prefix is not recognized. """Called on an input line when the command prefix is not recognized.
+4 -2
View File
@@ -91,7 +91,8 @@ class Intf( object ):
"Return updated IP address based on ifconfig" "Return updated IP address based on ifconfig"
# use pexec instead of node.cmd so that we dont read # use pexec instead of node.cmd so that we dont read
# backgrounded output from the cli. # backgrounded output from the cli.
ifconfig, _err, _exitCode = self.node.pexec( 'ifconfig %s' % self.name ) ifconfig, _err, _exitCode = self.node.pexec(
'ifconfig %s' % self.name )
ips = self._ipMatchRegex.findall( ifconfig ) ips = self._ipMatchRegex.findall( ifconfig )
self.ip = ips[ 0 ] if ips else None self.ip = ips[ 0 ] if ips else None
return self.ip return self.ip
@@ -333,7 +334,8 @@ class TCIntf( Intf ):
# Delay/jitter/loss/max_queue_size using netem # Delay/jitter/loss/max_queue_size using netem
delaycmds, parent = self.delayCmds( delay=delay, jitter=jitter, delaycmds, parent = self.delayCmds( delay=delay, jitter=jitter,
loss=loss, max_queue_size=max_queue_size, loss=loss,
max_queue_size=max_queue_size,
parent=parent ) parent=parent )
cmds += delaycmds cmds += delaycmds
-1
View File
@@ -170,7 +170,6 @@ class Mininet( object ):
if topo and build: if topo and build:
self.build() self.build()
def waitConnected( self, timeout=None, delay=.5 ): def waitConnected( self, timeout=None, delay=.5 ):
"""wait for each switch to connect to a controller, """wait for each switch to connect to a controller,
up to 5 seconds up to 5 seconds
+3 -1
View File
@@ -1196,7 +1196,6 @@ class OVSSwitch( Switch ):
for intf in self.intfList(): for intf in self.intfList():
self.TCReapply( intf ) self.TCReapply( intf )
def stop( self, deleteIntfs=True ): def stop( self, deleteIntfs=True ):
"""Terminate OVS switch. """Terminate OVS switch.
deleteIntfs: delete interfaces? (True)""" deleteIntfs: delete interfaces? (True)"""
@@ -1354,17 +1353,20 @@ class Controller( Node ):
return '<%s %s: %s:%s pid=%s> ' % ( return '<%s %s: %s:%s pid=%s> ' % (
self.__class__.__name__, self.name, self.__class__.__name__, self.name,
self.IP(), self.port, self.pid ) self.IP(), self.port, self.pid )
@classmethod @classmethod
def isAvailable( cls ): def isAvailable( cls ):
"Is controller available?" "Is controller available?"
return quietRun( 'which controller' ) return quietRun( 'which controller' )
class OVSController( Controller ): class OVSController( Controller ):
"Open vSwitch controller" "Open vSwitch controller"
def __init__( self, name, command='ovs-controller', **kwargs ): def __init__( self, name, command='ovs-controller', **kwargs ):
if quietRun( 'which test-controller' ): if quietRun( 'which test-controller' ):
command = 'test-controller' command = 'test-controller'
Controller.__init__( self, name, command=command, **kwargs ) Controller.__init__( self, name, command=command, **kwargs )
@classmethod @classmethod
def isAvailable( cls ): def isAvailable( cls ):
return ( quietRun( 'which ovs-controller' ) or return ( quietRun( 'which ovs-controller' ) or
+4 -4
View File
@@ -87,7 +87,7 @@ class testOptionsTopoCommon( object ):
upperBound, lowerBound ) ) upperBound, lowerBound ) )
msg += info msg += info
self.assertGreaterEqual( float( measured ),lowerBound, msg=msg ) self.assertGreaterEqual( float( measured ), lowerBound, msg=msg )
self.assertLessEqual( float( measured ), upperBound, msg=msg ) self.assertLessEqual( float( measured ), upperBound, msg=msg )
def testCPULimits( self ): def testCPULimits( self ):
@@ -125,7 +125,7 @@ class testOptionsTopoCommon( object ):
def testLinkBandwidth( self ): def testLinkBandwidth( self ):
"Verify that link bandwidths are accurate within a bound." "Verify that link bandwidths are accurate within a bound."
if self.switchClass is UserSwitch: if self.switchClass is UserSwitch:
self.skipTest ( 'UserSwitch has very poor performance -' self.skipTest( 'UserSwitch has very poor performance -'
' skipping for now' ) ' skipping for now' )
BW = 5 # Mbps BW = 5 # Mbps
BW_TOLERANCE = 0.8 # BW fraction below which test should fail BW_TOLERANCE = 0.8 # BW fraction below which test should fail
@@ -195,7 +195,6 @@ class testOptionsTopoCommon( object ):
self.assertWithinTolerance( rttval, DELAY_MS * 4.0, self.assertWithinTolerance( rttval, DELAY_MS * 4.0,
DELAY_TOLERANCE, msg ) DELAY_TOLERANCE, msg )
def testLinkLoss( self ): def testLinkLoss( self ):
"Verify that we see packet drops with a high configured loss rate." "Verify that we see packet drops with a high configured loss rate."
LOSS_PERCENT = 99 LOSS_PERCENT = 99
@@ -259,7 +258,8 @@ class testOptionsTopoIVS( testOptionsTopoCommon, unittest.TestCase ):
@unittest.skipUnless( quietRun( 'which ofprotocol' ), @unittest.skipUnless( quietRun( 'which ofprotocol' ),
'Reference user switch is not installed' ) 'Reference user switch is not installed' )
class testOptionsTopoUserspace( testOptionsTopoCommon, unittest.TestCase ): class testOptionsTopoUserspace( testOptionsTopoCommon, unittest.TestCase ):
"Verify ability to create networks with host and link options (UserSwitch)." """Verify ability to create networks with host and link options
(UserSwitch)."""
longMessage = True longMessage = True
switchClass = UserSwitch switchClass = UserSwitch
+5 -3
View File
@@ -8,7 +8,8 @@ import sys
from mininet.net import Mininet from mininet.net import Mininet
from mininet.node import Host, Controller from mininet.node import Host, Controller
from mininet.node import UserSwitch, OVSSwitch, OVSLegacyKernelSwitch, IVSSwitch from mininet.node import ( UserSwitch, OVSSwitch, OVSLegacyKernelSwitch,
IVSSwitch )
from mininet.topo import Topo from mininet.topo import Topo
from mininet.log import setLogLevel from mininet.log import setLogLevel
from mininet.util import quietRun from mininet.util import quietRun
@@ -27,11 +28,12 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
if sys.exc_info != ( None, None, None ): if sys.exc_info != ( None, None, None ):
cleanup() cleanup()
def testDefaultDpid ( self ): def testDefaultDpid( self ):
"""Verify that the default dpid is assigned using a valid provided """Verify that the default dpid is assigned using a valid provided
canonical switchname if no dpid is passed in switch creation.""" canonical switchname if no dpid is passed in switch creation."""
switch = Mininet( Topo(), switch = Mininet( Topo(),
self.switchClass, Host, Controller ).addSwitch( 's1' ) self.switchClass,
Host, Controller ).addSwitch( 's1' )
self.assertEqual( switch.defaultDpid(), switch.dpid ) self.assertEqual( switch.defaultDpid(), switch.dpid )
def dpidFrom( self, num ): def dpidFrom( self, num ):
+2 -2
View File
@@ -78,7 +78,6 @@ class MultiGraph( object ):
"Return list of graph edges" "Return list of graph edges"
return list( self.edges_iter( data=data, keys=keys ) ) return list( self.edges_iter( data=data, keys=keys ) )
def __getitem__( self, node ): def __getitem__( self, node ):
"Return link dict for given src node" "Return link dict for given src node"
return self.edge[ node ] return self.edge[ node ]
@@ -306,7 +305,8 @@ class SingleSwitchTopo( Topo ):
class SingleSwitchReversedTopo( Topo ): class SingleSwitchReversedTopo( Topo ):
"""Single switch connected to k hosts, with reversed ports. """Single switch connected to k hosts, with reversed ports.
The lowest-numbered host is connected to the highest-numbered port. The lowest-numbered host is connected to the highest-numbered port.
Useful to verify that Mininet properly handles custom port numberings.""" Useful to verify that Mininet properly handles custom port
numberings."""
def build( self, k=2 ): def build( self, k=2 ):
"k: number of hosts" "k: number of hosts"