print -> info; end the horror of print vs. print()

Although we could use print() from __future__, this messes
up scripts which use examples as modules.

The simple, if not nicest for 2.7, solution is to use
info(), output() and other mininet.log functions. The disadvantage
is that we may have to adjust things if we change info() to
add automatic newlines, but we can burn that bridge in Mininet
3.x.
This commit is contained in:
Bob Lantz
2016-08-23 01:54:54 -07:00
parent 1eb6f65e40
commit ee15ce2243
18 changed files with 128 additions and 132 deletions
+11 -10
View File
@@ -23,7 +23,7 @@ to-do:
from mininet.net import Mininet
from mininet.node import OVSSwitch
from mininet.topo import LinearTopo
from mininet.log import output, warn
from mininet.log import info, output, warn, setLogLevel
from random import randint
@@ -106,30 +106,31 @@ def moveHost( host, oldSwitch, newSwitch, newPort=None ):
def mobilityTest():
"A simple test of mobility"
print( '* Simple mobility test' )
info( '* Simple mobility test\n' )
net = Mininet( topo=LinearTopo( 3 ), switch=MobilitySwitch )
print( '* Starting network:' )
info( '* Starting network:\n' )
net.start()
printConnections( net.switches )
print( '* Testing network' )
info( '* Testing network\n' )
net.pingAll()
print( '* Identifying switch interface for h1' )
info( '* Identifying switch interface for h1\n' )
h1, old = net.get( 'h1', 's1' )
for s in 2, 3, 1:
new = net[ 's%d' % s ]
port = randint( 10, 20 )
print( '* Moving', h1, 'from', old, 'to', new, 'port', port )
info( '* Moving', h1, 'from', old, 'to', new, 'port', port, '\n' )
hintf, sintf = moveHost( h1, old, new, newPort=port )
print( '*', hintf, 'is now connected to', sintf )
print( '* Clearing out old flows' )
info( '*', hintf, 'is now connected to', sintf, '\n' )
info( '* Clearing out old flows\n' )
for sw in net.switches:
sw.dpctl( 'del-flows' )
print( '* New network:' )
info( '* New network:\n' )
printConnections( net.switches )
print( '* Testing connectivity:' )
info( '* Testing connectivity:\n' )
net.pingAll()
old = new
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
mobilityTest()