Spacing tweaks for pep8 checker
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
+9
-8
@@ -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 ):
|
||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ def demo():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
demo()
|
demo()
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -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
|
||||||
|
|||||||
+2
-1
@@ -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
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -31,7 +32,8 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
|
|||||||
"""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
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user