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
@@ -57,7 +57,7 @@ def testHostWithPrivateDirs():
net.start()
directories = [ directory[ 0 ] if isinstance( directory, tuple )
else directory for directory in privateDirs ]
info( 'Private Directories:', directories, '\n' )
info( 'Private Directories:', directories, '\n' )
CLI( net )
net.stop()
+17 -16
View File
@@ -254,8 +254,10 @@ class RemoteMixin( object ):
def addIntf( self, *args, **kwargs ):
"Override: use RemoteLink.moveIntf"
return super( RemoteMixin, self).addIntf( *args,
moveIntfFn=RemoteLink.moveIntf, **kwargs )
return super( RemoteMixin,
self).addIntf( *args,
moveIntfFn=RemoteLink.moveIntf,
**kwargs )
def cleanup( self ):
"Help python collect its garbage."
@@ -277,7 +279,9 @@ class RemoteHost( RemoteNode ):
class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
"Remote instance of Open vSwitch"
OVSVersions = {}
def isOldOVS( self ):
"Is remote switch using an old OVS version?"
cls = type( self )
@@ -288,12 +292,10 @@ class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
cls.OVSVersions[ self.server ] = re.findall(
r'\d+\.\d+', vers )[ 0 ]
return ( StrictVersion( cls.OVSVersions[ self.server ] ) <
StrictVersion( '1.10' ) )
StrictVersion( '1.10' ) )
class RemoteLink( Link ):
"A RemoteLink is a link between nodes which may be on different servers"
def __init__( self, node1, node2, **kwargs ):
@@ -349,7 +351,7 @@ class RemoteLink( Link ):
if not ' %s:' % intf in links:
if printError:
error( '*** Error: RemoteLink.moveIntf: ' + intf +
' not successfully moved to ' + node.name + '\n' )
' not successfully moved to ' + node.name + '\n' )
return False
return True
@@ -388,7 +390,7 @@ class RemoteLink( Link ):
'Tunnel setup failed for',
'%s:%s' % ( node1, node1.dest ), 'to',
'%s:%s\n' % ( node2, node2.dest ),
'command was:', cmd, '\n' )
'command was:', cmd, '\n' )
tunnel.terminate()
tunnel.wait()
error( ch + tunnel.stdout.read() )
@@ -400,7 +402,7 @@ class RemoteLink( Link ):
retry( 3, .01, RemoteLink.moveIntf, 'tap9', node )
# 4. Rename tap interfaces to desired names
for node, intf, addr in ( ( node1, intfname1, addr1 ),
( node2, intfname2, addr2 ) ):
( node2, intfname2, addr2 ) ):
if not addr:
node.cmd( 'ip link set tap9 name', intf )
else:
@@ -429,7 +431,7 @@ class Placer( object ):
"Node placement algorithm for MininetCluster"
def __init__( self, servers=None, nodes=None, hosts=None,
switches=None, controllers=None, links=None ):
switches=None, controllers=None, links=None ):
"""Initialize placement object
servers: list of servers
nodes: list of all nodes
@@ -494,7 +496,7 @@ class SwitchBinPlacer( Placer ):
self.sset = frozenset( self.switches )
self.cset = frozenset( self.controllers )
# Server and switch placement indices
self.placement = self.calculatePlacement()
self.placement = self.calculatePlacement()
@staticmethod
def bin( nodes, servers ):
@@ -561,7 +563,7 @@ class HostSwitchBinPlacer( Placer ):
scount = len( self.servers )
self.hbin = max( int( len( self.hosts ) / 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( 'bins:', self.hbin, self.sbin, self.cbin, '\n' )
self.servdict = dict( enumerate( self.servers ) )
@@ -589,7 +591,6 @@ class HostSwitchBinPlacer( Placer ):
return server
# The MininetCluster class is not strictly necessary.
# However, it has several purposes:
# 1. To set up ssh connection sharing/multiplexing
@@ -667,7 +668,8 @@ class MininetCluster( Mininet ):
result |= code
if result:
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'
'*** use sudo -E.\n' )
sys.exit( 1 )
@@ -679,7 +681,6 @@ class MininetCluster( Mininet ):
kwargs[ 'splitInit' ] = True
return Mininet.addHost( *args, **kwargs )
def placeNodes( self ):
"""Place nodes on servers (if they don't have a server), and
start shell processes"""
@@ -695,7 +696,7 @@ class MininetCluster( Mininet ):
for node in nodes:
config = self.topo.nodeInfo( node )
# 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'
server = config.setdefault( 'server', placer.place( node ) )
if server:
@@ -805,7 +806,7 @@ def testRemoteTopo():
"Test remote Node classes using Mininet()/Topo() API"
topo = LinearTopo( 2 )
net = Mininet( topo=topo, host=HostPlacer, switch=SwitchPlacer,
link=RemoteLink, controller=ClusterController )
link=RemoteLink, controller=ClusterController )
net.start()
net.pingAll()
net.stop()
+1 -1
View File
@@ -17,6 +17,6 @@ def clusterSanity():
CLI( net )
net.stop()
if __name__ == '__main__':
if __name__ == '__main__':
setLogLevel( 'info' )
clusterSanity()
+3 -4
View File
@@ -16,8 +16,8 @@ class ClusterCLI( CLI ):
def colorsFor( seq ):
"Return a list of background colors for a sequence"
colors = [ 'red', 'lightgreen', 'cyan', 'yellow', 'orange',
'magenta', 'pink', 'grey', 'brown',
'white' ]
'magenta', 'pink', 'grey', 'brown',
'white' ]
slen, clen = len( seq ), len( colors )
reps = max( 1, slen / clen )
colors = colors * reps
@@ -55,7 +55,7 @@ class ClusterCLI( CLI ):
# Plot it!
pos = nx.graphviz_layout( g )
opts = { 'ax': None, 'font_weight': 'bold',
'width': 2, 'edge_color': 'darkblue' }
'width': 2, 'edge_color': 'darkblue' }
hcolors = [ color[ getattr( h, 'server', 'localhost' ) ]
for h in hosts ]
scolors = [ color[ getattr( s, 'server', 'localhost' ) ]
@@ -88,7 +88,6 @@ class ClusterCLI( CLI ):
else:
output( 'All nodes are still running.\n' )
def do_placement( self, _line ):
"Describe node placement"
mn = self.mn
-1
View File
@@ -20,4 +20,3 @@ def demo():
if __name__ == '__main__':
setLogLevel( 'info' )
demo()
+1 -1
View File
@@ -327,7 +327,7 @@ class ConsoleApp( Frame ):
elif units[0] == 'b':
val *= 10 ** -9
self.updates += 1
self.bw += val
self.bw += val
if self.updates >= self.hostCount:
self.graph.addBar( self.bw )
self.bw = 0
+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.
"""
import re, sys
import re
import sys
from mininet.cli import CLI
from mininet.log import setLogLevel, info, error
+1 -1
View File
@@ -62,7 +62,7 @@ class NetworkTopo( Topo ):
def run():
"Test linux router"
topo = NetworkTopo()
net = Mininet( topo=topo, controller=None ) # no controller needed
net = Mininet( topo=topo, controller=None ) # no controller needed
net.start()
info( '*** Routing Table on Router\n' )
print net[ 'r0' ].cmd( 'route' )
+1 -1
View File
@@ -140,7 +140,7 @@ class customOvs(OVSSwitch):
"Customized OVS switch"
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
def getSwitchIP(self):
+1 -1
View File
@@ -59,7 +59,7 @@ class MobilitySwitch( OVSSwitch ):
def validatePort( self, intf ):
"Validate intf's OF port number"
ofport = int( self.cmd( 'ovs-vsctl get Interface', intf,
'ofport' ) )
'ofport' ) )
if ofport != self.ports[ intf ]:
warn( 'WARNING: ofport for', intf, 'is actually', ofport,
'\n' )
+1 -1
View File
@@ -22,7 +22,7 @@ def startNAT( root, inetIntf='eth0', subnet='10.0/8' ):
subnet: Mininet subnet (default 10.0/8)="""
# Identify the interface connecting to the mininet network
localIntf = root.defaultIntf()
localIntf = root.defaultIntf()
# Flush any currently active rules
root.cmd( 'iptables -F' )
+3 -3
View File
@@ -13,7 +13,7 @@ from mininet.log import setLogLevel, info, warn
def validatePort( switch, intf ):
"Validate intf's OF port number"
ofport = int( switch.cmd( 'ovs-vsctl get Interface', intf,
'ofport' ) )
'ofport' ) )
if ofport != switch.ports[ intf ]:
warn( 'WARNING: ofport for', intf, 'is actually', ofport, '\n' )
return 0
@@ -60,8 +60,8 @@ def testPortNumbering():
for intfs in s1.intfList():
if not intfs.name == "lo":
info( intfs, ': ', s1.ports[intfs],
'\n' )
info ( 'Validating that', intfs,
'\n' )
info( 'Validating that', intfs,
'is actually on port', s1.ports[intfs], '... ' )
if validatePort( s1, intfs ):
info( 'Validated.\n' )
+2 -2
View File
@@ -33,8 +33,8 @@ def perfTest():
"Create network and run simple performance test"
topo = SingleSwitchTopo( n=4 )
net = Mininet( topo=topo,
host=CPULimitedHost, link=TCLink,
autoStaticArp=True )
host=CPULimitedHost, link=TCLink,
autoStaticArp=True )
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)