pep8: fix E128 continuation line under-indented errors
I wasn't sure this was worth fixing at first, but it does look more readable now.
This commit is contained in:
@@ -37,14 +37,14 @@ from mininet.util import buildTopo
|
|||||||
# built in topologies, created only when run
|
# built in topologies, created only when run
|
||||||
TOPODEF = 'minimal'
|
TOPODEF = 'minimal'
|
||||||
TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
|
TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
|
||||||
'linear': LinearTopo,
|
'linear': LinearTopo,
|
||||||
'reversed': SingleSwitchReversedTopo,
|
'reversed': SingleSwitchReversedTopo,
|
||||||
'single': SingleSwitchTopo,
|
'single': SingleSwitchTopo,
|
||||||
'tree': TreeTopo }
|
'tree': TreeTopo }
|
||||||
|
|
||||||
SWITCHDEF = 'ovsk'
|
SWITCHDEF = 'ovsk'
|
||||||
SWITCHES = { 'user': UserSwitch,
|
SWITCHES = { 'user': UserSwitch,
|
||||||
'ovsk': OVSKernelSwitch,
|
'ovsk': OVSKernelSwitch,
|
||||||
'ovsl': OVSLegacyKernelSwitch }
|
'ovsl': OVSLegacyKernelSwitch }
|
||||||
|
|
||||||
HOSTDEF = 'proc'
|
HOSTDEF = 'proc'
|
||||||
@@ -66,10 +66,13 @@ LINKS = { 'default': Link,
|
|||||||
|
|
||||||
# optional tests to run
|
# optional tests to run
|
||||||
TESTS = [ 'cli', 'build', 'pingall', 'pingpair', 'iperf', 'all', 'iperfudp',
|
TESTS = [ 'cli', 'build', 'pingall', 'pingpair', 'iperf', 'all', 'iperfudp',
|
||||||
'none' ]
|
'none' ]
|
||||||
|
|
||||||
ALTSPELLING = { 'pingall': 'pingAll', 'pingpair': 'pingPair',
|
ALTSPELLING = { 'pingall': 'pingAll',
|
||||||
'iperfudp': 'iperfUdp', 'iperfUDP': 'iperfUdp', 'prefixlen': 'prefixLen' }
|
'pingpair': 'pingPair',
|
||||||
|
'iperfudp': 'iperfUdp',
|
||||||
|
'iperfUDP': 'iperfUdp',
|
||||||
|
'prefixlen': 'prefixLen' }
|
||||||
|
|
||||||
|
|
||||||
def addDictOption( opts, choicesDict, default, name, helpStr=None ):
|
def addDictOption( opts, choicesDict, default, name, helpStr=None ):
|
||||||
@@ -81,14 +84,14 @@ def addDictOption( opts, choicesDict, default, name, helpStr=None ):
|
|||||||
help: string"""
|
help: string"""
|
||||||
if default not in choicesDict:
|
if default not in choicesDict:
|
||||||
raise Exception( 'Invalid default %s for choices dict: %s' %
|
raise Exception( 'Invalid default %s for choices dict: %s' %
|
||||||
( default, name ) )
|
( default, name ) )
|
||||||
if not helpStr:
|
if not helpStr:
|
||||||
helpStr = ( '|'.join( sorted( choicesDict.keys() ) ) +
|
helpStr = ( '|'.join( sorted( choicesDict.keys() ) ) +
|
||||||
'[,param=value...]' )
|
'[,param=value...]' )
|
||||||
opts.add_option( '--' + name,
|
opts.add_option( '--' + name,
|
||||||
type='string',
|
type='string',
|
||||||
default = default,
|
default = default,
|
||||||
help = helpStr )
|
help = helpStr )
|
||||||
|
|
||||||
|
|
||||||
def version( *_args ):
|
def version( *_args ):
|
||||||
@@ -158,36 +161,36 @@ class MininetRunner( object ):
|
|||||||
addDictOption( opts, TOPOS, TOPODEF, 'topo' )
|
addDictOption( opts, TOPOS, TOPODEF, 'topo' )
|
||||||
|
|
||||||
opts.add_option( '--clean', '-c', action='store_true',
|
opts.add_option( '--clean', '-c', action='store_true',
|
||||||
default=False, help='clean and exit' )
|
default=False, help='clean and exit' )
|
||||||
opts.add_option( '--custom', type='string', default=None,
|
opts.add_option( '--custom', type='string', default=None,
|
||||||
help='read custom topo and node params from .py file' )
|
help='read custom topo and node params from .py file' )
|
||||||
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 ) )
|
||||||
opts.add_option( '--xterms', '-x', action='store_true',
|
opts.add_option( '--xterms', '-x', action='store_true',
|
||||||
default=False, help='spawn xterms for each node' )
|
default=False, help='spawn xterms for each node' )
|
||||||
opts.add_option( '--ipbase', '-i', type='string', default='10.0.0.0/8',
|
opts.add_option( '--ipbase', '-i', type='string', default='10.0.0.0/8',
|
||||||
help='base IP address for hosts' )
|
help='base IP address for hosts' )
|
||||||
opts.add_option( '--mac', action='store_true',
|
opts.add_option( '--mac', action='store_true',
|
||||||
default=False, help='automatically set host MACs' )
|
default=False, help='automatically set host MACs' )
|
||||||
opts.add_option( '--arp', action='store_true',
|
opts.add_option( '--arp', action='store_true',
|
||||||
default=False, help='set all-pairs ARP entries' )
|
default=False, help='set all-pairs ARP entries' )
|
||||||
opts.add_option( '--verbosity', '-v', type='choice',
|
opts.add_option( '--verbosity', '-v', type='choice',
|
||||||
choices=LEVELS.keys(), default = 'info',
|
choices=LEVELS.keys(), default = 'info',
|
||||||
help = '|'.join( LEVELS.keys() ) )
|
help = '|'.join( LEVELS.keys() ) )
|
||||||
opts.add_option( '--innamespace', action='store_true',
|
opts.add_option( '--innamespace', action='store_true',
|
||||||
default=False, help='sw and ctrl in namespace?' )
|
default=False, help='sw and ctrl in namespace?' )
|
||||||
opts.add_option( '--listenport', type='int', default=6635,
|
opts.add_option( '--listenport', type='int', default=6635,
|
||||||
help='base port for passive switch listening' )
|
help='base port for passive switch listening' )
|
||||||
opts.add_option( '--nolistenport', action='store_true',
|
opts.add_option( '--nolistenport', action='store_true',
|
||||||
default=False, help="don't use passive listening port")
|
default=False, help="don't use passive listening port")
|
||||||
opts.add_option( '--pre', type='string', default=None,
|
opts.add_option( '--pre', type='string', default=None,
|
||||||
help='CLI script to run before tests' )
|
help='CLI script to run before tests' )
|
||||||
opts.add_option( '--post', type='string', default=None,
|
opts.add_option( '--post', type='string', default=None,
|
||||||
help='CLI script to run after tests' )
|
help='CLI script to run after tests' )
|
||||||
opts.add_option( '--prefixlen', type='int', default=8,
|
opts.add_option( '--prefixlen', type='int', default=8,
|
||||||
help='prefix length (e.g. /8) for automatic '
|
help='prefix length (e.g. /8) for automatic '
|
||||||
'network configuration' )
|
'network configuration' )
|
||||||
opts.add_option( '--pin', action='store_true',
|
opts.add_option( '--pin', action='store_true',
|
||||||
default=False, help="pin hosts to CPU cores "
|
default=False, help="pin hosts to CPU cores "
|
||||||
"(requires --host cfs or --host rt)" )
|
"(requires --host cfs or --host rt)" )
|
||||||
|
|||||||
+8
-11
@@ -74,11 +74,11 @@ class Console( Frame ):
|
|||||||
"Pop up a new terminal window for a node."
|
"Pop up a new terminal window for a node."
|
||||||
net.terms += makeTerms( [ node ], title )
|
net.terms += makeTerms( [ node ], title )
|
||||||
label = Button( self, text=self.node.name, command=newTerm,
|
label = Button( self, text=self.node.name, command=newTerm,
|
||||||
**self.buttonStyle )
|
**self.buttonStyle )
|
||||||
label.pack( side='top', fill='x' )
|
label.pack( side='top', fill='x' )
|
||||||
text = Text( self, wrap='word', **self.textStyle )
|
text = Text( self, wrap='word', **self.textStyle )
|
||||||
ybar = Scrollbar( self, orient='vertical', width=7,
|
ybar = Scrollbar( self, orient='vertical', width=7,
|
||||||
command=text.yview )
|
command=text.yview )
|
||||||
text.configure( yscrollcommand=ybar.set )
|
text.configure( yscrollcommand=ybar.set )
|
||||||
text.pack( side='left', expand=True, fill='both' )
|
text.pack( side='left', expand=True, fill='both' )
|
||||||
ybar.pack( side='right', fill='y' )
|
ybar.pack( side='right', fill='y' )
|
||||||
@@ -95,7 +95,7 @@ class Console( Frame ):
|
|||||||
# way to trigger a file event handler from Tk's
|
# way to trigger a file event handler from Tk's
|
||||||
# event loop!
|
# event loop!
|
||||||
self.tk.createfilehandler( self.node.stdout, READABLE,
|
self.tk.createfilehandler( self.node.stdout, READABLE,
|
||||||
self.handleReadable )
|
self.handleReadable )
|
||||||
|
|
||||||
# We're not a terminal (yet?), so we ignore the following
|
# We're not a terminal (yet?), so we ignore the following
|
||||||
# control characters other than [\b\n\r]
|
# control characters other than [\b\n\r]
|
||||||
@@ -169,11 +169,8 @@ class Graph( Frame ):
|
|||||||
|
|
||||||
"Graph that we can add bars to over time."
|
"Graph that we can add bars to over time."
|
||||||
|
|
||||||
def __init__( self, parent=None,
|
def __init__( self, parent=None, bg = 'white', gheight=200, gwidth=500,
|
||||||
bg = 'white',
|
barwidth=10, ymax=3.5,):
|
||||||
gheight=200, gwidth=500,
|
|
||||||
barwidth=10,
|
|
||||||
ymax=3.5,):
|
|
||||||
|
|
||||||
Frame.__init__( self, parent )
|
Frame.__init__( self, parent )
|
||||||
|
|
||||||
@@ -195,7 +192,7 @@ class Graph( Frame ):
|
|||||||
width = 25
|
width = 25
|
||||||
ymax = self.ymax
|
ymax = self.ymax
|
||||||
scale = Canvas( self, width=width, height=height,
|
scale = Canvas( self, width=width, height=height,
|
||||||
background=self.bg )
|
background=self.bg )
|
||||||
opts = { 'fill': 'red' }
|
opts = { 'fill': 'red' }
|
||||||
# Draw scale line
|
# Draw scale line
|
||||||
scale.create_line( width - 1, height, width - 1, 0, **opts )
|
scale.create_line( width - 1, height, width - 1, 0, **opts )
|
||||||
@@ -211,7 +208,7 @@ class Graph( Frame ):
|
|||||||
ofs = 20
|
ofs = 20
|
||||||
height = self.gheight + ofs
|
height = self.gheight + ofs
|
||||||
self.graph.configure( scrollregion=( 0, -ofs,
|
self.graph.configure( scrollregion=( 0, -ofs,
|
||||||
self.xpos * self.barwidth, height ) )
|
self.xpos * self.barwidth, height ) )
|
||||||
self.scale.configure( scrollregion=( 0, -ofs, 0, height ) )
|
self.scale.configure( scrollregion=( 0, -ofs, 0, height ) )
|
||||||
|
|
||||||
def yview( self, *args ):
|
def yview( self, *args ):
|
||||||
@@ -231,7 +228,7 @@ class Graph( Frame ):
|
|||||||
xbar = Scrollbar( self, orient='horizontal', command=graph.xview )
|
xbar = Scrollbar( self, orient='horizontal', command=graph.xview )
|
||||||
ybar = Scrollbar( self, orient='vertical', command=self.yview )
|
ybar = Scrollbar( self, orient='vertical', command=self.yview )
|
||||||
graph.configure( xscrollcommand=xbar.set, yscrollcommand=ybar.set,
|
graph.configure( xscrollcommand=xbar.set, yscrollcommand=ybar.set,
|
||||||
scrollregion=(0, 0, width, height ) )
|
scrollregion=(0, 0, width, height ) )
|
||||||
scale.configure( yscrollcommand=ybar.set )
|
scale.configure( yscrollcommand=ybar.set )
|
||||||
|
|
||||||
# Layout
|
# Layout
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ def checkIntf( intf ):
|
|||||||
ips = re.findall( r'\d+\.\d+\.\d+\.\d+', quietRun( 'ifconfig ' + intf ) )
|
ips = re.findall( r'\d+\.\d+\.\d+\.\d+', quietRun( 'ifconfig ' + intf ) )
|
||||||
if ips:
|
if ips:
|
||||||
error( 'Error:', intf, 'has an IP address,'
|
error( 'Error:', intf, 'has an IP address,'
|
||||||
'and is probably in use!\n' )
|
'and is probably in use!\n' )
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ def linearBandwidthTest( lengths ):
|
|||||||
hostCount = switchCount + 1
|
hostCount = switchCount + 1
|
||||||
|
|
||||||
switches = { 'reference user': UserSwitch,
|
switches = { 'reference user': UserSwitch,
|
||||||
'Open vSwitch kernel': OVSKernelSwitch }
|
'Open vSwitch kernel': OVSKernelSwitch }
|
||||||
|
|
||||||
topo = LinearTestTopo( hostCount )
|
topo = LinearTestTopo( hostCount )
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class MiniEdit( Frame ):
|
|||||||
appMenu = Menu( mbar, tearoff=False )
|
appMenu = Menu( mbar, tearoff=False )
|
||||||
mbar.add_cascade( label=self.appName, font=font, menu=appMenu )
|
mbar.add_cascade( label=self.appName, font=font, menu=appMenu )
|
||||||
appMenu.add_command( label='About MiniEdit', command=self.about,
|
appMenu.add_command( label='About MiniEdit', command=self.about,
|
||||||
font=font)
|
font=font)
|
||||||
appMenu.add_separator()
|
appMenu.add_separator()
|
||||||
appMenu.add_command( label='Quit', command=self.quit, font=font )
|
appMenu.add_command( label='Quit', command=self.quit, font=font )
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ class MiniEdit( Frame ):
|
|||||||
editMenu = Menu( mbar, tearoff=False )
|
editMenu = Menu( mbar, tearoff=False )
|
||||||
mbar.add_cascade( label="Edit", font=font, menu=editMenu )
|
mbar.add_cascade( label="Edit", font=font, menu=editMenu )
|
||||||
editMenu.add_command( label="Cut", font=font,
|
editMenu.add_command( label="Cut", font=font,
|
||||||
command=lambda: self.deleteSelection( None ) )
|
command=lambda: self.deleteSelection( None ) )
|
||||||
|
|
||||||
runMenu = Menu( mbar, tearoff=False )
|
runMenu = Menu( mbar, tearoff=False )
|
||||||
mbar.add_cascade( label="Run", font=font, menu=runMenu )
|
mbar.add_cascade( label="Run", font=font, menu=runMenu )
|
||||||
@@ -143,7 +143,7 @@ class MiniEdit( Frame ):
|
|||||||
f = Frame( self )
|
f = Frame( self )
|
||||||
|
|
||||||
canvas = Canvas( f, width=self.cwidth, height=self.cheight,
|
canvas = Canvas( f, width=self.cwidth, height=self.cheight,
|
||||||
bg=self.bg )
|
bg=self.bg )
|
||||||
|
|
||||||
# Scroll bars
|
# Scroll bars
|
||||||
xbar = Scrollbar( f, orient='horizontal', command=canvas.xview )
|
xbar = Scrollbar( f, orient='horizontal', command=canvas.xview )
|
||||||
@@ -177,7 +177,7 @@ class MiniEdit( Frame ):
|
|||||||
bbox = self.canvas.bbox( 'all' )
|
bbox = self.canvas.bbox( 'all' )
|
||||||
if bbox is not None:
|
if bbox is not None:
|
||||||
self.canvas.configure( scrollregion=( 0, 0, bbox[ 2 ],
|
self.canvas.configure( scrollregion=( 0, 0, bbox[ 2 ],
|
||||||
bbox[ 3 ] ) )
|
bbox[ 3 ] ) )
|
||||||
|
|
||||||
def canvasx( self, x_root ):
|
def canvasx( self, x_root ):
|
||||||
"Convert root x coordinate to canvas coordinate."
|
"Convert root x coordinate to canvas coordinate."
|
||||||
@@ -223,7 +223,7 @@ class MiniEdit( Frame ):
|
|||||||
for cmd, color in [ ( 'Stop', 'darkRed' ), ( 'Run', 'darkGreen' ) ]:
|
for cmd, color in [ ( 'Stop', 'darkRed' ), ( 'Run', 'darkGreen' ) ]:
|
||||||
doCmd = getattr( self, 'do' + cmd )
|
doCmd = getattr( self, 'do' + cmd )
|
||||||
b = Button( toolbar, text=cmd, font=self.smallFont,
|
b = Button( toolbar, text=cmd, font=self.smallFont,
|
||||||
fg=color, command=doCmd )
|
fg=color, command=doCmd )
|
||||||
b.pack( fill='x', side='bottom' )
|
b.pack( fill='x', side='bottom' )
|
||||||
|
|
||||||
return toolbar
|
return toolbar
|
||||||
@@ -308,7 +308,7 @@ class MiniEdit( Frame ):
|
|||||||
def nodeIcon( self, node, name ):
|
def nodeIcon( self, node, name ):
|
||||||
"Create a new node icon."
|
"Create a new node icon."
|
||||||
icon = Button( self.canvas, image=self.images[ node ],
|
icon = Button( self.canvas, image=self.images[ node ],
|
||||||
text=name, compound='top' )
|
text=name, compound='top' )
|
||||||
# Unfortunately bindtags wants a tuple
|
# Unfortunately bindtags wants a tuple
|
||||||
bindtags = [ str( self.nodeBindings ) ]
|
bindtags = [ str( self.nodeBindings ) ]
|
||||||
bindtags += list( icon.bindtags() )
|
bindtags += list( icon.bindtags() )
|
||||||
@@ -322,8 +322,8 @@ class MiniEdit( Frame ):
|
|||||||
self.nodeCount += 1
|
self.nodeCount += 1
|
||||||
name = self.nodePrefixes[ node ] + str( self.nodeCount )
|
name = self.nodePrefixes[ node ] + str( self.nodeCount )
|
||||||
icon = self.nodeIcon( node, name )
|
icon = self.nodeIcon( node, name )
|
||||||
item = self.canvas.create_window( x, y, anchor='c',
|
item = self.canvas.create_window( x, y, anchor='c', window=icon,
|
||||||
window=icon, tags=node )
|
tags=node )
|
||||||
self.widgetToItem[ icon ] = item
|
self.widgetToItem[ icon ] = item
|
||||||
self.itemToWidget[ item ] = icon
|
self.itemToWidget[ item ] = icon
|
||||||
self.selectItem( item )
|
self.selectItem( item )
|
||||||
@@ -437,7 +437,7 @@ class MiniEdit( Frame ):
|
|||||||
item = self.widgetToItem[ w ]
|
item = self.widgetToItem[ w ]
|
||||||
x, y = self.canvas.coords( item )
|
x, y = self.canvas.coords( item )
|
||||||
self.link = self.canvas.create_line( x, y, x, y, width=4,
|
self.link = self.canvas.create_line( x, y, x, y, width=4,
|
||||||
fill='blue', tag='link' )
|
fill='blue', tag='link' )
|
||||||
self.linkx, self.linky = x, y
|
self.linkx, self.linky = x, y
|
||||||
self.linkWidget = w
|
self.linkWidget = w
|
||||||
self.linkItem = item
|
self.linkItem = item
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ def startpings( host, targetips ):
|
|||||||
'done &' )
|
'done &' )
|
||||||
|
|
||||||
print ( '*** Host %s (%s) will be pinging ips: %s' %
|
print ( '*** Host %s (%s) will be pinging ips: %s' %
|
||||||
( host.name, host.IP(), targetips ) )
|
( host.name, host.IP(), targetips ) )
|
||||||
|
|
||||||
host.cmd( cmd )
|
host.cmd( cmd )
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ def monitorFiles( outfiles, seconds, timeoutms ):
|
|||||||
tails, fdToFile, fdToHost = {}, {}, {}
|
tails, fdToFile, fdToHost = {}, {}, {}
|
||||||
for h, outfile in outfiles.iteritems():
|
for h, outfile in outfiles.iteritems():
|
||||||
tail = Popen( [ 'tail', '-f', outfile ],
|
tail = Popen( [ 'tail', '-f', outfile ],
|
||||||
stdout=PIPE, stderr=devnull )
|
stdout=PIPE, stderr=devnull )
|
||||||
fd = tail.stdout.fileno()
|
fd = tail.stdout.fileno()
|
||||||
tails[ h ] = tail
|
tails[ h ] = tail
|
||||||
fdToFile[ fd ] = tail.stdout
|
fdToFile[ fd ] = tail.stdout
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ def treePing64():
|
|||||||
"Run ping test on 64-node tree networks."
|
"Run ping test on 64-node tree networks."
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
switches = { # 'reference kernel': KernelSwitch,
|
switches = { # 'reference kernel': KernelSwitch,
|
||||||
'reference user': UserSwitch,
|
'reference user': UserSwitch,
|
||||||
'Open vSwitch kernel': OVSKernelSwitch }
|
'Open vSwitch kernel': OVSKernelSwitch }
|
||||||
|
|
||||||
for name in switches:
|
for name in switches:
|
||||||
print "*** Testing", name, "datapath"
|
print "*** Testing", name, "datapath"
|
||||||
|
|||||||
+3
-3
@@ -192,7 +192,7 @@ class CLI( Cmd ):
|
|||||||
"List interfaces."
|
"List interfaces."
|
||||||
for node in self.nodelist:
|
for node in self.nodelist:
|
||||||
output( '%s: %s\n' %
|
output( '%s: %s\n' %
|
||||||
( node.name, ','.join( node.intfNames() ) ) )
|
( node.name, ','.join( node.intfNames() ) ) )
|
||||||
|
|
||||||
def do_dump( self, _line ):
|
def do_dump( self, _line ):
|
||||||
"Dump node info."
|
"Dump node info."
|
||||||
@@ -303,8 +303,8 @@ class CLI( Cmd ):
|
|||||||
node = self.nodemap[ first ]
|
node = self.nodemap[ first ]
|
||||||
# Substitute IP addresses for node names in command
|
# Substitute IP addresses for node names in command
|
||||||
rest = [ self.nodemap[ arg ].IP()
|
rest = [ self.nodemap[ arg ].IP()
|
||||||
if arg in self.nodemap else arg
|
if arg in self.nodemap else arg
|
||||||
for arg in rest ]
|
for arg in rest ]
|
||||||
rest = ' '.join( rest )
|
rest = ' '.join( rest )
|
||||||
# Run cmd on node:
|
# Run cmd on node:
|
||||||
builtin = isShellBuiltin( first )
|
builtin = isShellBuiltin( first )
|
||||||
|
|||||||
+9
-8
@@ -202,13 +202,13 @@ class TCIntf( Intf ):
|
|||||||
elif use_tbf:
|
elif use_tbf:
|
||||||
if latency_ms is None:
|
if latency_ms is None:
|
||||||
latency_ms = 15 * 8 / bw
|
latency_ms = 15 * 8 / bw
|
||||||
cmds += ['%s qdisc add dev %s root handle 1: tbf ' +
|
cmds += [ '%s qdisc add dev %s root handle 1: tbf ' +
|
||||||
'rate %fMbit burst 15000 latency %fms' %
|
'rate %fMbit burst 15000 latency %fms' %
|
||||||
( bw, latency_ms ) ]
|
( bw, latency_ms ) ]
|
||||||
else:
|
else:
|
||||||
cmds += [ '%s qdisc add dev %s root handle 1:0 htb default 1',
|
cmds += [ '%s qdisc add dev %s root handle 1:0 htb default 1',
|
||||||
'%s class add dev %s parent 1:0 classid 1:1 htb ' +
|
'%s class add dev %s parent 1:0 classid 1:1 htb ' +
|
||||||
'rate %fMbit burst 15k' % bw ]
|
'rate %fMbit burst 15k' % bw ]
|
||||||
parent = ' parent 1:1 '
|
parent = ' parent 1:1 '
|
||||||
|
|
||||||
# ECN or RED
|
# ECN or RED
|
||||||
@@ -282,9 +282,10 @@ class TCIntf( Intf ):
|
|||||||
|
|
||||||
# Bandwidth limits via various methods
|
# Bandwidth limits via various methods
|
||||||
bwcmds, parent = self.bwCmds( bw=bw, speedup=speedup,
|
bwcmds, parent = self.bwCmds( bw=bw, speedup=speedup,
|
||||||
use_hfsc=use_hfsc, use_tbf=use_tbf,
|
use_hfsc=use_hfsc, use_tbf=use_tbf,
|
||||||
latency_ms=latency_ms, enable_ecn=enable_ecn,
|
latency_ms=latency_ms,
|
||||||
enable_red=enable_red )
|
enable_ecn=enable_ecn,
|
||||||
|
enable_red=enable_red )
|
||||||
cmds += bwcmds
|
cmds += bwcmds
|
||||||
|
|
||||||
# Delay/jitter/loss/max_queue_size using netem
|
# Delay/jitter/loss/max_queue_size using netem
|
||||||
|
|||||||
+5
-5
@@ -11,11 +11,11 @@ import types
|
|||||||
OUTPUT = 25
|
OUTPUT = 25
|
||||||
|
|
||||||
LEVELS = { 'debug': logging.DEBUG,
|
LEVELS = { 'debug': logging.DEBUG,
|
||||||
'info': logging.INFO,
|
'info': logging.INFO,
|
||||||
'output': OUTPUT,
|
'output': OUTPUT,
|
||||||
'warning': logging.WARNING,
|
'warning': logging.WARNING,
|
||||||
'error': logging.ERROR,
|
'error': logging.ERROR,
|
||||||
'critical': logging.CRITICAL }
|
'critical': logging.CRITICAL }
|
||||||
|
|
||||||
# change this to logging.INFO to get printouts when running unit tests
|
# change this to logging.INFO to get printouts when running unit tests
|
||||||
LOGLEVELDEFAULT = OUTPUT
|
LOGLEVELDEFAULT = OUTPUT
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ def moduleDeps( subtract=None, add=None ):
|
|||||||
modprobeOutput = modprobe( mod )
|
modprobeOutput = modprobe( mod )
|
||||||
if modprobeOutput:
|
if modprobeOutput:
|
||||||
error( 'Error inserting ' + mod +
|
error( 'Error inserting ' + mod +
|
||||||
' - is it installed and available via modprobe?\n' +
|
' - is it installed and available via modprobe?\n' +
|
||||||
'Error was: "%s"\n' % modprobeOutput )
|
'Error was: "%s"\n' % modprobeOutput )
|
||||||
if mod not in lsmod():
|
if mod not in lsmod():
|
||||||
error( 'Failed to insert ' + mod + ' - quitting.\n' )
|
error( 'Failed to insert ' + mod + ' - quitting.\n' )
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
@@ -63,6 +63,6 @@ def pathCheck( *args, **kwargs ):
|
|||||||
for arg in args:
|
for arg in args:
|
||||||
if not quietRun( 'which ' + arg ):
|
if not quietRun( 'which ' + arg ):
|
||||||
error( 'Cannot find required executable %s.\n' % arg +
|
error( 'Cannot find required executable %s.\n' % arg +
|
||||||
'Please make sure that %s is installed ' % moduleName +
|
'Please make sure that %s is installed ' % moduleName +
|
||||||
'and available in your $PATH:\n(%s)\n' % environ[ 'PATH' ] )
|
'and available in your $PATH:\n(%s)\n' % environ[ 'PATH' ] )
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
|
|||||||
+8
-8
@@ -107,11 +107,11 @@ class Mininet( object ):
|
|||||||
"Network emulation with hosts spawned in network namespaces."
|
"Network emulation with hosts spawned in network namespaces."
|
||||||
|
|
||||||
def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
|
def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
|
||||||
controller=Controller, link=Link, intf=Intf,
|
controller=Controller, link=Link, intf=Intf,
|
||||||
build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
|
build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
|
||||||
inNamespace=False,
|
inNamespace=False,
|
||||||
autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
|
autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
|
||||||
listenPort=None ):
|
listenPort=None ):
|
||||||
"""Create Mininet object.
|
"""Create Mininet object.
|
||||||
topo: Topo (topology) object or None
|
topo: Topo (topology) object or None
|
||||||
switch: default Switch class
|
switch: default Switch class
|
||||||
@@ -307,7 +307,7 @@ class Mininet( object ):
|
|||||||
def configureControlNetwork( self ):
|
def configureControlNetwork( self ):
|
||||||
"Control net config hook: override in subclass"
|
"Control net config hook: override in subclass"
|
||||||
raise Exception( 'configureControlNetwork: '
|
raise Exception( 'configureControlNetwork: '
|
||||||
'should be overriden in subclass', self )
|
'should be overriden in subclass', self )
|
||||||
|
|
||||||
def build( self ):
|
def build( self ):
|
||||||
"Build mininet."
|
"Build mininet."
|
||||||
@@ -519,7 +519,7 @@ class Mininet( object ):
|
|||||||
output('waiting for iperf to start up...')
|
output('waiting for iperf to start up...')
|
||||||
sleep(.5)
|
sleep(.5)
|
||||||
cliout = client.cmd( iperfArgs + '-t 5 -c ' + server.IP() + ' ' +
|
cliout = client.cmd( iperfArgs + '-t 5 -c ' + server.IP() + ' ' +
|
||||||
bwArgs )
|
bwArgs )
|
||||||
debug( 'Client output: %s\n' % cliout )
|
debug( 'Client output: %s\n' % cliout )
|
||||||
server.sendInt()
|
server.sendInt()
|
||||||
servout += server.waitOutput()
|
servout += server.waitOutput()
|
||||||
@@ -617,7 +617,7 @@ class MininetWithControlNet( Mininet ):
|
|||||||
# in the control network location.
|
# in the control network location.
|
||||||
|
|
||||||
def configureRoutedControlNetwork( self, ip='192.168.123.1',
|
def configureRoutedControlNetwork( self, ip='192.168.123.1',
|
||||||
prefixLen=16 ):
|
prefixLen=16 ):
|
||||||
"""Configure a routed control network on controller and switches.
|
"""Configure a routed control network on controller and switches.
|
||||||
For use with the user datapath only right now."""
|
For use with the user datapath only right now."""
|
||||||
controller = self.controllers[ 0 ]
|
controller = self.controllers[ 0 ]
|
||||||
|
|||||||
+32
-31
@@ -52,7 +52,7 @@ from subprocess import Popen, PIPE, STDOUT
|
|||||||
|
|
||||||
from mininet.log import info, error, warn, debug
|
from mininet.log import info, error, warn, debug
|
||||||
from mininet.util import ( quietRun, errRun, errFail, moveIntf, isShellBuiltin,
|
from mininet.util import ( quietRun, errRun, errFail, moveIntf, isShellBuiltin,
|
||||||
numCores, retry, mountCgroups )
|
numCores, retry, mountCgroups )
|
||||||
from mininet.moduledeps import moduleDeps, pathCheck, OVS_KMOD, OF_KMOD, TUN
|
from mininet.moduledeps import moduleDeps, pathCheck, OVS_KMOD, OF_KMOD, TUN
|
||||||
from mininet.link import Link, Intf, TCIntf
|
from mininet.link import Link, Intf, TCIntf
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ class Node( object ):
|
|||||||
# bash -m: enable job control
|
# bash -m: enable job control
|
||||||
cmd = [ 'mnexec', opts, 'bash', '-m' ]
|
cmd = [ 'mnexec', opts, 'bash', '-m' ]
|
||||||
self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
|
self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
|
||||||
close_fds=True )
|
close_fds=True )
|
||||||
self.stdin = self.shell.stdin
|
self.stdin = self.shell.stdin
|
||||||
self.stdout = self.shell.stdout
|
self.stdout = self.shell.stdout
|
||||||
self.pid = self.shell.pid
|
self.pid = self.shell.pid
|
||||||
@@ -355,7 +355,7 @@ class Node( object ):
|
|||||||
return self.intfs[ min( ports ) ]
|
return self.intfs[ min( ports ) ]
|
||||||
else:
|
else:
|
||||||
warn( '*** defaultIntf: warning:', self.name,
|
warn( '*** defaultIntf: warning:', self.name,
|
||||||
'has no interfaces\n' )
|
'has no interfaces\n' )
|
||||||
|
|
||||||
def intf( self, intf='' ):
|
def intf( self, intf='' ):
|
||||||
"""Return our interface object with given name,
|
"""Return our interface object with given name,
|
||||||
@@ -513,7 +513,7 @@ class Node( object ):
|
|||||||
def __repr__( self ):
|
def __repr__( self ):
|
||||||
"More informative string representation"
|
"More informative string representation"
|
||||||
intfs = ( ','.join( [ '%s:%s' % ( i.name, i.IP() )
|
intfs = ( ','.join( [ '%s:%s' % ( i.name, i.IP() )
|
||||||
for i in self.intfList() ] ) )
|
for i in self.intfList() ] ) )
|
||||||
return '<%s %s: %s pid=%s> ' % (
|
return '<%s %s: %s pid=%s> ' % (
|
||||||
self.__class__.__name__, self.name, intfs, self.pid )
|
self.__class__.__name__, self.name, intfs, self.pid )
|
||||||
|
|
||||||
@@ -775,7 +775,7 @@ class Switch( Node ):
|
|||||||
def __repr__( self ):
|
def __repr__( self ):
|
||||||
"More informative string representation"
|
"More informative string representation"
|
||||||
intfs = ( ','.join( [ '%s:%s' % ( i.name, i.IP() )
|
intfs = ( ','.join( [ '%s:%s' % ( i.name, i.IP() )
|
||||||
for i in self.intfList() ] ) )
|
for i in self.intfList() ] ) )
|
||||||
return '<%s %s: %s pid=%s> ' % (
|
return '<%s %s: %s pid=%s> ' % (
|
||||||
self.__class__.__name__, self.name, intfs, self.pid )
|
self.__class__.__name__, self.name, intfs, self.pid )
|
||||||
|
|
||||||
@@ -789,7 +789,8 @@ class UserSwitch( Switch ):
|
|||||||
name: name for the switch"""
|
name: name for the switch"""
|
||||||
Switch.__init__( self, name, **kwargs )
|
Switch.__init__( self, name, **kwargs )
|
||||||
pathCheck( 'ofdatapath', 'ofprotocol',
|
pathCheck( 'ofdatapath', 'ofprotocol',
|
||||||
moduleName='the OpenFlow reference user switch (openflow.org)' )
|
moduleName='the OpenFlow reference user switch' +
|
||||||
|
'(openflow.org)' )
|
||||||
if self.listenPort:
|
if self.listenPort:
|
||||||
self.opts += ' --listen=ptcp:%i ' % self.listenPort
|
self.opts += ' --listen=ptcp:%i ' % self.listenPort
|
||||||
|
|
||||||
@@ -812,18 +813,18 @@ class UserSwitch( Switch ):
|
|||||||
controllers: list of controller objects"""
|
controllers: list of controller objects"""
|
||||||
# Add controllers
|
# Add controllers
|
||||||
clist = ','.join( [ 'tcp:%s:%d' % ( c.IP(), c.port )
|
clist = ','.join( [ 'tcp:%s:%d' % ( c.IP(), c.port )
|
||||||
for c in controllers ] )
|
for c in controllers ] )
|
||||||
ofdlog = '/tmp/' + self.name + '-ofd.log'
|
ofdlog = '/tmp/' + self.name + '-ofd.log'
|
||||||
ofplog = '/tmp/' + self.name + '-ofp.log'
|
ofplog = '/tmp/' + self.name + '-ofp.log'
|
||||||
self.cmd( 'ifconfig lo up' )
|
self.cmd( 'ifconfig lo up' )
|
||||||
intfs = [ str( i ) for i in self.intfList() if not i.IP() ]
|
intfs = [ str( i ) for i in self.intfList() if not i.IP() ]
|
||||||
self.cmd( 'ofdatapath -i ' + ','.join( intfs ) +
|
self.cmd( 'ofdatapath -i ' + ','.join( intfs ) +
|
||||||
' punix:/tmp/' + self.name + ' -d ' + self.dpid +
|
' punix:/tmp/' + self.name + ' -d ' + self.dpid +
|
||||||
' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
|
' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
|
||||||
self.cmd( 'ofprotocol unix:/tmp/' + self.name +
|
self.cmd( 'ofprotocol unix:/tmp/' + self.name +
|
||||||
' ' + clist +
|
' ' + clist +
|
||||||
' --fail=closed ' + self.opts +
|
' --fail=closed ' + self.opts +
|
||||||
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
|
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
|
||||||
|
|
||||||
def stop( self ):
|
def stop( self ):
|
||||||
"Stop OpenFlow reference user datapath."
|
"Stop OpenFlow reference user datapath."
|
||||||
@@ -846,14 +847,14 @@ class OVSLegacyKernelSwitch( Switch ):
|
|||||||
self.intf = self.dp
|
self.intf = self.dp
|
||||||
if self.inNamespace:
|
if self.inNamespace:
|
||||||
error( "OVSKernelSwitch currently only works"
|
error( "OVSKernelSwitch currently only works"
|
||||||
" in the root namespace.\n" )
|
" in the root namespace.\n" )
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup( cls ):
|
def setup( cls ):
|
||||||
"Ensure any dependencies are loaded; if not, try to load them."
|
"Ensure any dependencies are loaded; if not, try to load them."
|
||||||
pathCheck( 'ovs-dpctl', 'ovs-openflowd',
|
pathCheck( 'ovs-dpctl', 'ovs-openflowd',
|
||||||
moduleName='Open vSwitch (openvswitch.org)')
|
moduleName='Open vSwitch (openvswitch.org)')
|
||||||
moduleDeps( subtract=OF_KMOD, add=OVS_KMOD )
|
moduleDeps( subtract=OF_KMOD, add=OVS_KMOD )
|
||||||
|
|
||||||
def start( self, controllers ):
|
def start( self, controllers ):
|
||||||
@@ -868,12 +869,12 @@ class OVSLegacyKernelSwitch( Switch ):
|
|||||||
self.cmd( 'ovs-dpctl', 'add-if', self.dp, ' '.join( intfs ) )
|
self.cmd( 'ovs-dpctl', 'add-if', self.dp, ' '.join( intfs ) )
|
||||||
# Run protocol daemon
|
# Run protocol daemon
|
||||||
clist = ','.join( [ 'tcp:%s:%d' % ( c.IP(), c.port )
|
clist = ','.join( [ 'tcp:%s:%d' % ( c.IP(), c.port )
|
||||||
for c in controllers ] )
|
for c in controllers ] )
|
||||||
self.cmd( 'ovs-openflowd ' + self.dp +
|
self.cmd( 'ovs-openflowd ' + self.dp +
|
||||||
' ' + clist +
|
' ' + clist +
|
||||||
' --fail=secure ' + self.opts +
|
' --fail=secure ' + self.opts +
|
||||||
' --datapath-id=' + self.dpid +
|
' --datapath-id=' + self.dpid +
|
||||||
' 1>' + ofplog + ' 2>' + ofplog + '&' )
|
' 1>' + ofplog + ' 2>' + ofplog + '&' )
|
||||||
self.execed = False
|
self.execed = False
|
||||||
|
|
||||||
def stop( self ):
|
def stop( self ):
|
||||||
@@ -897,7 +898,7 @@ class OVSSwitch( Switch ):
|
|||||||
def setup( cls ):
|
def setup( cls ):
|
||||||
"Make sure Open vSwitch is installed and working"
|
"Make sure Open vSwitch is installed and working"
|
||||||
pathCheck( 'ovs-vsctl',
|
pathCheck( 'ovs-vsctl',
|
||||||
moduleName='Open vSwitch (openvswitch.org)')
|
moduleName='Open vSwitch (openvswitch.org)')
|
||||||
# This should no longer be needed, and it breaks
|
# This should no longer be needed, and it breaks
|
||||||
# with OVS 1.7 which has renamed the kernel module:
|
# with OVS 1.7 which has renamed the kernel module:
|
||||||
# moduleDeps( subtract=OF_KMOD, add=OVS_KMOD )
|
# moduleDeps( subtract=OF_KMOD, add=OVS_KMOD )
|
||||||
@@ -970,15 +971,15 @@ class Controller( Node ):
|
|||||||
OpenFlow controller."""
|
OpenFlow controller."""
|
||||||
|
|
||||||
def __init__( self, name, inNamespace=False, command='controller',
|
def __init__( self, name, inNamespace=False, command='controller',
|
||||||
cargs='-v ptcp:%d', cdir=None, ip="127.0.0.1",
|
cargs='-v ptcp:%d', cdir=None, ip="127.0.0.1",
|
||||||
port=6633, **params ):
|
port=6633, **params ):
|
||||||
self.command = command
|
self.command = command
|
||||||
self.cargs = cargs
|
self.cargs = cargs
|
||||||
self.cdir = cdir
|
self.cdir = cdir
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.port = port
|
self.port = port
|
||||||
Node.__init__( self, name, inNamespace=inNamespace,
|
Node.__init__( self, name, inNamespace=inNamespace,
|
||||||
ip=ip, **params )
|
ip=ip, **params )
|
||||||
self.cmd( 'ifconfig lo up' ) # Shouldn't be necessary
|
self.cmd( 'ifconfig lo up' ) # Shouldn't be necessary
|
||||||
self.checkListening()
|
self.checkListening()
|
||||||
|
|
||||||
@@ -1002,7 +1003,7 @@ class Controller( Node ):
|
|||||||
if self.cdir is not None:
|
if self.cdir is not None:
|
||||||
self.cmd( 'cd ' + self.cdir )
|
self.cmd( 'cd ' + self.cdir )
|
||||||
self.cmd( self.command + ' ' + self.cargs % self.port +
|
self.cmd( self.command + ' ' + self.cargs % self.port +
|
||||||
' 1>' + cout + ' 2>' + cout + '&' )
|
' 1>' + cout + ' 2>' + cout + '&' )
|
||||||
self.execed = False
|
self.execed = False
|
||||||
|
|
||||||
def stop( self ):
|
def stop( self ):
|
||||||
@@ -1050,24 +1051,24 @@ class NOX( Controller ):
|
|||||||
noxCoreDir = os.environ[ 'NOX_CORE_DIR' ]
|
noxCoreDir = os.environ[ 'NOX_CORE_DIR' ]
|
||||||
|
|
||||||
Controller.__init__( self, name,
|
Controller.__init__( self, name,
|
||||||
command=noxCoreDir + '/nox_core',
|
command=noxCoreDir + '/nox_core',
|
||||||
cargs='--libdir=/usr/local/lib -v -i ptcp:%s ' +
|
cargs='--libdir=/usr/local/lib -v -i ptcp:%s ' +
|
||||||
' '.join( noxArgs ),
|
' '.join( noxArgs ),
|
||||||
cdir=noxCoreDir, **kwargs )
|
cdir=noxCoreDir,
|
||||||
|
**kwargs )
|
||||||
|
|
||||||
|
|
||||||
class RemoteController( Controller ):
|
class RemoteController( Controller ):
|
||||||
"Controller running outside of Mininet's control."
|
"Controller running outside of Mininet's control."
|
||||||
|
|
||||||
def __init__( self, name, ip='127.0.0.1',
|
def __init__( self, name, ip='127.0.0.1',
|
||||||
port=6633, **kwargs):
|
port=6633, **kwargs):
|
||||||
"""Init.
|
"""Init.
|
||||||
name: name to give controller
|
name: name to give controller
|
||||||
ip: the IP address where the remote controller is
|
ip: the IP address where the remote controller is
|
||||||
listening
|
listening
|
||||||
port: the port where the remote controller is listening"""
|
port: the port where the remote controller is listening"""
|
||||||
Controller.__init__( self, name, ip=ip, port=port,
|
Controller.__init__( self, name, ip=ip, port=port, **kwargs )
|
||||||
**kwargs )
|
|
||||||
|
|
||||||
def start( self ):
|
def start( self ):
|
||||||
"Overridden to do nothing."
|
"Overridden to do nothing."
|
||||||
|
|||||||
+2
-2
@@ -181,7 +181,7 @@ def moveIntfNoRetry( intf, node, printError=False ):
|
|||||||
if not ( ' %s:' % intf ) in links:
|
if not ( ' %s:' % intf ) in links:
|
||||||
if printError:
|
if printError:
|
||||||
error( '*** Error: moveIntf: ' + intf +
|
error( '*** Error: moveIntf: ' + intf +
|
||||||
' not successfully moved to ' + node.name + '\n' )
|
' not successfully moved to ' + node.name + '\n' )
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -431,7 +431,7 @@ def customConstructor( constructors, argStr ):
|
|||||||
|
|
||||||
if not constructor:
|
if not constructor:
|
||||||
raise Exception( "error: %s is unknown - please specify one of %s" %
|
raise Exception( "error: %s is unknown - please specify one of %s" %
|
||||||
( cname, constructors.keys() ) )
|
( cname, constructors.keys() ) )
|
||||||
|
|
||||||
def customized( name, *args, **params ):
|
def customized( name, *args, **params ):
|
||||||
"Customized constructor, useful for Node, Link, and other classes"
|
"Customized constructor, useful for Node, Link, and other classes"
|
||||||
|
|||||||
Reference in New Issue
Block a user