Remove trailing whitespace. ;-/

This commit is contained in:
Bob Lantz
2014-12-01 15:39:44 -08:00
parent 3c9f5ad56e
commit 5a530af189
34 changed files with 85 additions and 87 deletions
+2 -2
View File
@@ -145,7 +145,7 @@ class MininetRunner( object ):
else: else:
# Accept a comma-separated list of filenames # Accept a comma-separated list of filenames
files += value.split(',') files += value.split(',')
for fileName in files: for fileName in files:
customs = {} customs = {}
if os.path.isfile( fileName ): if os.path.isfile( fileName ):
@@ -289,7 +289,7 @@ class MininetRunner( object ):
else: else:
raise Exception( "Could not find a default controller for switch %s" % raise Exception( "Could not find a default controller for switch %s" %
self.options.switch ) self.options.switch )
topo = buildTopo( TOPOS, self.options.topo ) topo = buildTopo( TOPOS, self.options.topo )
switch = customConstructor( SWITCHES, self.options.switch ) switch = customConstructor( SWITCHES, self.options.switch )
host = customConstructor( HOSTS, self.options.host ) host = customConstructor( HOSTS, self.options.host )
+3 -5
View File
@@ -22,7 +22,7 @@ to temporary private directories. To do this, simply create a list of
directories to be made private. A tmpfs will then be mounted on them. directories to be made private. A tmpfs will then be mounted on them.
You may use both temporary and persistent directories at the same You may use both temporary and persistent directories at the same
time. In the following privateDirs string, each host will have a time. In the following privateDirs string, each host will have a
persistent directory in the root filesystem at persistent directory in the root filesystem at
"/tmp/(hostname)/var/run" mounted on "/var/run". Each host will also "/tmp/(hostname)/var/run" mounted on "/var/run". Each host will also
have a temporary private directory mounted on "/var/log". have a temporary private directory mounted on "/var/log".
@@ -48,8 +48,8 @@ from functools import partial
def testHostWithPrivateDirs(): def testHostWithPrivateDirs():
"Test bind mounts" "Test bind mounts"
topo = SingleSwitchTopo( 10 ) topo = SingleSwitchTopo( 10 )
privateDirs = [ ( '/var/log', '/tmp/%(name)s/var/log' ), privateDirs = [ ( '/var/log', '/tmp/%(name)s/var/log' ),
( '/var/run', '/tmp/%(name)s/var/run' ), ( '/var/run', '/tmp/%(name)s/var/run' ),
'/var/mn' ] '/var/mn' ]
host = partial( Host, host = partial( Host,
privateDirs=privateDirs ) privateDirs=privateDirs )
@@ -65,5 +65,3 @@ if __name__ == '__main__':
setLogLevel( 'info' ) setLogLevel( 'info' )
testHostWithPrivateDirs() testHostWithPrivateDirs()
info( 'Done.\n') info( 'Done.\n')
+5 -5
View File
@@ -346,7 +346,7 @@ class RemoteLink( Link ):
' not successfully moved to ' + node.name + '\n' ) ' not successfully moved to ' + node.name + '\n' )
return False return False
return True return True
def makeTunnel( self, node1, node2, intfname1, intfname2, def makeTunnel( self, node1, node2, intfname1, intfname2,
addr1=None, addr2=None ): addr1=None, addr2=None ):
"Make a tunnel across switches on different servers" "Make a tunnel across switches on different servers"
@@ -380,7 +380,7 @@ class RemoteLink( Link ):
if ch != '@': if ch != '@':
error( 'makeTunnel:\n', error( 'makeTunnel:\n',
'Tunnel setup failed for', 'Tunnel setup failed for',
'%s:%s' % ( node1, node1.dest ), 'to', '%s:%s' % ( node1, node1.dest ), 'to',
'%s:%s\n' % ( node2, node2.dest ), '%s:%s\n' % ( node2, node2.dest ),
'command was:', cmd, '\n' ) 'command was:', cmd, '\n' )
tunnel.terminate() tunnel.terminate()
@@ -421,7 +421,7 @@ class RemoteLink( Link ):
class Placer( object ): class Placer( object ):
"Node placement algorithm for MininetCluster" "Node placement algorithm for MininetCluster"
def __init__( self, servers=None, nodes=None, hosts=None, def __init__( self, servers=None, nodes=None, hosts=None,
switches=None, controllers=None, links=None ): switches=None, controllers=None, links=None ):
"""Initialize placement object """Initialize placement object
@@ -459,7 +459,7 @@ class RoundRobinPlacer( Placer ):
"""Round-robin placement """Round-robin placement
Note this will usually result in cross-server links between Note this will usually result in cross-server links between
hosts and switches""" hosts and switches"""
def __init__( self, *args, **kwargs ): def __init__( self, *args, **kwargs ):
Placer.__init__( self, *args, **kwargs ) Placer.__init__( self, *args, **kwargs )
self.next = 0 self.next = 0
@@ -560,7 +560,7 @@ class HostSwitchBinPlacer( Placer ):
self.sset = frozenset( self.switches ) self.sset = frozenset( self.switches )
self.cset = frozenset( self.controllers ) self.cset = frozenset( self.controllers )
self.hind, self.sind, self.cind = 0, 0, 0 self.hind, self.sind, self.cind = 0, 0, 0
def place( self, nodename ): def place( self, nodename ):
"""Simple placement algorithm: """Simple placement algorithm:
place nodes into evenly sized bins""" place nodes into evenly sized bins"""
+1 -1
View File
@@ -12,7 +12,7 @@ from mininet.topo import SingleSwitchTopo
def clusterSanity(): def clusterSanity():
"Sanity check for cluster mode" "Sanity check for cluster mode"
topo = SingleSwitchTopo() topo = SingleSwitchTopo()
net = MininetCluster( topo=topo ) net = MininetCluster( topo=topo )
net.start() net.start()
CLI( net ) CLI( net )
net.stop() net.stop()
+1 -1
View File
@@ -22,7 +22,7 @@ class ClusterCLI( CLI ):
colors = colors * reps colors = colors * reps
colors = colors[ 0 : slen ] colors = colors[ 0 : slen ]
return colors return colors
def do_plot( self, line ): def do_plot( self, line ):
"Plot topology colored by node placement" "Plot topology colored by node placement"
# Import networkx if needed # Import networkx if needed
+2 -2
View File
@@ -35,7 +35,7 @@ class DataController( Controller ):
class MininetFacade( object ): class MininetFacade( object ):
"""Mininet object facade that allows a single CLI to """Mininet object facade that allows a single CLI to
talk to one or more networks""" talk to one or more networks"""
def __init__( self, net, *args, **kwargs ): def __init__( self, net, *args, **kwargs ):
"""Create MininetFacade object. """Create MininetFacade object.
net: Primary Mininet object net: Primary Mininet object
@@ -114,7 +114,7 @@ class ControlNetwork( Topo ):
def run(): def run():
"Create control and data networks, and invoke the CLI" "Create control and data networks, and invoke the CLI"
info( '* Creating Control Network\n' ) info( '* Creating Control Network\n' )
ctopo = ControlNetwork( n=4, dataController=DataController ) ctopo = ControlNetwork( n=4, dataController=DataController )
cnet = Mininet( topo=ctopo, ipBase='192.168.123.0/24', controller=None ) cnet = Mininet( topo=ctopo, ipBase='192.168.123.0/24', controller=None )
+3 -3
View File
@@ -21,7 +21,7 @@ def intfOptions():
link1 = net.addLink( h1, s1, cls=TCLink ) link1 = net.addLink( h1, s1, cls=TCLink )
net.addLink( h2, s1 ) net.addLink( h2, s1 )
net.start() net.start()
# flush out latency from reactive forwarding delay # flush out latency from reactive forwarding delay
net.pingAll() net.pingAll()
@@ -34,12 +34,12 @@ def intfOptions():
link1.intf1.config( loss=50 ) link1.intf1.config( loss=50 )
info( '\n' ) info( '\n' )
net.iperf( ( h1, h2 ), l4Type='UDP' ) net.iperf( ( h1, h2 ), l4Type='UDP' )
info( '\n*** Configuring one intf with delay of 15ms\n' ) info( '\n*** Configuring one intf with delay of 15ms\n' )
link1.intf1.config( delay='15ms' ) link1.intf1.config( delay='15ms' )
info( '\n*** Run a ping to confirm delay\n' ) info( '\n*** Run a ping to confirm delay\n' )
net.pingPairFull() net.pingPairFull()
info( '\n*** Done testing\n' ) info( '\n*** Done testing\n' )
net.stop() net.stop()
+2 -2
View File
@@ -2,7 +2,7 @@
""" """
linuxrouter.py: Example network with Linux IP router linuxrouter.py: Example network with Linux IP router
This example converts a Node into a router using IP forwarding This example converts a Node into a router using IP forwarding
already built into Linux. already built into Linux.
@@ -16,7 +16,7 @@ The topology contains a router with three IP subnets:
- h2 (IP: 172.16.0.100) - h2 (IP: 172.16.0.100)
- h3 (IP: 10.0.0.100) - h3 (IP: 10.0.0.100)
Routing entries can be added to the routing tables of the Routing entries can be added to the routing tables of the
hosts or router using the "ip route add" or "route add" command. hosts or router using the "ip route add" or "route add" command.
See the man pages for more details. See the man pages for more details.
+13 -13
View File
@@ -750,7 +750,7 @@ class SwitchDialog(CustomDialog):
'please either specify a DPID or use a ' 'please either specify a DPID or use a '
'canonical switch name such as s23.' ) 'canonical switch name such as s23.' )
results = {'externalInterfaces':externalInterfaces, results = {'externalInterfaces':externalInterfaces,
'hostname':self.hostnameEntry.get(), 'hostname':self.hostnameEntry.get(),
'dpid':dpid, 'dpid':dpid,
@@ -784,10 +784,10 @@ class VerticalScrolledTable(LabelFrame):
* Use the 'interior' attribute to place widgets inside the scrollable frame * Use the 'interior' attribute to place widgets inside the scrollable frame
* Construct and pack/place/grid normally * Construct and pack/place/grid normally
* This frame only allows vertical scrolling * This frame only allows vertical scrolling
""" """
def __init__(self, parent, rows=2, columns=2, title=None, *args, **kw): def __init__(self, parent, rows=2, columns=2, title=None, *args, **kw):
LabelFrame.__init__(self, parent, text=title, padx=5, pady=5, *args, **kw) LabelFrame.__init__(self, parent, text=title, padx=5, pady=5, *args, **kw)
# create a canvas object and a vertical scrollbar for scrolling it # create a canvas object and a vertical scrollbar for scrolling it
vscrollbar = Scrollbar(self, orient=VERTICAL) vscrollbar = Scrollbar(self, orient=VERTICAL)
@@ -1709,7 +1709,7 @@ class MiniEdit( Frame ):
for widget in self.widgetToItem: for widget in self.widgetToItem:
name = widget[ 'text' ] name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] ) tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Controller' in tags: if 'Controller' in tags:
opts = self.controllers[name] opts = self.controllers[name]
controllerType = opts['controllerType'] controllerType = opts['controllerType']
@@ -1720,9 +1720,9 @@ class MiniEdit( Frame ):
controllerIP = opts['remoteIP'] controllerIP = opts['remoteIP']
controllerPort = opts['remotePort'] controllerPort = opts['remotePort']
f.write(" "+name+"=net.addController(name='"+name+"',\n") f.write(" "+name+"=net.addController(name='"+name+"',\n")
if controllerType == 'remote': if controllerType == 'remote':
f.write(" controller=RemoteController,\n") f.write(" controller=RemoteController,\n")
f.write(" ip='"+controllerIP+"',\n") f.write(" ip='"+controllerIP+"',\n")
@@ -1733,7 +1733,7 @@ class MiniEdit( Frame ):
f.write(" controller=OVSController,\n") f.write(" controller=OVSController,\n")
else: else:
f.write(" controller=Controller,\n") f.write(" controller=Controller,\n")
f.write(" protocol='"+controllerProtocol+"',\n") f.write(" protocol='"+controllerProtocol+"',\n")
f.write(" port="+str(controllerPort)+")\n") f.write(" port="+str(controllerPort)+")\n")
f.write("\n") f.write("\n")
@@ -1943,7 +1943,7 @@ class MiniEdit( Frame ):
for widget in self.widgetToItem: for widget in self.widgetToItem:
name = widget[ 'text' ] name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] ) tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Switch' in tags: if 'Switch' in tags:
opts = self.switchOpts[name] opts = self.switchOpts[name]
if 'netflow' in opts: if 'netflow' in opts:
@@ -1967,7 +1967,7 @@ class MiniEdit( Frame ):
for widget in self.widgetToItem: for widget in self.widgetToItem:
name = widget[ 'text' ] name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] ) tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Switch' in tags: if 'Switch' in tags:
opts = self.switchOpts[name] opts = self.switchOpts[name]
if 'sflow' in opts: if 'sflow' in opts:
@@ -2641,7 +2641,7 @@ class MiniEdit( Frame ):
else: else:
controllerName = dest[ 'text' ] controllerName = dest[ 'text' ]
switchName = source[ 'text' ] switchName = source[ 'text' ]
if controllerName in self.switchOpts[switchName]['controllers']: if controllerName in self.switchOpts[switchName]['controllers']:
self.switchOpts[switchName]['controllers'].remove(controllerName) self.switchOpts[switchName]['controllers'].remove(controllerName)
@@ -2662,7 +2662,7 @@ class MiniEdit( Frame ):
if 'Switch' in tags: if 'Switch' in tags:
if widget['text'] in self.switchOpts[name]['controllers']: if widget['text'] in self.switchOpts[name]['controllers']:
self.switchOpts[name]['controllers'].remove(widget['text']) self.switchOpts[name]['controllers'].remove(widget['text'])
for link in widget.links.values(): for link in widget.links.values():
# Delete from view and model # Delete from view and model
self.deleteItem( link ) self.deleteItem( link )
@@ -2917,7 +2917,7 @@ class MiniEdit( Frame ):
for widget in self.widgetToItem: for widget in self.widgetToItem:
name = widget[ 'text' ] name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] ) tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Switch' in tags: if 'Switch' in tags:
opts = self.switchOpts[name] opts = self.switchOpts[name]
if 'netflow' in opts: if 'netflow' in opts:
@@ -2947,7 +2947,7 @@ class MiniEdit( Frame ):
for widget in self.widgetToItem: for widget in self.widgetToItem:
name = widget[ 'text' ] name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] ) tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Switch' in tags: if 'Switch' in tags:
opts = self.switchOpts[name] opts = self.switchOpts[name]
if 'sflow' in opts: if 'sflow' in opts:
+3 -3
View File
@@ -9,9 +9,9 @@ from mininet.cli import CLI
from mininet.log import setLogLevel from mininet.log import setLogLevel
from mininet.net import Mininet from mininet.net import Mininet
from mininet.topo import Topo from mininet.topo import Topo
def runMultiLink(): def runMultiLink():
topo = simpleMultiLinkTopo( n=2 ) topo = simpleMultiLinkTopo( n=2 )
net = Mininet( topo=topo ) net = Mininet( topo=topo )
net.start() net.start()
@@ -25,7 +25,7 @@ class simpleMultiLinkTopo( Topo ):
h1, h2 = self.addHost( 'h1' ), self.addHost( 'h2' ) h1, h2 = self.addHost( 'h1' ), self.addHost( 'h2' )
s1 = self.addSwitch( 's1' ) s1 = self.addSwitch( 's1' )
for _ in range( n ): for _ in range( n ):
self.addLink( s1, h1 ) self.addLink( s1, h1 )
self.addLink( s1, h2 ) self.addLink( s1, h2 )
+5 -5
View File
@@ -14,7 +14,7 @@ natnet.py: Example network with NATs
| | | |
s1 s2 s1 s2
| | | |
h1 h2 h1 h2
""" """
@@ -44,15 +44,15 @@ class InternetTopo(Topo):
localSubnet = '192.168.%d.0/24' % i localSubnet = '192.168.%d.0/24' % i
natParams = { 'ip' : '%s/24' % localIP } natParams = { 'ip' : '%s/24' % localIP }
# add NAT to topology # add NAT to topology
nat = self.addNode('nat%d' % i, cls=NAT, subnet=localSubnet, nat = self.addNode('nat%d' % i, cls=NAT, subnet=localSubnet,
inetIntf=inetIntf, localIntf=localIntf) inetIntf=inetIntf, localIntf=localIntf)
switch = self.addSwitch('s%d' % i) switch = self.addSwitch('s%d' % i)
# connect NAT to inet and local switches # connect NAT to inet and local switches
self.addLink(nat, inetSwitch, intfName1=inetIntf) self.addLink(nat, inetSwitch, intfName1=inetIntf)
self.addLink(nat, switch, intfName1=localIntf, params1=natParams) self.addLink(nat, switch, intfName1=localIntf, params1=natParams)
# add host and connect to local switch # add host and connect to local switch
host = self.addHost('h%d' % i, host = self.addHost('h%d' % i,
ip='192.168.%d.100/24' % i, ip='192.168.%d.100/24' % i,
defaultRoute='via %s' % localIP) defaultRoute='via %s' % localIP)
self.addLink(host, switch) self.addLink(host, switch)
@@ -67,4 +67,4 @@ def run():
if __name__ == '__main__': if __name__ == '__main__':
setLogLevel('info') setLogLevel('info')
run() run()
+3 -3
View File
@@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
""" """
Create a network with 5 hosts, numbered 1-4 and 9. Create a network with 5 hosts, numbered 1-4 and 9.
Validate that the port numbers match to the interface name, Validate that the port numbers match to the interface name,
and that the ovs ports match the mininet ports. and that the ovs ports match the mininet ports.
""" """
@@ -54,13 +54,13 @@ def net():
info( '\n*** printing and validating the ports running on each interface\n' ) info( '\n*** printing and validating the ports running on each interface\n' )
for intfs in s1.intfList(): for intfs in s1.intfList():
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, 'is actually on port', s1.ports[intfs], '... ' ) info ( 'Validating that', intfs, 'is actually on port', s1.ports[intfs], '... ' )
if validatePort( s1, intfs ): if validatePort( s1, intfs ):
info( 'Validated.\n' ) info( 'Validated.\n' )
print '\n' print '\n'
# test the network with pingall # test the network with pingall
net.pingAll() net.pingAll()
print '\n' print '\n'
+1 -1
View File
@@ -36,7 +36,7 @@ class testBareSSHD( unittest.TestCase ):
'-o StrictModes=no' ) '-o StrictModes=no' )
p = pexpect.spawn( cmd ) p = pexpect.spawn( cmd )
runOpts = [ 'You may now ssh into h1 at 10.0.0.1', runOpts = [ 'You may now ssh into h1 at 10.0.0.1',
'after 5 seconds, h1 is not listening on port 22', 'after 5 seconds, h1 is not listening on port 22',
pexpect.EOF, pexpect.TIMEOUT ] pexpect.EOF, pexpect.TIMEOUT ]
while True: while True:
index = p.expect( runOpts ) index = p.expect( runOpts )
+3 -3
View File
@@ -6,7 +6,7 @@ Test for cpu.py
results format: results format:
sched cpu client MB/s sched cpu client MB/s
cfs 45.00% 13254.669841 cfs 45.00% 13254.669841
cfs 40.00% 11822.441399 cfs 40.00% 11822.441399
cfs 30.00% 5112.963009 cfs 30.00% 5112.963009
@@ -28,13 +28,13 @@ class testCPU( unittest.TestCase ):
"Verify that CPU utilization is monotonically decreasing for each scheduler" "Verify that CPU utilization is monotonically decreasing for each scheduler"
p = pexpect.spawn( 'python -m mininet.examples.cpu' ) p = pexpect.spawn( 'python -m mininet.examples.cpu' )
# matches each line from results( shown above ) # matches each line from results( shown above )
opts = [ '([a-z]+)\t([\d\.]+)%\t([\d\.]+)', opts = [ '([a-z]+)\t([\d\.]+)%\t([\d\.]+)',
pexpect.EOF ] pexpect.EOF ]
scheds = [] scheds = []
while True: while True:
index = p.expect( opts, timeout=600 ) index = p.expect( opts, timeout=600 )
if index == 0: if index == 0:
sched = p.match.group( 1 ) sched = p.match.group( 1 )
cpu = float( p.match.group( 2 ) ) cpu = float( p.match.group( 2 ) )
bw = float( p.match.group( 3 ) ) bw = float( p.match.group( 3 ) )
if sched not in scheds: if sched not in scheds:
+1 -1
View File
@@ -19,7 +19,7 @@ class testEmptyNet( unittest.TestCase ):
p.sendline( 'pingall' ) p.sendline( 'pingall' )
p.expect ( '(\d+)% dropped' ) p.expect ( '(\d+)% dropped' )
percent = int( p.match.group( 1 ) ) if p.match else -1 percent = int( p.match.group( 1 ) ) if p.match else -1
self.assertEqual( percent, 0 ) self.assertEqual( percent, 0 )
p.expect( self.prompt ) p.expect( self.prompt )
# iperf test # iperf test
p.sendline( 'iperf' ) p.sendline( 'iperf' )
+2 -2
View File
@@ -14,8 +14,8 @@ class testLimit( unittest.TestCase ):
def testLimit( self ): def testLimit( self ):
"Verify that CPU limits are within a 2% tolerance of limit for each scheduler" "Verify that CPU limits are within a 2% tolerance of limit for each scheduler"
p = pexpect.spawn( 'python -m mininet.examples.limit' ) p = pexpect.spawn( 'python -m mininet.examples.limit' )
opts = [ '\*\*\* Testing network ([\d\.]+) Mbps', opts = [ '\*\*\* Testing network ([\d\.]+) Mbps',
'\*\*\* Results: \[([\d\., ]+)\]', '\*\*\* Results: \[([\d\., ]+)\]',
pexpect.EOF ] pexpect.EOF ]
count = 0 count = 0
bw = 0 bw = 0
+2 -2
View File
@@ -15,8 +15,8 @@ class testLinearBandwidth( unittest.TestCase ):
"Verify that bandwidth is monotonically decreasing as # of hops increases" "Verify that bandwidth is monotonically decreasing as # of hops increases"
p = pexpect.spawn( 'python -m mininet.examples.linearbandwidth' ) p = pexpect.spawn( 'python -m mininet.examples.linearbandwidth' )
count = 0 count = 0
opts = [ '\*\*\* Linear network results', opts = [ '\*\*\* Linear network results',
'(\d+)\s+([\d\.]+) (.bits)', '(\d+)\s+([\d\.]+) (.bits)',
pexpect.EOF ] pexpect.EOF ]
while True: while True:
index = p.expect( opts, timeout=600 ) index = p.expect( opts, timeout=600 )
+2 -2
View File
@@ -22,14 +22,14 @@ class testMultiLink( unittest.TestCase ):
hostToIntfs = intfsOutput.split( '\r\n' )[ 1:3 ] hostToIntfs = intfsOutput.split( '\r\n' )[ 1:3 ]
intfList = [] intfList = []
for hostToIntf in hostToIntfs: for hostToIntf in hostToIntfs:
intfList += [ intf for intf in intfList += [ intf for intf in
hostToIntf.split()[1].split(',') ] hostToIntf.split()[1].split(',') ]
# get interfaces from system by running ifconfig on every host # get interfaces from system by running ifconfig on every host
sysIntfList = [] sysIntfList = []
opts = [ 'h(\d)-eth(\d)', self.prompt ] opts = [ 'h(\d)-eth(\d)', self.prompt ]
p.expect( self.prompt ) p.expect( self.prompt )
p.sendline( 'h1 ifconfig' ) p.sendline( 'h1 ifconfig' )
while True: while True:
p.expect( opts ) p.expect( opts )
+1 -1
View File
@@ -11,7 +11,7 @@ from collections import defaultdict
class testMultiPing( unittest.TestCase ): class testMultiPing( unittest.TestCase ):
def testMultiPing( self ): def testMultiPing( self ):
"""Verify that each target is pinged at least once, and """Verify that each target is pinged at least once, and
that pings to 'real' targets are successful and unknown targets fail""" that pings to 'real' targets are successful and unknown targets fail"""
p = pexpect.spawn( 'python -m mininet.examples.multiping' ) p = pexpect.spawn( 'python -m mininet.examples.multiping' )
opts = [ "Host (h\d+) \(([\d.]+)\) will be pinging ips: ([\d\. ]+)", opts = [ "Host (h\d+) \(([\d.]+)\) will be pinging ips: ([\d\. ]+)",
+1 -1
View File
@@ -14,7 +14,7 @@ class testNAT( unittest.TestCase ):
prompt = 'mininet>' prompt = 'mininet>'
@unittest.skipIf( '0 received' in quietRun( 'ping -c 1 %s' % destIP ), @unittest.skipIf( '0 received' in quietRun( 'ping -c 1 %s' % destIP ),
'Destination IP is not reachable' ) 'Destination IP is not reachable' )
def testNAT( self ): def testNAT( self ):
"Attempt to ping an IP on the Internet and verify 0% packet loss" "Attempt to ping an IP on the Internet and verify 0% packet loss"
+3 -3
View File
@@ -15,8 +15,8 @@ class testNumberedports( unittest.TestCase ):
def testConsistency( self ): def testConsistency( self ):
"""verify consistency between mininet and ovs ports""" """verify consistency between mininet and ovs ports"""
p = pexpect.spawn( 'python -m mininet.examples.numberedports' ) p = pexpect.spawn( 'python -m mininet.examples.numberedports' )
opts = [ 'Validating that s1-eth\d is actually on port \d ... Validated.', opts = [ 'Validating that s1-eth\d is actually on port \d ... Validated.',
'Validating that s1-eth\d is actually on port \d ... WARNING', 'Validating that s1-eth\d is actually on port \d ... WARNING',
pexpect.EOF ] pexpect.EOF ]
correct_ports = True correct_ports = True
count = 0 count = 0
@@ -34,7 +34,7 @@ class testNumberedports( unittest.TestCase ):
def testNumbering( self ): def testNumbering( self ):
"""verify that all of the port numbers are printed correctly and consistent with their interface""" """verify that all of the port numbers are printed correctly and consistent with their interface"""
p = pexpect.spawn( 'python -m mininet.examples.numberedports' ) p = pexpect.spawn( 'python -m mininet.examples.numberedports' )
opts = [ 's1-eth(\d+) : (\d+)', opts = [ 's1-eth(\d+) : (\d+)',
pexpect.EOF ] pexpect.EOF ]
count_intfs = 0 count_intfs = 0
while True: while True:
+2 -2
View File
@@ -14,7 +14,7 @@ class testSSHD( unittest.TestCase ):
def connected( self, ip ): def connected( self, ip ):
"Log into ssh server, check banner, then exit" "Log into ssh server, check banner, then exit"
# Note: this test will fail if "Welcome" is not in the sshd banner # Note: this test will fail if "Welcome" is not in the sshd banner
# and '#'' or '$'' are not in the prompt # and '#'' or '$'' are not in the prompt
p = pexpect.spawn( 'ssh -i /tmp/ssh/test_rsa %s' % ip, timeout=10 ) p = pexpect.spawn( 'ssh -i /tmp/ssh/test_rsa %s' % ip, timeout=10 )
while True: while True:
@@ -26,7 +26,7 @@ class testSSHD( unittest.TestCase ):
return False return False
elif index == 2: elif index == 2:
p.sendline( 'exit' ) p.sendline( 'exit' )
p.wait() p.wait()
return True return True
else: else:
return False return False
+1 -1
View File
@@ -47,4 +47,4 @@ class testVLANHost( unittest.TestCase ):
self.assertEqual( i, 0 ) # check vlan intf is present self.assertEqual( i, 0 ) # check vlan intf is present
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
+1 -1
View File
@@ -40,7 +40,7 @@ class VLANHost( Host ):
intf = self.defaultIntf() intf = self.defaultIntf()
# remove IP from default, "physical" interface # remove IP from default, "physical" interface
self.cmd( 'ifconfig %s inet 0' % intf ) self.cmd( 'ifconfig %s inet 0' % intf )
# create VLAN interface # create VLAN interface
self.cmd( 'vconfig add %s %d' % ( intf, vlan ) ) self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
# assign the host's IP to the VLAN interface # assign the host's IP to the VLAN interface
self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) ) self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+1 -1
View File
@@ -92,5 +92,5 @@ def cleanup():
killprocs( 'Tunnel=Ethernet' ) killprocs( 'Tunnel=Ethernet' )
killprocs( '.ssh/mn') killprocs( '.ssh/mn')
sh( 'rm -f ~/.ssh/mn/*' ) sh( 'rm -f ~/.ssh/mn/*' )
info( "*** Cleanup complete.\n" ) info( "*** Cleanup complete.\n" )
+1 -1
View File
@@ -43,7 +43,7 @@ class Intf( object ):
self.link = link self.link = link
self.mac = mac self.mac = mac
self.ip, self.prefixLen = None, None self.ip, self.prefixLen = None, None
# if interface is lo, we know the ip is 127.0.0.1. # if interface is lo, we know the ip is 127.0.0.1.
# This saves an ifconfig command per node # This saves an ifconfig command per node
if self.name == 'lo': if self.name == 'lo':
+4 -4
View File
@@ -692,7 +692,7 @@ class CPULimitedHost( Host ):
retry( retries=3, delaySecs=1, fn=self.cgroupDel ) retry( retries=3, delaySecs=1, fn=self.cgroupDel )
_rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set? _rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set?
@classmethod @classmethod
def checkRtGroupSched( cls ): def checkRtGroupSched( cls ):
"Check (Ubuntu,Debian) kernel config for CONFIG_RT_GROUP_SCHED for RT" "Check (Ubuntu,Debian) kernel config for CONFIG_RT_GROUP_SCHED for RT"
@@ -749,7 +749,7 @@ class CPULimitedHost( Host ):
"""Set overall CPU fraction for this host """Set overall CPU fraction for this host
f: CPU bandwidth limit (positive fraction, or -1 for cfs unlimited) f: CPU bandwidth limit (positive fraction, or -1 for cfs unlimited)
sched: 'rt' or 'cfs' sched: 'rt' or 'cfs'
Note 'cfs' requires CONFIG_CFS_BANDWIDTH, Note 'cfs' requires CONFIG_CFS_BANDWIDTH,
and 'rt' requires CONFIG_RT_GROUP_SCHED""" and 'rt' requires CONFIG_RT_GROUP_SCHED"""
if not sched: if not sched:
sched = self.sched sched = self.sched
@@ -1199,11 +1199,11 @@ OVSKernelSwitch = OVSSwitch
class OVSBridge( OVSSwitch ): class OVSBridge( OVSSwitch ):
"OVSBridge is an OVSSwitch in standalone/bridge mode" "OVSBridge is an OVSSwitch in standalone/bridge mode"
def __init__( self, args, **kwargs ): def __init__( self, args, **kwargs ):
kwargs.update( failMode='standalone' ) kwargs.update( failMode='standalone' )
OVSSwitch.__init__( self, args, **kwargs ) OVSSwitch.__init__( self, args, **kwargs )
def start( self, controllers ): def start( self, controllers ):
OVSSwitch.start( self, controllers=[] ) OVSSwitch.start( self, controllers=[] )
+1 -1
View File
@@ -32,7 +32,7 @@ class LinuxBridge( Switch ):
return 'forwarding' in self.cmd( 'brctl showstp', self ) return 'forwarding' in self.cmd( 'brctl showstp', self )
else: else:
return True return True
def start( self, controllers ): def start( self, controllers ):
"Start Linux bridge" "Start Linux bridge"
self.cmd( 'ifconfig', self, 'down' ) self.cmd( 'ifconfig', self, 'down' )
+1 -1
View File
@@ -181,7 +181,7 @@ class testOptionsTopoCommon( object ):
for rttval in [rttmin, rttavg, rttmax]: for rttval in [rttmin, rttavg, rttmax]:
# Multiply delay by 4 to cover there & back on two links # Multiply delay by 4 to cover there & back on two links
self.assertWithinTolerance( rttval, DELAY_MS * 4.0, self.assertWithinTolerance( rttval, DELAY_MS * 4.0,
DELAY_TOLERANCE, msg ) DELAY_TOLERANCE, msg )
+6 -6
View File
@@ -27,14 +27,14 @@ class testSwitchDpidAssignmentCommon ( object ):
self.assertEqual( switch.defaultDpid(), switch.dpid ) self.assertEqual( switch.defaultDpid(), switch.dpid )
def testActualDpidAssignment( self ): def testActualDpidAssignment( self ):
"""Verify that Switch dpid is the actual dpid assigned if dpid is """Verify that Switch dpid is the actual dpid assigned if dpid is
passed in switch creation.""" passed in switch creation."""
switch = Mininet( Topo(), self.switchClass, Host, Controller ).addSwitch( 'A', dpid = '000000000000ABCD' ) switch = Mininet( Topo(), self.switchClass, Host, Controller ).addSwitch( 'A', dpid = '000000000000ABCD' )
self.assertEqual( switch.dpid, '000000000000ABCD' ) self.assertEqual( switch.dpid, '000000000000ABCD' )
def testDefaultDpidAssignmentFailure( self ): def testDefaultDpidAssignmentFailure( self ):
"""Verify that Default dpid assignment raises an Exception if the """Verify that Default dpid assignment raises an Exception if the
name of the switch does not contin a digit. Also verify the name of the switch does not contin a digit. Also verify the
exception message.""" exception message."""
with self.assertRaises( Exception ) as raises_cm: with self.assertRaises( Exception ) as raises_cm:
Mininet( Topo(), self.switchClass, Host, Controller ).addSwitch( 'A' ) Mininet( Topo(), self.switchClass, Host, Controller ).addSwitch( 'A' )
@@ -58,7 +58,7 @@ class testSwitchDpidAssignmentCommon ( object ):
except TypeError: except TypeError:
# Switch is OVS User Switch # Switch is OVS User Switch
self.assertEqual( switch.dpid, '0' * (16 - len(dpid)) + str(dpid) ) self.assertEqual( switch.dpid, '0' * (16 - len(dpid)) + str(dpid) )
class testSwitchOVSKernel( testSwitchDpidAssignmentCommon, unittest.TestCase ): class testSwitchOVSKernel( testSwitchDpidAssignmentCommon, unittest.TestCase ):
"""Test dpid assignnment of OVS Kernel Switch.""" """Test dpid assignnment of OVS Kernel Switch."""
@@ -67,12 +67,12 @@ class testSwitchOVSKernel( testSwitchDpidAssignmentCommon, unittest.TestCase ):
class testSwitchOVSUser( testSwitchDpidAssignmentCommon, unittest.TestCase ): class testSwitchOVSUser( testSwitchDpidAssignmentCommon, unittest.TestCase ):
"""Test dpid assignnment of OVS User Switch.""" """Test dpid assignnment of OVS User Switch."""
switchClass = partial(OVSSwitch, datapath = 'user') switchClass = partial(OVSSwitch, datapath = 'user')
@unittest.skipUnless( quietRun( 'which ovs-openflowd' ), 'OVS Legacy Kernel switch is not installed' ) @unittest.skipUnless( quietRun( 'which ovs-openflowd' ), 'OVS Legacy Kernel switch is not installed' )
class testSwitchOVSLegacyKernel( testSwitchDpidAssignmentCommon, unittest.TestCase ): class testSwitchOVSLegacyKernel( testSwitchDpidAssignmentCommon, unittest.TestCase ):
"""Test dpid assignnment of OVS Legacy Kernel Switch.""" """Test dpid assignnment of OVS Legacy Kernel Switch."""
switchClass = OVSLegacyKernelSwitch switchClass = OVSLegacyKernelSwitch
@unittest.skipUnless( quietRun( 'which ivs-ctl' ), 'IVS switch is not installed' ) @unittest.skipUnless( quietRun( 'which ivs-ctl' ), 'IVS switch is not installed' )
class testSwitchIVS( testSwitchDpidAssignmentCommon, unittest.TestCase ): class testSwitchIVS( testSwitchDpidAssignmentCommon, unittest.TestCase ):
"""Test dpid assignment of IVS switch.""" """Test dpid assignment of IVS switch."""
+2 -2
View File
@@ -101,7 +101,7 @@ class Topo( object ):
"Data center network representation for structured multi-trees." "Data center network representation for structured multi-trees."
def __init__( self, *args, **params ): def __init__( self, *args, **params ):
"""Topo object. """Topo object.
Optional named parameters: Optional named parameters:
hinfo: default host options hinfo: default host options
sopts: default switch options sopts: default switch options
@@ -256,7 +256,7 @@ class Topo( object ):
if key is None: if key is None:
key = min( entry ) key = min( entry )
return entry, key return entry, key
def linkInfo( self, src, dst, key=None ): def linkInfo( self, src, dst, key=None ):
"Return link metadata dict" "Return link metadata dict"
entry, key = self._linkEntry( src, dst, key ) entry, key = self._linkEntry( src, dst, key )
+2 -2
View File
@@ -41,7 +41,7 @@ class TorusTopo( Topo ):
with the default controller or any Ethernet bridge with the default controller or any Ethernet bridge
without STP turned on! It can be used with STP, e.g.: without STP turned on! It can be used with STP, e.g.:
# mn --topo torus,3,3 --switch lxbr,stp=1 --test pingall""" # mn --topo torus,3,3 --switch lxbr,stp=1 --test pingall"""
def build( self, x, y ): def build( self, x, y ):
if x < 3 or y < 3: if x < 3 or y < 3:
raise Exception( 'Please use 3x3 or greater for compatibility ' raise Exception( 'Please use 3x3 or greater for compatibility '
@@ -65,5 +65,5 @@ class TorusTopo( Topo ):
self.addLink( sw1, sw2 ) self.addLink( sw1, sw2 )
self.addLink( sw1, sw3 ) self.addLink( sw1, sw3 )
+3 -3
View File
@@ -30,7 +30,7 @@ def fixParam( line ):
def fixReturns( line ): def fixReturns( line ):
"Change returns: foo to @return foo" "Change returns: foo to @return foo"
return re.sub( 'returns:', r'@returns', line ) return re.sub( 'returns:', r'@returns', line )
def fixLine( line ): def fixLine( line ):
global comment global comment
match = spaces.match( line ) match = spaces.match( line )
@@ -69,7 +69,7 @@ def funTest():
).splitlines( True ) ).splitlines( True )
fixLines( testFun ) fixLines( testFun )
def fixLines( lines, fid ): def fixLines( lines, fid ):
for line in lines: for line in lines:
os.write( fid, fixLine( line ) ) os.write( fid, fixLine( line ) )
@@ -86,4 +86,4 @@ if __name__ == '__main__':
+1 -1
View File
@@ -881,7 +881,7 @@ def getMininetVersion( vm ):
return version return version
def bootAndRun( image, prompt=Prompt, memory=1024, outputFile=None, def bootAndRun( image, prompt=Prompt, memory=1024, outputFile=None,
runFunction=None, **runArgs ): runFunction=None, **runArgs ):
"""Boot and test VM """Boot and test VM
tests: list of tests to run tests: list of tests to run