diff --git a/Makefile b/Makefile index fe677fb..01c7448 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ BIN = $(MN) PYSRC = $(MININET) $(TEST) $(EXAMPLES) $(BIN) MNEXEC = mnexec MANPAGES = mn.1 mnexec.1 -P8IGN = E251,E201,E302,E202 +P8IGN = E251,E201,E302,E202,E126,E127,E203,E226 BINDIR = /usr/bin MANDIR = /usr/share/man/man1 DOCDIRS = doc/html doc/latex diff --git a/bin/mn b/bin/mn index 5b85ff3..bace2fe 100755 --- a/bin/mn +++ b/bin/mn @@ -57,7 +57,7 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ), SWITCHDEF = 'default' SWITCHES = { 'user': UserSwitch, - 'ovs': OVSSwitch, + 'ovs': OVSSwitch, 'ovsbr' : OVSBridge, # Keep ovsk for compatibility with 2.0 'ovsk': OVSSwitch, @@ -206,7 +206,9 @@ class MininetRunner( object ): opts.add_option( '--custom', action='callback', callback=self.custom, 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, default=TESTS[ 0 ], help='|'.join( TESTS ) ) @@ -329,7 +331,7 @@ class MininetRunner( object ): cli = ClusterCLI if cluster else CLI if cluster: warn( '*** WARNING: Experimental cluster mode!\n' - '*** Using RemoteHost, RemoteOVSSwitch, RemoteLink\n' ) + '*** Using RemoteHost, RemoteOVSSwitch, RemoteLink\n' ) host, switch, link = RemoteHost, RemoteOVSSwitch, RemoteLink Net = partial( MininetCluster, servers=cluster.split( ',' ), placement=PLACEMENT[ self.options.placement ] ) @@ -344,7 +346,8 @@ class MininetRunner( object ): listenPort=listenPort ) 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() if self.options.pre: diff --git a/examples/bind.py b/examples/bind.py index dd96297..6a60e63 100755 --- a/examples/bind.py +++ b/examples/bind.py @@ -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() diff --git a/examples/cluster.py b/examples/cluster.py index 3522087..d89016b 100755 --- a/examples/cluster.py +++ b/examples/cluster.py @@ -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() diff --git a/examples/clusterSanity.py b/examples/clusterSanity.py index 9b6832b..2e1af91 100755 --- a/examples/clusterSanity.py +++ b/examples/clusterSanity.py @@ -17,6 +17,6 @@ def clusterSanity(): CLI( net ) net.stop() -if __name__ == '__main__': +if __name__ == '__main__': setLogLevel( 'info' ) clusterSanity() diff --git a/examples/clustercli.py b/examples/clustercli.py index 9f532e3..30878c6 100644 --- a/examples/clustercli.py +++ b/examples/clustercli.py @@ -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 diff --git a/examples/clusterdemo.py b/examples/clusterdemo.py index cd7d21b..6e050c5 100755 --- a/examples/clusterdemo.py +++ b/examples/clusterdemo.py @@ -20,4 +20,3 @@ def demo(): if __name__ == '__main__': setLogLevel( 'info' ) demo() - diff --git a/examples/consoles.py b/examples/consoles.py index 3197ca1..fd92378 100755 --- a/examples/consoles.py +++ b/examples/consoles.py @@ -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 diff --git a/examples/hwintf.py b/examples/hwintf.py index 1e010fd..b376538 100755 --- a/examples/hwintf.py +++ b/examples/hwintf.py @@ -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 diff --git a/examples/linuxrouter.py b/examples/linuxrouter.py index a2d1442..5e9092d 100755 --- a/examples/linuxrouter.py +++ b/examples/linuxrouter.py @@ -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' ) diff --git a/examples/miniedit.py b/examples/miniedit.py index 4697fa2..72daa35 100755 --- a/examples/miniedit.py +++ b/examples/miniedit.py @@ -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): diff --git a/examples/mobility.py b/examples/mobility.py index dd04451..f6fc01d 100755 --- a/examples/mobility.py +++ b/examples/mobility.py @@ -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' ) diff --git a/examples/nat.py b/examples/nat.py index dada363..7db7415 100755 --- a/examples/nat.py +++ b/examples/nat.py @@ -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' ) diff --git a/examples/numberedports.py b/examples/numberedports.py index 68f5aaa..5d88a2f 100755 --- a/examples/numberedports.py +++ b/examples/numberedports.py @@ -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' ) diff --git a/examples/simpleperf.py b/examples/simpleperf.py index 96725ef..a5a08a7 100755 --- a/examples/simpleperf.py +++ b/examples/simpleperf.py @@ -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) diff --git a/mininet/clean.py b/mininet/clean.py index 8883fcc..4761721 100755 --- a/mininet/clean.py +++ b/mininet/clean.py @@ -73,7 +73,7 @@ def cleanup(): dps = sh("ovs-vsctl --timeout=1 list-br").strip().splitlines() if dps: sh( "ovs-vsctl " + " -- ".join( "--if-exists del-br " + dp - for dp in dps if dp ) ) + for dp in dps if dp ) ) # And in case the above didn't work... dps = sh("ovs-vsctl --timeout=1 list-br").strip().splitlines() for dp in dps: @@ -89,7 +89,7 @@ def cleanup(): info( "*** Killing stale mininet node processes\n" ) killprocs( 'mininet:' ) - info ( "*** Shutting down stale tunnels\n" ) + info( "*** Shutting down stale tunnels\n" ) killprocs( 'Tunnel=Ethernet' ) killprocs( '.ssh/mn') sh( 'rm -f ~/.ssh/mn/*' ) diff --git a/mininet/cli.py b/mininet/cli.py index b92b7e9..23aaac5 100644 --- a/mininet/cli.py +++ b/mininet/cli.py @@ -37,7 +37,7 @@ import atexit from mininet.log import info, output, error from mininet.term import makeTerms, runX11 from mininet.util import ( quietRun, dumpNodeConnections, - dumpPorts ) + dumpPorts ) class CLI( Cmd ): "Simple command-line interface to talk to nodes." @@ -357,7 +357,7 @@ class CLI( Cmd ): return sw = args[ 0 ] 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 ] ) else: sw = args[ 0 ] @@ -367,7 +367,8 @@ class CLI( Cmd ): elif command == 'stop': self.mn.get( sw ).stop( deleteIntfs=False ) else: - error( 'invalid command: switch {start, stop}\n' ) + error( 'invalid command: ' + 'switch {start, stop}\n' ) def default( self, line ): """Called on an input line when the command prefix is not recognized. diff --git a/mininet/link.py b/mininet/link.py index 4c70ca2..e5b85e1 100644 --- a/mininet/link.py +++ b/mininet/link.py @@ -91,7 +91,8 @@ class Intf( object ): "Return updated IP address based on ifconfig" # use pexec instead of node.cmd so that we dont read # 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 ) self.ip = ips[ 0 ] if ips else None return self.ip @@ -333,8 +334,9 @@ class TCIntf( Intf ): # Delay/jitter/loss/max_queue_size using netem delaycmds, parent = self.delayCmds( delay=delay, jitter=jitter, - loss=loss, max_queue_size=max_queue_size, - parent=parent ) + loss=loss, + max_queue_size=max_queue_size, + parent=parent ) cmds += delaycmds # Ugly but functional: display configuration info diff --git a/mininet/net.py b/mininet/net.py index a2562e5..b816966 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -99,7 +99,7 @@ from math import ceil from mininet.cli import CLI from mininet.log import info, error, debug, output, warn from mininet.node import ( Node, Host, OVSKernelSwitch, DefaultController, - Controller ) + Controller ) from mininet.nodelib import NAT from mininet.link import Link, Intf from mininet.util import quietRun, fixLimits, numCores, ensureRoot @@ -170,7 +170,6 @@ class Mininet( object ): if topo and build: self.build() - def waitConnected( self, timeout=None, delay=.5 ): """wait for each switch to connect to a controller, up to 5 seconds @@ -260,7 +259,7 @@ class Mininet( object ): else: controller_new = controller( name, **params ) # Add new controller to net - if controller_new: # allow controller-less setups + if controller_new: # allow controller-less setups self.controllers.append( controller_new ) self.nameToNode[ name ] = controller_new return controller_new @@ -335,7 +334,7 @@ class Mininet( object ): @staticmethod def randMac(): "Return a random, non-multicast MAC address" - return macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff | + return macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff | 0x020000000000 ) def addLink( self, node1, node2, port1=None, port2=None, diff --git a/mininet/node.py b/mininet/node.py index 5389d99..9c303ae 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -129,7 +129,7 @@ class Node( object ): # bash -m: enable job control, i: force interactive # -s: pass $* to shell, and make process easy to find in ps # prompt is set to sentinel chr( 127 ) - cmd = [ 'mnexec', opts, 'env', 'PS1=' + chr( 127 ), + cmd = [ 'mnexec', opts, 'env', 'PS1=' + chr( 127 ), 'bash', '--norc', '-mis', 'mininet:' + self.name ] # Spawn a shell subprocess in a pseudo-tty, to disable buffering # in the subprocess and insulate it from signals (e.g. SIGINT) @@ -380,7 +380,7 @@ class Node( object ): """Execute a command using popen returns: out, err, exitcode""" popen = self.popen( *args, stdin=PIPE, stdout=PIPE, stderr=PIPE, - **kwargs ) + **kwargs ) # Warning: this can fail with large numbers of fds! out, err = popen.communicate() exitcode = popen.wait() @@ -950,12 +950,12 @@ class UserSwitch( Switch ): we re-create the user switch's configuration, but as a leaf of the TCIntf-created configuration.""" if isinstance( intf, TCIntf ): - ifspeed = 10000000000 # 10 Gbps + ifspeed = 10000000000 # 10 Gbps minspeed = ifspeed * 0.001 res = intf.config( **intf.params ) - if res is None: # link may not have TC parameters + if res is None: # link may not have TC parameters return # Re-add qdisc, root, and default classes user switch created, but @@ -988,7 +988,7 @@ class UserSwitch( Switch ): ' 1> ' + ofplog + ' 2>' + ofplog + ' &' ) if "no-slicing" not in self.dpopts: # Only TCReapply if slicing is enable - sleep(1) # Allow ofdatapath to start before re-arranging qdisc's + sleep(1) # Allow ofdatapath to start before re-arranging qdisc's for intf in self.intfList(): if not intf.IP(): self.TCReapply( intf ) @@ -1055,7 +1055,7 @@ class OVSSwitch( Switch ): "Open vSwitch switch. Depends on ovs-vsctl." def __init__( self, name, failMode='secure', datapath='kernel', - inband=False, protocols=None, **params ): + inband=False, protocols=None, **params ): """Init. name: name for switch failMode: controller loss behavior (secure|open) @@ -1087,13 +1087,13 @@ class OVSSwitch( Switch ): '"service openvswitch-switch start".\n' ) exit( 1 ) version = quietRun( 'ovs-vsctl --version' ) - cls.OVSVersion = findall( r'\d+\.\d+', version )[ 0 ] + cls.OVSVersion = findall( r'\d+\.\d+', version )[ 0 ] @classmethod def isOldOVS( cls ): "Is OVS ersion < 1.10?" return ( StrictVersion( cls.OVSVersion ) < - StrictVersion( '1.10' ) ) + StrictVersion( '1.10' ) ) @classmethod def batchShutdown( cls, switches ): @@ -1128,7 +1128,7 @@ class OVSSwitch( Switch ): "Return ovsdb UUIDs for our controllers" uuids = [] controllers = self.cmd( 'ovs-vsctl -- get Bridge', self, - 'Controller' ).strip() + 'Controller' ).strip() if controllers.startswith( '[' ) and controllers.endswith( ']' ): controllers = controllers[ 1 : -1 ] uuids = [ c.strip() for c in controllers.split( ',' ) ] @@ -1137,7 +1137,7 @@ class OVSSwitch( Switch ): def connected( self ): "Are we connected to at least one of our controllers?" results = [ 'true' in self.cmd( 'ovs-vsctl -- get Controller', - uuid, 'is_connected' ) + uuid, 'is_connected' ) for uuid in self.controllerUUIDs() ] return reduce( or_, results, False ) @@ -1148,15 +1148,15 @@ class OVSSwitch( Switch ): 'OVS kernel switch does not work in a namespace' ) # Annoyingly, --if-exists option seems not to work self.cmd( 'ovs-vsctl del-br', self ) - int( self.dpid, 16 ) # DPID must be a hex string + int( self.dpid, 16 ) # DPID must be a hex string # Interfaces and controllers intfs = ' '.join( '-- add-port %s %s ' % ( self, intf ) + '-- set Interface %s ' % intf + 'ofport_request=%s ' % self.ports[ intf ] - for intf in self.intfList() - if self.ports[ intf ] and not intf.IP() ) + for intf in self.intfList() + if self.ports[ intf ] and not intf.IP() ) clist = ' '.join( '%s:%s:%d' % ( c.protocol, c.IP(), c.port ) - for c in controllers ) + for c in controllers ) if self.listenPort: clist += ' ptcp:%s' % self.listenPort # Construct big ovs-vsctl command for new versions of OVS @@ -1196,7 +1196,6 @@ class OVSSwitch( Switch ): for intf in self.intfList(): self.TCReapply( intf ) - def stop( self, deleteIntfs=True ): """Terminate OVS switch. deleteIntfs: delete interfaces? (True)""" @@ -1354,17 +1353,20 @@ class Controller( Node ): return '<%s %s: %s:%s pid=%s> ' % ( self.__class__.__name__, self.name, self.IP(), self.port, self.pid ) + @classmethod def isAvailable( cls ): "Is controller available?" return quietRun( 'which controller' ) + class OVSController( Controller ): "Open vSwitch controller" def __init__( self, name, command='ovs-controller', **kwargs ): if quietRun( 'which test-controller' ): command = 'test-controller' Controller.__init__( self, name, command=command, **kwargs ) + @classmethod def isAvailable( cls ): return ( quietRun( 'which ovs-controller' ) or @@ -1411,11 +1413,11 @@ class RYU( Controller ): ryuArgs = [ ryuArgs ] Controller.__init__( self, name, - command='ryu-manager', - cargs='--ofp-tcp-listen-port %s ' + - ' '.join( ryuArgs ), - cdir=ryuCoreDir, - **kwargs ) + command='ryu-manager', + cargs='--ofp-tcp-listen-port %s ' + + ' '.join( ryuArgs ), + cdir=ryuCoreDir, + **kwargs ) class RemoteController( Controller ): "Controller running outside of Mininet's control." diff --git a/mininet/nodelib.py b/mininet/nodelib.py index 7f4f841..a2f8707 100644 --- a/mininet/nodelib.py +++ b/mininet/nodelib.py @@ -82,7 +82,7 @@ class NAT( Node ): super( NAT, self).config( **params ) if not self.localIntf: - self.localIntf = self.defaultIntf() + self.localIntf = self.defaultIntf() self.cmd( 'sysctl net.ipv4.ip_forward=0' ) diff --git a/mininet/term.py b/mininet/term.py index 91d95eb..8d838a4 100644 --- a/mininet/term.py +++ b/mininet/term.py @@ -32,7 +32,7 @@ def tunnelX11( node, display=None): port = 6000 + int( float( screen ) ) connection = r'TCP\:%s\:%s' % ( host, port ) cmd = [ "socat", "TCP-LISTEN:%d,fork,reuseaddr" % port, - "EXEC:'mnexec -a 1 socat STDIO %s'" % connection ] + "EXEC:'mnexec -a 1 socat STDIO %s'" % connection ] return 'localhost:' + screen, node.popen( cmd ) def makeTerm( node, title='Node', term='xterm', display=None ): diff --git a/mininet/test/test_hifi.py b/mininet/test/test_hifi.py index dace8a6..1a3a0ac 100755 --- a/mininet/test/test_hifi.py +++ b/mininet/test/test_hifi.py @@ -40,7 +40,7 @@ class testOptionsTopoCommon( object ): """Verify ability to create networks with host and link options (common code).""" - switchClass = None # overridden in subclasses + switchClass = None # overridden in subclasses @staticmethod def tearDown(): @@ -87,7 +87,7 @@ class testOptionsTopoCommon( object ): upperBound, lowerBound ) ) msg += info - self.assertGreaterEqual( float( measured ),lowerBound, msg=msg ) + self.assertGreaterEqual( float( measured ), lowerBound, msg=msg ) self.assertLessEqual( float( measured ), upperBound, msg=msg ) def testCPULimits( self ): @@ -125,8 +125,8 @@ class testOptionsTopoCommon( object ): def testLinkBandwidth( self ): "Verify that link bandwidths are accurate within a bound." if self.switchClass is UserSwitch: - self.skipTest ( 'UserSwitch has very poor performance -' - ' skipping for now' ) + self.skipTest( 'UserSwitch has very poor performance -' + ' skipping for now' ) BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; @@ -195,7 +195,6 @@ class testOptionsTopoCommon( object ): self.assertWithinTolerance( rttval, DELAY_MS * 4.0, DELAY_TOLERANCE, msg ) - def testLinkLoss( self ): "Verify that we see packet drops with a high configured loss rate." LOSS_PERCENT = 99 @@ -257,9 +256,10 @@ class testOptionsTopoIVS( testOptionsTopoCommon, unittest.TestCase ): switchClass = IVSSwitch @unittest.skipUnless( quietRun( 'which ofprotocol' ), - 'Reference user switch is not installed' ) + 'Reference user switch is not installed' ) 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 switchClass = UserSwitch diff --git a/mininet/test/test_nets.py b/mininet/test/test_nets.py index 5b44207..e468555 100755 --- a/mininet/test/test_nets.py +++ b/mininet/test/test_nets.py @@ -21,7 +21,7 @@ from mininet.clean import cleanup class testSingleSwitchCommon( object ): "Test ping with single switch topology (common code)." - switchClass = None # overridden in subclasses + switchClass = None # overridden in subclasses @staticmethod def tearDown(): @@ -59,7 +59,7 @@ class testSingleSwitchIVS( testSingleSwitchCommon, unittest.TestCase ): switchClass = IVSSwitch @unittest.skipUnless( quietRun( 'which ofprotocol' ), - 'Reference user switch is not installed' ) + 'Reference user switch is not installed' ) class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ): "Test ping with single switch topology (Userspace switch)." switchClass = UserSwitch @@ -71,7 +71,7 @@ class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ): class testLinearCommon( object ): "Test all-pairs ping with LinearNet (common code)." - switchClass = None # overridden in subclasses + switchClass = None # overridden in subclasses def testLinear5( self ): "Ping test on a 5-switch topology" diff --git a/mininet/test/test_switchdpidassignment.py b/mininet/test/test_switchdpidassignment.py index 3678667..14495b3 100755 --- a/mininet/test/test_switchdpidassignment.py +++ b/mininet/test/test_switchdpidassignment.py @@ -8,7 +8,8 @@ import sys from mininet.net import Mininet 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.log import setLogLevel from mininet.util import quietRun @@ -18,7 +19,7 @@ from mininet.clean import cleanup class TestSwitchDpidAssignmentOVS( unittest.TestCase ): "Verify Switch dpid assignment." - switchClass = OVSSwitch # overridden in subclasses + switchClass = OVSSwitch # overridden in subclasses def tearDown( self ): "Clean up if necessary" @@ -27,11 +28,12 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ): if sys.exc_info != ( None, None, None ): cleanup() - def testDefaultDpid ( self ): + def testDefaultDpid( self ): """Verify that the default dpid is assigned using a valid provided canonical switchname if no dpid is passed in switch creation.""" switch = Mininet( Topo(), - self.switchClass, Host, Controller ).addSwitch( 's1' ) + self.switchClass, + Host, Controller ).addSwitch( 's1' ) self.assertEqual( switch.defaultDpid(), switch.dpid ) def dpidFrom( self, num ): @@ -45,7 +47,7 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ): dpid = self.dpidFrom( 0xABCD ) switch = Mininet( Topo(), self.switchClass, Host, Controller ).addSwitch( - 's1', dpid=dpid ) + 's1', dpid=dpid ) self.assertEqual( switch.dpid, dpid ) def testDefaultDpidAssignmentFailure( self ): diff --git a/mininet/topo.py b/mininet/topo.py index bd4e2fb..aea2b67 100644 --- a/mininet/topo.py +++ b/mininet/topo.py @@ -78,7 +78,6 @@ class MultiGraph( object ): "Return list of graph edges" return list( self.edges_iter( data=data, keys=keys ) ) - def __getitem__( self, node ): "Return link dict for given src node" return self.edge[ node ] @@ -147,7 +146,7 @@ class Topo( object ): return result def addLink( self, node1, node2, port1=None, port2=None, - key=None, **opts ): + key=None, **opts ): """node1, node2: nodes to link together port1, port2: ports (optional) opts: link options (optional) @@ -306,7 +305,8 @@ class SingleSwitchTopo( Topo ): class SingleSwitchReversedTopo( Topo ): """Single switch connected to k hosts, with reversed ports. 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 ): "k: number of hosts" diff --git a/mininet/topolib.py b/mininet/topolib.py index 6bd4562..e459bcf 100644 --- a/mininet/topolib.py +++ b/mininet/topolib.py @@ -48,7 +48,7 @@ class TorusTopo( Topo ): def build( self, x, y ): if x < 3 or y < 3: raise Exception( 'Please use 3x3 or greater for compatibility ' - 'with 2.1' ) + 'with 2.1' ) hosts, switches, dpid = {}, {}, 0 # Create and wire interior for i in range( 0, x ): diff --git a/mininet/util.py b/mininet/util.py index 0ee2762..90bf03d 100644 --- a/mininet/util.py +++ b/mininet/util.py @@ -200,7 +200,7 @@ def moveIntfNoRetry( intf, dstNode, printError=False ): return True def moveIntf( intf, dstNode, printError=True, - retries=3, delaySecs=0.001 ): + retries=3, delaySecs=0.001 ): """Move interface to node, retrying on failure. intf: string, interface dstNode: destination Node @@ -546,13 +546,13 @@ def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ): """Wait until server is listening on port. returns True if server is listening""" runCmd = ( client.cmd if client else - partial( quietRun, shell=True ) ) + partial( quietRun, shell=True ) ) if not runCmd( 'which telnet' ): raise Exception('Could not find telnet' ) # pylint: disable=maybe-no-member serverIP = server if isinstance( server, basestring ) else server.IP() cmd = ( 'sh -c "echo A | telnet -e A %s %s"' % - ( serverIP, port ) ) + ( serverIP, port ) ) time = 0 while 'Connected' not in runCmd( cmd ): if timeout: