Pass codecheck.
This commit is contained in:
@@ -77,7 +77,8 @@ class Console( Frame ):
|
|||||||
**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, command=text.yview )
|
ybar = Scrollbar( self, orient='vertical', width=7,
|
||||||
|
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' )
|
||||||
@@ -98,7 +99,7 @@ class Console( Frame ):
|
|||||||
|
|
||||||
# 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]
|
||||||
ignoreChars = re.compile( r'[\x00-\x07\x09\x0b\x0c\x0e-\x1f]+' )
|
ignoreChars = re.compile( r'[\x00-\x07\x09\x0b\x0c\x0e-\x1f]+' )
|
||||||
|
|
||||||
def append( self, text ):
|
def append( self, text ):
|
||||||
"Append something to our text frame."
|
"Append something to our text frame."
|
||||||
@@ -134,7 +135,7 @@ class Console( Frame ):
|
|||||||
"Handle control-c."
|
"Handle control-c."
|
||||||
self.node.sendInt()
|
self.node.sendInt()
|
||||||
# pylint: enable-msg=W0613
|
# pylint: enable-msg=W0613
|
||||||
|
|
||||||
def sendCmd( self, cmd ):
|
def sendCmd( self, cmd ):
|
||||||
"Send a command to our node."
|
"Send a command to our node."
|
||||||
if not self.node.waiting:
|
if not self.node.waiting:
|
||||||
@@ -196,7 +197,7 @@ class Graph( Frame ):
|
|||||||
height = float( self.gheight )
|
height = float( self.gheight )
|
||||||
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
|
||||||
@@ -268,7 +269,7 @@ class Graph( Frame ):
|
|||||||
"Add a bar for testing purposes."
|
"Add a bar for testing purposes."
|
||||||
ms = 1000
|
ms = 1000
|
||||||
if self.xpos < 10:
|
if self.xpos < 10:
|
||||||
self.addBar( self.xpos/10 * self.ymax )
|
self.addBar( self.xpos / 10 * self.ymax )
|
||||||
self.after( ms, self.test )
|
self.after( ms, self.test )
|
||||||
|
|
||||||
def setTitle( self, text ):
|
def setTitle( self, text ):
|
||||||
@@ -279,7 +280,7 @@ class Graph( Frame ):
|
|||||||
class ConsoleApp( Frame ):
|
class ConsoleApp( Frame ):
|
||||||
|
|
||||||
"Simple Tk consoles for Mininet."
|
"Simple Tk consoles for Mininet."
|
||||||
|
|
||||||
menuStyle = { 'font': 'Geneva 7 bold' }
|
menuStyle = { 'font': 'Geneva 7 bold' }
|
||||||
|
|
||||||
def __init__( self, net, parent=None, width=4 ):
|
def __init__( self, net, parent=None, width=4 ):
|
||||||
|
|||||||
+12
-11
@@ -67,7 +67,7 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
# Initialize node data
|
# Initialize node data
|
||||||
self.nodeBindings = self.createNodeBindings()
|
self.nodeBindings = self.createNodeBindings()
|
||||||
self.nodePrefixes = { 'Switch': 's', 'Host': 'h' }
|
self.nodePrefixes = { 'Switch': 's', 'Host': 'h' }
|
||||||
self.widgetToItem = {}
|
self.widgetToItem = {}
|
||||||
self.itemToWidget = {}
|
self.itemToWidget = {}
|
||||||
|
|
||||||
@@ -176,7 +176,8 @@ class MiniEdit( Frame ):
|
|||||||
"Update canvas scroll region to hold everything."
|
"Update canvas scroll region to hold everything."
|
||||||
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 ], bbox[ 3 ] ) )
|
self.canvas.configure( scrollregion=( 0, 0, bbox[ 2 ],
|
||||||
|
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."
|
||||||
@@ -221,7 +222,7 @@ class MiniEdit( Frame ):
|
|||||||
# Commands
|
# Commands
|
||||||
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' )
|
||||||
|
|
||||||
@@ -324,7 +325,7 @@ 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, tags=node )
|
window=icon, tags=node )
|
||||||
self.widgetToItem[ icon ] = item
|
self.widgetToItem[ icon ] = item
|
||||||
self.itemToWidget[ item ] = icon
|
self.itemToWidget[ item ] = icon
|
||||||
@@ -449,21 +450,26 @@ class MiniEdit( Frame ):
|
|||||||
self.linkx, self.linky = x, y
|
self.linkx, self.linky = x, y
|
||||||
self.linkWidget = w
|
self.linkWidget = w
|
||||||
self.linkItem = item
|
self.linkItem = item
|
||||||
|
|
||||||
# Link bindings
|
# Link bindings
|
||||||
# Selection still needs a bit of work overall
|
# Selection still needs a bit of work overall
|
||||||
# Callbacks ignore event
|
# Callbacks ignore event
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
|
|
||||||
def select( event, link=self.link ):
|
def select( event, link=self.link ):
|
||||||
"Select item on mouse entry."
|
"Select item on mouse entry."
|
||||||
self.selectItem( link )
|
self.selectItem( link )
|
||||||
|
|
||||||
def highlight( event, link=self.link ):
|
def highlight( event, link=self.link ):
|
||||||
"Highlight item on mouse entry."
|
"Highlight item on mouse entry."
|
||||||
# self.selectItem( link )
|
# self.selectItem( link )
|
||||||
self.canvas.itemconfig( link, fill='green' )
|
self.canvas.itemconfig( link, fill='green' )
|
||||||
|
|
||||||
def unhighlight( event, link=self.link ):
|
def unhighlight( event, link=self.link ):
|
||||||
"Unhighlight item on mouse exit."
|
"Unhighlight item on mouse exit."
|
||||||
self.canvas.itemconfig( link, fill='blue' )
|
self.canvas.itemconfig( link, fill='blue' )
|
||||||
# self.selectItem( None )
|
# self.selectItem( None )
|
||||||
|
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
self.canvas.tag_bind( self.link, '<Enter>', highlight )
|
self.canvas.tag_bind( self.link, '<Enter>', highlight )
|
||||||
self.canvas.tag_bind( self.link, '<Leave>', unhighlight )
|
self.canvas.tag_bind( self.link, '<Leave>', unhighlight )
|
||||||
@@ -520,7 +526,6 @@ class MiniEdit( Frame ):
|
|||||||
# Show (existing) window
|
# Show (existing) window
|
||||||
about.deiconify()
|
about.deiconify()
|
||||||
|
|
||||||
|
|
||||||
def createToolImages( self ):
|
def createToolImages( self ):
|
||||||
"Create toolbar (and icon) images."
|
"Create toolbar (and icon) images."
|
||||||
|
|
||||||
@@ -575,7 +580,7 @@ class MiniEdit( Frame ):
|
|||||||
# Make links
|
# Make links
|
||||||
for link in self.links.values():
|
for link in self.links.values():
|
||||||
( src, dst ) = link
|
( src, dst ) = link
|
||||||
srcName, dstName = src[ 'text' ], dst[ 'text' ]
|
srcName, dstName = src[ 'text' ], dst[ 'text' ]
|
||||||
src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
|
src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
|
||||||
src.linkTo( dst )
|
src.linkTo( dst )
|
||||||
|
|
||||||
@@ -615,7 +620,7 @@ def miniEditImages():
|
|||||||
# Image data. Git will be unhappy. However, the alternative
|
# Image data. Git will be unhappy. However, the alternative
|
||||||
# is to keep track of separate binary files, which is also
|
# is to keep track of separate binary files, which is also
|
||||||
# unappealing.
|
# unappealing.
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'Select': BitmapImage(
|
'Select': BitmapImage(
|
||||||
file='/usr/include/X11/bitmaps/left_ptr' ),
|
file='/usr/include/X11/bitmaps/left_ptr' ),
|
||||||
@@ -706,7 +711,3 @@ if __name__ == '__main__':
|
|||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
app = MiniEdit()
|
app = MiniEdit()
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,3 @@ if __name__ == '__main__':
|
|||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
network = TreeNet( depth=2, fanout=32, switch=KernelSwitch )
|
network = TreeNet( depth=2, fanout=32, switch=KernelSwitch )
|
||||||
network.run( CLI, network )
|
network.run( CLI, network )
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class UdpBwTest( Frame ):
|
|||||||
switch = self.controls.switch()
|
switch = self.controls.switch()
|
||||||
controller = self.controls.controller()
|
controller = self.controls.controller()
|
||||||
|
|
||||||
self.net = Mininet( self.topo, switch=switch,
|
self.net = Mininet( self.topo, switch=switch,
|
||||||
controller=controller )
|
controller=controller )
|
||||||
self.hosts = self.net.hosts
|
self.hosts = self.net.hosts
|
||||||
self.hostCount = len( self.hosts )
|
self.hostCount = len( self.hosts )
|
||||||
@@ -252,7 +252,8 @@ class UdpBwTest( Frame ):
|
|||||||
seconds, inbw, outbw = parsebwtest( line )
|
seconds, inbw, outbw = parsebwtest( line )
|
||||||
if seconds is None:
|
if seconds is None:
|
||||||
break
|
break
|
||||||
result = self.results.get( seconds, [] ) + [ ( host, inbw, outbw ) ]
|
result = self.results.get( seconds, [] ) + [
|
||||||
|
( host, inbw, outbw ) ]
|
||||||
self.results[ seconds ] = result
|
self.results[ seconds ] = result
|
||||||
if len( result ) == self.hostCount:
|
if len( result ) == self.hostCount:
|
||||||
# Calculate total and update graph
|
# Calculate total and update graph
|
||||||
@@ -260,7 +261,7 @@ class UdpBwTest( Frame ):
|
|||||||
totalin = 0
|
totalin = 0
|
||||||
for host, inbw, outbw in result:
|
for host, inbw, outbw in result:
|
||||||
totalin += inbw
|
totalin += inbw
|
||||||
self.graph.addBar( totalin * 8.0/1000.0 )
|
self.graph.addBar( totalin * 8.0 / 1000.0 )
|
||||||
print totalin
|
print totalin
|
||||||
# Fileevent might be better, but for now we just poll every 500ms
|
# Fileevent might be better, but for now we just poll every 500ms
|
||||||
self.graph.after( 500, self.updateGraph )
|
self.graph.after( 500, self.updateGraph )
|
||||||
@@ -306,5 +307,3 @@ if __name__ == '__main__':
|
|||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
app = UdpBwTest( topo=TreeTopo( depth=2, fanout=2 ) )
|
app = UdpBwTest( topo=TreeTopo( depth=2, fanout=2 ) )
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,4 +52,3 @@ def cleanup():
|
|||||||
sh( "ip link del " + link )
|
sh( "ip link del " + link )
|
||||||
|
|
||||||
info( "*** Cleanup complete.\n" )
|
info( "*** Cleanup complete.\n" )
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ class CLI( Cmd ):
|
|||||||
output( switch.name, '<->' )
|
output( switch.name, '<->' )
|
||||||
for intf in switch.intfs.values():
|
for intf in switch.intfs.values():
|
||||||
# Ugly, but pylint wants it
|
# Ugly, but pylint wants it
|
||||||
name = switch.connection.get( intf,
|
name = switch.connection.get( intf,
|
||||||
( None, 'Unknown ' ) )[ 1 ]
|
( None, 'Unknown ' ) )[ 1 ]
|
||||||
output( ' %s' % name )
|
output( ' %s' % name )
|
||||||
output( '\n' )
|
output( '\n' )
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ class Mininet( object ):
|
|||||||
if topo and build:
|
if topo and build:
|
||||||
self.build()
|
self.build()
|
||||||
|
|
||||||
|
|
||||||
def addHost( self, name, mac=None, ip=None ):
|
def addHost( self, name, mac=None, ip=None ):
|
||||||
"""Add host.
|
"""Add host.
|
||||||
name: name of host to add
|
name: name of host to add
|
||||||
|
|||||||
+6
-6
@@ -437,7 +437,7 @@ class UserSwitch( Switch ):
|
|||||||
if self.inNamespace:
|
if self.inNamespace:
|
||||||
intfs = intfs[ :-1 ]
|
intfs = intfs[ :-1 ]
|
||||||
self.cmd( 'ofdatapath -i ' + ','.join( intfs ) +
|
self.cmd( 'ofdatapath -i ' + ','.join( intfs ) +
|
||||||
' punix:/tmp/' + self.name +
|
' punix:/tmp/' + self.name +
|
||||||
' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
|
' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
|
||||||
self.cmd( 'ofprotocol unix:/tmp/' + self.name +
|
self.cmd( 'ofprotocol unix:/tmp/' + self.name +
|
||||||
' tcp:' + controller.IP() + ' --fail=closed ' + self.opts +
|
' tcp:' + controller.IP() + ' --fail=closed ' + self.opts +
|
||||||
@@ -486,11 +486,11 @@ class KernelSwitch( Switch ):
|
|||||||
raise Exception( 'only contiguous, zero-indexed port ranges'
|
raise Exception( 'only contiguous, zero-indexed port ranges'
|
||||||
'supported: %s' % ports )
|
'supported: %s' % ports )
|
||||||
intfs = [ self.intfs[ port ] for port in ports ]
|
intfs = [ self.intfs[ port ] for port in ports ]
|
||||||
self.cmd( 'dpctl', 'addif', self.dp, ' '.join( intfs ) )
|
self.cmd( 'dpctl', 'addif', self.dp, ' '.join( intfs ) )
|
||||||
# Run protocol daemon
|
# Run protocol daemon
|
||||||
controller = controllers[ 0 ]
|
controller = controllers[ 0 ]
|
||||||
self.cmd( 'ofprotocol ' + self.dp +
|
self.cmd( 'ofprotocol ' + self.dp +
|
||||||
' tcp:%s:%d' % ( controller.IP(), controller.port ) +
|
' tcp:%s:%d' % ( controller.IP(), controller.port ) +
|
||||||
' --fail=closed ' + self.opts +
|
' --fail=closed ' + self.opts +
|
||||||
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
|
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
|
||||||
self.execed = False
|
self.execed = False
|
||||||
@@ -540,11 +540,11 @@ class OVSKernelSwitch( Switch ):
|
|||||||
raise Exception( 'only contiguous, zero-indexed port ranges'
|
raise Exception( 'only contiguous, zero-indexed port ranges'
|
||||||
'supported: %s' % self.intfs )
|
'supported: %s' % self.intfs )
|
||||||
intfs = [ self.intfs[ port ] for port in ports ]
|
intfs = [ self.intfs[ port ] for port in ports ]
|
||||||
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
|
||||||
controller = controllers[ 0 ]
|
controller = controllers[ 0 ]
|
||||||
self.cmd( 'ovs-openflowd ' + self.dp +
|
self.cmd( 'ovs-openflowd ' + self.dp +
|
||||||
' tcp:%s:%i' % ( controller.IP(), controller.port ) +
|
' tcp:%s:%i' % ( controller.IP(), controller.port ) +
|
||||||
' --fail=closed ' + self.opts +
|
' --fail=closed ' + self.opts +
|
||||||
' 1>' + ofplog + ' 2>' + ofplog + '&' )
|
' 1>' + ofplog + ' 2>' + ofplog + '&' )
|
||||||
self.execed = False
|
self.execed = False
|
||||||
@@ -577,7 +577,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.controller + ' ' + self.cargs +
|
self.cmd( self.controller + ' ' + self.cargs +
|
||||||
' 1>' + cout + ' 2>' + cout + '&' )
|
' 1>' + cout + ' 2>' + cout + '&' )
|
||||||
self.execed = False
|
self.execed = False
|
||||||
|
|
||||||
def stop( self ):
|
def stop( self ):
|
||||||
|
|||||||
@@ -58,4 +58,3 @@ def makeTerms( nodes, title='Node', term='xterm' ):
|
|||||||
title: base title for each
|
title: base title for each
|
||||||
returns: list of created terminal processes"""
|
returns: list of created terminal processes"""
|
||||||
return [ makeTerm( node, title, term ) for node in nodes ]
|
return [ makeTerm( node, title, term ) for node in nodes ]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user