@@ -11,6 +11,7 @@ Example to pull custom params (topo, switch, etc.) from a file:
|
||||
sudo mn --custom ~/mininet/custom/custom_example.py
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
from optparse import OptionParser
|
||||
import os
|
||||
import sys
|
||||
@@ -117,7 +118,7 @@ def addDictOption( opts, choicesDict, default, name, **kwargs ):
|
||||
|
||||
def version( *_args ):
|
||||
"Print Mininet version and exit"
|
||||
print "%s" % VERSION
|
||||
print( "%s" % VERSION )
|
||||
exit()
|
||||
|
||||
|
||||
@@ -269,7 +270,7 @@ class MininetRunner( object ):
|
||||
|
||||
# set logging verbosity
|
||||
if LEVELS[self.options.verbosity] > LEVELS['output']:
|
||||
print ( '*** WARNING: selected verbosity level (%s) will hide CLI '
|
||||
print( '*** WARNING: selected verbosity level (%s) will hide CLI '
|
||||
'output!\n'
|
||||
'Please restart Mininet with -v [debug, info, output].'
|
||||
% self.options.verbosity )
|
||||
@@ -331,7 +332,7 @@ class MininetRunner( object ):
|
||||
inNamespace = self.options.innamespace
|
||||
cluster = self.options.cluster
|
||||
if inNamespace and cluster:
|
||||
print "Please specify --innamespace OR --cluster"
|
||||
print( "Please specify --innamespace OR --cluster" )
|
||||
exit()
|
||||
Net = MininetWithControlNet if inNamespace else Mininet
|
||||
cli = ClusterCLI if cluster else CLI
|
||||
|
||||
+11
-8
@@ -2,33 +2,36 @@
|
||||
|
||||
"This example doesn't use OpenFlow, but attempts to run sshd in a namespace."
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
from mininet.node import Host
|
||||
from mininet.util import ensureRoot, waitListening
|
||||
|
||||
|
||||
ensureRoot()
|
||||
timeout = 5
|
||||
|
||||
print "*** Creating nodes"
|
||||
print( "*** Creating nodes" )
|
||||
h1 = Host( 'h1' )
|
||||
|
||||
root = Host( 'root', inNamespace=False )
|
||||
|
||||
print "*** Creating links"
|
||||
print( "*** Creating links" )
|
||||
h1.linkTo( root )
|
||||
|
||||
print h1
|
||||
print( h1 )
|
||||
|
||||
print "*** Configuring nodes"
|
||||
print( "*** Configuring nodes" )
|
||||
h1.setIP( '10.0.0.1', 8 )
|
||||
root.setIP( '10.0.0.2', 8 )
|
||||
|
||||
print "*** Creating banner file"
|
||||
print( "*** Creating banner file" )
|
||||
f = open( '/tmp/%s.banner' % h1.name, 'w' )
|
||||
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
|
||||
f.close()
|
||||
|
||||
print "*** Running sshd"
|
||||
print( "*** Running sshd" )
|
||||
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
|
||||
# add arguments from the command line
|
||||
if len( sys.argv ) > 1:
|
||||
@@ -37,7 +40,7 @@ h1.cmd( cmd )
|
||||
listening = waitListening( server=h1, port=22, timeout=timeout )
|
||||
|
||||
if listening:
|
||||
print "*** You may now ssh into", h1.name, "at", h1.IP()
|
||||
print( "*** You may now ssh into", h1.name, "at", h1.IP() )
|
||||
else:
|
||||
print ( "*** Warning: after %s seconds, %s is not listening on port 22"
|
||||
print( "*** Warning: after %s seconds, %s is not listening on port 22"
|
||||
% ( timeout, h1.name ) )
|
||||
|
||||
+13
-11
@@ -74,6 +74,8 @@ Things to do:
|
||||
- hifi support (e.g. delay compensation)
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.node import Node, Host, OVSSwitch, Controller
|
||||
from mininet.link import Link, Intf
|
||||
from mininet.net import Mininet
|
||||
@@ -238,7 +240,7 @@ class RemoteMixin( object ):
|
||||
args: string or list of strings
|
||||
returns: stdout and stderr"""
|
||||
popen = self.rpopen( *cmd, **opts )
|
||||
# print 'RCMD: POPEN:', popen
|
||||
# print( 'RCMD: POPEN:', popen )
|
||||
# These loops are tricky to get right.
|
||||
# Once the process exits, we can read
|
||||
# EOF twice if necessary.
|
||||
@@ -792,28 +794,28 @@ def testNsTunnels():
|
||||
|
||||
def testRemoteNet( remote='ubuntu2' ):
|
||||
"Test remote Node classes"
|
||||
print '*** Remote Node Test'
|
||||
print( '*** Remote Node Test' )
|
||||
net = Mininet( host=RemoteHost, switch=RemoteOVSSwitch,
|
||||
link=RemoteLink )
|
||||
c0 = net.addController( 'c0' )
|
||||
# Make sure controller knows its non-loopback address
|
||||
Intf( 'eth0', node=c0 ).updateIP()
|
||||
print "*** Creating local h1"
|
||||
print( "*** Creating local h1" )
|
||||
h1 = net.addHost( 'h1' )
|
||||
print "*** Creating remote h2"
|
||||
print( "*** Creating remote h2" )
|
||||
h2 = net.addHost( 'h2', server=remote )
|
||||
print "*** Creating local s1"
|
||||
print( "*** Creating local s1" )
|
||||
s1 = net.addSwitch( 's1' )
|
||||
print "*** Creating remote s2"
|
||||
print( "*** Creating remote s2" )
|
||||
s2 = net.addSwitch( 's2', server=remote )
|
||||
print "*** Adding links"
|
||||
print( "*** Adding links" )
|
||||
net.addLink( h1, s1 )
|
||||
net.addLink( s1, s2 )
|
||||
net.addLink( h2, s2 )
|
||||
net.start()
|
||||
print 'Mininet is running on', quietRun( 'hostname' ).strip()
|
||||
print( 'Mininet is running on', quietRun( 'hostname' ).strip() )
|
||||
for node in c0, h1, h2, s1, s2:
|
||||
print 'Node', node, 'is running on', node.cmd( 'hostname' ).strip()
|
||||
print( 'Node', node, 'is running on', node.cmd( 'hostname' ).strip() )
|
||||
net.pingAll()
|
||||
CLI( net )
|
||||
net.stop()
|
||||
@@ -900,9 +902,9 @@ def signalTest():
|
||||
h.shell.send_signal( SIGINT )
|
||||
h.shell.poll()
|
||||
if h.shell.returncode is None:
|
||||
print 'OK: ', h, 'has not exited'
|
||||
print( 'OK: ', h, 'has not exited' )
|
||||
else:
|
||||
print 'FAILURE:', h, 'exited with code', h.shell.returncode
|
||||
print( 'FAILURE:', h, 'exited with code', h.shell.returncode )
|
||||
h.stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+12
-10
@@ -11,6 +11,8 @@ Note that one could also create a custom switch class and pass it into
|
||||
the Mininet() constructor.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Controller, OVSSwitch
|
||||
from mininet.cli import CLI
|
||||
@@ -21,39 +23,39 @@ def multiControllerNet():
|
||||
|
||||
net = Mininet( controller=Controller, switch=OVSSwitch )
|
||||
|
||||
print "*** Creating (reference) controllers"
|
||||
print( "*** Creating (reference) controllers" )
|
||||
c1 = net.addController( 'c1', port=6633 )
|
||||
c2 = net.addController( 'c2', port=6634 )
|
||||
|
||||
print "*** Creating switches"
|
||||
print( "*** Creating switches" )
|
||||
s1 = net.addSwitch( 's1' )
|
||||
s2 = net.addSwitch( 's2' )
|
||||
|
||||
print "*** Creating hosts"
|
||||
hosts1 = [ net.addHost( 'h%d' % n ) for n in 3, 4 ]
|
||||
hosts2 = [ net.addHost( 'h%d' % n ) for n in 5, 6 ]
|
||||
print( "*** Creating hosts" )
|
||||
hosts1 = [ net.addHost( 'h%d' % n ) for n in ( 3, 4 ) ]
|
||||
hosts2 = [ net.addHost( 'h%d' % n ) for n in ( 5, 6 ) ]
|
||||
|
||||
print "*** Creating links"
|
||||
print( "*** Creating links" )
|
||||
for h in hosts1:
|
||||
net.addLink( s1, h )
|
||||
for h in hosts2:
|
||||
net.addLink( s2, h )
|
||||
net.addLink( s1, s2 )
|
||||
|
||||
print "*** Starting network"
|
||||
print( "*** Starting network" )
|
||||
net.build()
|
||||
c1.start()
|
||||
c2.start()
|
||||
s1.start( [ c1 ] )
|
||||
s2.start( [ c2 ] )
|
||||
|
||||
print "*** Testing network"
|
||||
print( "*** Testing network" )
|
||||
net.pingAll()
|
||||
|
||||
print "*** Running CLI"
|
||||
print( "*** Running CLI" )
|
||||
CLI( net )
|
||||
|
||||
print "*** Stopping network"
|
||||
print( "*** Stopping network" )
|
||||
net.stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+7
-5
@@ -4,6 +4,8 @@
|
||||
cpu.py: test iperf bandwidth for varying cpu limits
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import CPULimitedHost
|
||||
from mininet.topolib import TreeTopo
|
||||
@@ -20,7 +22,7 @@ def bwtest( cpuLimits, period_us=100000, seconds=5 ):
|
||||
results = {}
|
||||
|
||||
for sched in 'rt', 'cfs':
|
||||
print '*** Testing with', sched, 'bandwidth limiting'
|
||||
print( '*** Testing with', sched, 'bandwidth limiting' )
|
||||
for cpu in cpuLimits:
|
||||
host = custom( CPULimitedHost, sched=sched,
|
||||
period_us=period_us,
|
||||
@@ -54,16 +56,16 @@ def dump( results ):
|
||||
|
||||
fmt = '%s\t%s\t%s'
|
||||
|
||||
print
|
||||
print fmt % ( 'sched', 'cpu', 'client MB/s' )
|
||||
print
|
||||
print()
|
||||
print( fmt % ( 'sched', 'cpu', 'client MB/s' ) )
|
||||
print()
|
||||
|
||||
for sched in sorted( results.keys() ):
|
||||
entries = results[ sched ]
|
||||
for cpu, bps in entries:
|
||||
pct = '%.2f%%' % ( cpu * 100 )
|
||||
mbps = bps / 1e6
|
||||
print fmt % ( sched, pct, mbps )
|
||||
print( fmt % ( sched, pct, mbps ) )
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+16
-14
@@ -23,6 +23,8 @@ of switches, this example demonstrates:
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import UserSwitch, OVSKernelSwitch, Controller
|
||||
from mininet.topo import Topo
|
||||
@@ -83,7 +85,7 @@ def linearBandwidthTest( lengths ):
|
||||
assert 'reno' in output
|
||||
|
||||
for datapath in switches.keys():
|
||||
print "*** testing", datapath, "datapath"
|
||||
print( "*** testing", datapath, "datapath" )
|
||||
Switch = switches[ datapath ]
|
||||
results[ datapath ] = []
|
||||
link = partial( TCLink, delay='1ms' )
|
||||
@@ -91,36 +93,36 @@ def linearBandwidthTest( lengths ):
|
||||
controller=Controller, waitConnected=True,
|
||||
link=link )
|
||||
net.start()
|
||||
print "*** testing basic connectivity"
|
||||
print( "*** testing basic connectivity" )
|
||||
for n in lengths:
|
||||
net.ping( [ net.hosts[ 0 ], net.hosts[ n ] ] )
|
||||
print "*** testing bandwidth"
|
||||
print( "*** testing bandwidth" )
|
||||
for n in lengths:
|
||||
src, dst = net.hosts[ 0 ], net.hosts[ n ]
|
||||
# Try to prime the pump to reduce PACKET_INs during test
|
||||
# since the reference controller is reactive
|
||||
src.cmd( 'telnet', dst.IP(), '5001' )
|
||||
print "testing", src.name, "<->", dst.name,
|
||||
print( "testing", src.name, "<->", dst.name )
|
||||
bandwidth = net.iperf( [ src, dst ], seconds=10 )
|
||||
print bandwidth
|
||||
print( bandwidth )
|
||||
flush()
|
||||
results[ datapath ] += [ ( n, bandwidth ) ]
|
||||
net.stop()
|
||||
|
||||
for datapath in switches.keys():
|
||||
print
|
||||
print "*** Linear network results for", datapath, "datapath:"
|
||||
print
|
||||
print()
|
||||
print( "*** Linear network results for", datapath, "datapath:" )
|
||||
print()
|
||||
result = results[ datapath ]
|
||||
print "SwitchCount\tiperf Results"
|
||||
print( "SwitchCount\tiperf Results" )
|
||||
for switchCount, bandwidth in result:
|
||||
print switchCount, '\t\t',
|
||||
print bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client'
|
||||
print
|
||||
print
|
||||
print( switchCount, '\t\t' )
|
||||
print( bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client' )
|
||||
print()
|
||||
print()
|
||||
|
||||
if __name__ == '__main__':
|
||||
lg.setLogLevel( 'info' )
|
||||
sizes = [ 1, 10, 20, 40, 60, 80 ]
|
||||
print "*** Running linearBandwidthTest", sizes
|
||||
print( "*** Running linearBandwidthTest", sizes )
|
||||
linearBandwidthTest( sizes )
|
||||
|
||||
@@ -27,12 +27,15 @@ Additional routes may be added to the router or hosts by
|
||||
executing 'ip route' or 'route' commands on the router or hosts.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.topo import Topo
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Node
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.cli import CLI
|
||||
|
||||
|
||||
class LinuxRouter( Node ):
|
||||
"A Node with IP forwarding enabled."
|
||||
|
||||
@@ -54,7 +57,7 @@ class NetworkTopo( Topo ):
|
||||
defaultIP = '192.168.1.1/24' # IP address for r0-eth1
|
||||
router = self.addNode( 'r0', cls=LinuxRouter, ip=defaultIP )
|
||||
|
||||
s1, s2, s3 = [ self.addSwitch( s ) for s in 's1', 's2', 's3' ]
|
||||
s1, s2, s3 = [ self.addSwitch( s ) for s in ( 's1', 's2', 's3' ) ]
|
||||
|
||||
self.addLink( s1, router, intfName2='r0-eth1',
|
||||
params2={ 'ip' : defaultIP } ) # for clarity
|
||||
@@ -80,7 +83,7 @@ def run():
|
||||
net = Mininet( topo=topo ) # controller is used by s1-s3
|
||||
net.start()
|
||||
info( '*** Routing Table on Router:\n' )
|
||||
print net[ 'r0' ].cmd( 'route' )
|
||||
print( net[ 'r0' ].cmd( 'route' ) )
|
||||
CLI( net )
|
||||
net.stop()
|
||||
|
||||
|
||||
+41
-40
@@ -20,6 +20,7 @@ OpenFlow icon from https://www.opennetworking.org/
|
||||
|
||||
MINIEDIT_VERSION = '2.2.0.1'
|
||||
|
||||
from __future__ import print_function
|
||||
from optparse import OptionParser
|
||||
# from Tkinter import *
|
||||
from Tkinter import ( Frame, Label, LabelFrame, Entry, OptionMenu, Checkbutton,
|
||||
@@ -60,7 +61,7 @@ from mininet.moduledeps import moduleDeps
|
||||
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
|
||||
from mininet.topolib import TreeTopo
|
||||
|
||||
print 'MiniEdit running against Mininet '+VERSION
|
||||
print( 'MiniEdit running against Mininet '+VERSION )
|
||||
MININET_VERSION = re.sub(r'[^\d\.]', '', VERSION)
|
||||
if StrictVersion(MININET_VERSION) > StrictVersion('2.0'):
|
||||
from mininet.node import IVSSwitch
|
||||
@@ -383,10 +384,10 @@ class PrefsDialog(tkSimpleDialog.Dialog):
|
||||
r = r'ovs_version: "(.*)"'
|
||||
m = re.search(r, outp)
|
||||
if m is None:
|
||||
print 'Version check failed'
|
||||
print( 'Version check failed' )
|
||||
return None
|
||||
else:
|
||||
print 'Open vSwitch version is '+m.group(1)
|
||||
print( 'Open vSwitch version is '+m.group(1) )
|
||||
return m.group(1)
|
||||
|
||||
|
||||
@@ -755,7 +756,7 @@ class SwitchDialog(CustomDialog):
|
||||
def apply(self):
|
||||
externalInterfaces = []
|
||||
for row in range(self.tableFrame.rows):
|
||||
#print 'Interface is ' + self.tableFrame.get(row, 0)
|
||||
# print( 'Interface is ' + self.tableFrame.get(row, 0) )
|
||||
if len(self.tableFrame.get(row, 0)) > 0:
|
||||
externalInterfaces.append(self.tableFrame.get(row, 0))
|
||||
|
||||
@@ -866,7 +867,7 @@ class TableFrame(Frame):
|
||||
return widget.get()
|
||||
|
||||
def addRow( self, value=None, readonly=False ):
|
||||
#print "Adding row " + str(self.rows +1)
|
||||
# print( "Adding row " + str(self.rows +1) )
|
||||
current_row = []
|
||||
for column in range(self.columns):
|
||||
label = Entry(self, borderwidth=0)
|
||||
@@ -1669,7 +1670,7 @@ class MiniEdit( Frame ):
|
||||
f.write(json.dumps(savingDictionary, sort_keys=True, indent=4, separators=(',', ': ')))
|
||||
# pylint: disable=broad-except
|
||||
except Exception as er:
|
||||
print er
|
||||
print( er )
|
||||
# pylint: enable=broad-except
|
||||
finally:
|
||||
f.close()
|
||||
@@ -1683,7 +1684,7 @@ class MiniEdit( Frame ):
|
||||
|
||||
fileName = tkFileDialog.asksaveasfilename(filetypes=myFormats ,title="Export the topology as...")
|
||||
if len(fileName ) > 0:
|
||||
#print "Now saving under %s" % fileName
|
||||
# print( "Now saving under %s" % fileName )
|
||||
f = open(fileName, 'wb')
|
||||
|
||||
f.write("#!/usr/bin/python\n")
|
||||
@@ -2489,7 +2490,7 @@ class MiniEdit( Frame ):
|
||||
if len(hostBox.result['privateDirectory']) > 0:
|
||||
newHostOpts['privateDirectory'] = hostBox.result['privateDirectory']
|
||||
self.hostOpts[name] = newHostOpts
|
||||
print 'New host details for ' + name + ' = ' + str(newHostOpts)
|
||||
print( 'New host details for ' + name + ' = ' + str(newHostOpts) )
|
||||
|
||||
def switchDetails( self, _ignore=None ):
|
||||
if ( self.selection is None or
|
||||
@@ -2527,7 +2528,7 @@ class MiniEdit( Frame ):
|
||||
newSwitchOpts['sflow'] = switchBox.result['sflow']
|
||||
newSwitchOpts['netflow'] = switchBox.result['netflow']
|
||||
self.switchOpts[name] = newSwitchOpts
|
||||
print 'New switch details for ' + name + ' = ' + str(newSwitchOpts)
|
||||
print( 'New switch details for ' + name + ' = ' + str(newSwitchOpts) )
|
||||
|
||||
def linkUp( self ):
|
||||
if ( self.selection is None or
|
||||
@@ -2566,12 +2567,12 @@ class MiniEdit( Frame ):
|
||||
linkBox = LinkDialog(self, title='Link Details', linkDefaults=linkopts)
|
||||
if linkBox.result is not None:
|
||||
linkDetail['linkOpts'] = linkBox.result
|
||||
print 'New link details = ' + str(linkBox.result)
|
||||
print( 'New link details = ' + str(linkBox.result) )
|
||||
|
||||
def prefDetails( self ):
|
||||
prefDefaults = self.appPrefs
|
||||
prefBox = PrefsDialog(self, title='Preferences', prefDefaults=prefDefaults)
|
||||
print 'New Prefs = ' + str(prefBox.result)
|
||||
print( 'New Prefs = ' + str(prefBox.result) )
|
||||
if prefBox.result:
|
||||
self.appPrefs = prefBox.result
|
||||
|
||||
@@ -2590,14 +2591,14 @@ class MiniEdit( Frame ):
|
||||
|
||||
ctrlrBox = ControllerDialog(self, title='Controller Details', ctrlrDefaults=self.controllers[name])
|
||||
if ctrlrBox.result:
|
||||
#print 'Controller is ' + ctrlrBox.result[0]
|
||||
# print( 'Controller is ' + ctrlrBox.result[0] )
|
||||
if len(ctrlrBox.result['hostname']) > 0:
|
||||
name = ctrlrBox.result['hostname']
|
||||
widget[ 'text' ] = name
|
||||
else:
|
||||
ctrlrBox.result['hostname'] = name
|
||||
self.controllers[name] = ctrlrBox.result
|
||||
print 'New controller details for ' + name + ' = ' + str(self.controllers[name])
|
||||
print( 'New controller details for ' + name + ' = ' + str(self.controllers[name]) )
|
||||
# Find references to controller and change name
|
||||
if oldName != name:
|
||||
for widget in self.widgetToItem:
|
||||
@@ -2698,15 +2699,15 @@ class MiniEdit( Frame ):
|
||||
|
||||
def buildNodes( self, net):
|
||||
# Make nodes
|
||||
print "Getting Hosts and Switches."
|
||||
print( "Getting Hosts and Switches." )
|
||||
for widget in self.widgetToItem:
|
||||
name = widget[ 'text' ]
|
||||
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
|
||||
#print name+' has '+str(tags)
|
||||
# print( name+' has '+str(tags) )
|
||||
|
||||
if 'Switch' in tags:
|
||||
opts = self.switchOpts[name]
|
||||
#print str(opts)
|
||||
# print( str(opts) )
|
||||
|
||||
# Create the correct switch class
|
||||
switchClass = customOvs
|
||||
@@ -2772,7 +2773,7 @@ class MiniEdit( Frame ):
|
||||
newSwitch = net.addHost( name , cls=LegacyRouter)
|
||||
elif 'Host' in tags:
|
||||
opts = self.hostOpts[name]
|
||||
#print str(opts)
|
||||
# print( str(opts) )
|
||||
ip = None
|
||||
defaultRoute = None
|
||||
if 'defaultRoute' in opts and len(opts['defaultRoute']) > 0:
|
||||
@@ -2797,7 +2798,7 @@ class MiniEdit( Frame ):
|
||||
privateDirs=opts['privateDirectory'] )
|
||||
else:
|
||||
hostCls=Host
|
||||
print hostCls
|
||||
print( hostCls )
|
||||
newHost = net.addHost( name,
|
||||
cls=hostCls,
|
||||
ip=ip,
|
||||
@@ -2817,7 +2818,7 @@ class MiniEdit( Frame ):
|
||||
Intf( extInterface, node=newHost )
|
||||
if 'vlanInterfaces' in opts:
|
||||
if len(opts['vlanInterfaces']) > 0:
|
||||
print 'Checking that OS is VLAN prepared'
|
||||
print( 'Checking that OS is VLAN prepared' )
|
||||
self.pathCheck('vconfig', moduleName='vlan package')
|
||||
moduleDeps( add='8021q' )
|
||||
elif 'Controller' in tags:
|
||||
@@ -2834,7 +2835,7 @@ class MiniEdit( Frame ):
|
||||
controllerPort = opts['remotePort']
|
||||
|
||||
# Make controller
|
||||
print 'Getting controller selection:'+controllerType
|
||||
print( 'Getting controller selection:'+controllerType )
|
||||
if controllerType == 'remote':
|
||||
net.addController(name=name,
|
||||
controller=RemoteController,
|
||||
@@ -2874,7 +2875,7 @@ class MiniEdit( Frame ):
|
||||
|
||||
def buildLinks( self, net):
|
||||
# Make links
|
||||
print "Getting Links."
|
||||
print( "Getting Links." )
|
||||
for key,link in self.links.iteritems():
|
||||
tags = self.canvas.gettags(key)
|
||||
if 'data' in tags:
|
||||
@@ -2886,14 +2887,14 @@ class MiniEdit( Frame ):
|
||||
if linkopts:
|
||||
net.addLink(srcNode, dstNode, cls=TCLink, **linkopts)
|
||||
else:
|
||||
#print str(srcNode)
|
||||
#print str(dstNode)
|
||||
# print( str(srcNode) )
|
||||
# print( str(dstNode) )
|
||||
net.addLink(srcNode, dstNode)
|
||||
self.canvas.itemconfig(key, dash=())
|
||||
|
||||
|
||||
def build( self ):
|
||||
print "Build network based on our topology."
|
||||
print( "Build network based on our topology." )
|
||||
|
||||
dpctl = None
|
||||
if len(self.appPrefs['dpctl']) > 0:
|
||||
@@ -2924,7 +2925,7 @@ class MiniEdit( Frame ):
|
||||
# Attach vlan interfaces
|
||||
if 'vlanInterfaces' in opts:
|
||||
for vlanInterface in opts['vlanInterfaces']:
|
||||
print 'adding vlan interface '+vlanInterface[1]
|
||||
print( 'adding vlan interface '+vlanInterface[1] )
|
||||
newHost.cmdPrint('ifconfig '+name+'-eth0.'+vlanInterface[1]+' '+vlanInterface[0])
|
||||
# Run User Defined Start Command
|
||||
if 'startCommand' in opts:
|
||||
@@ -2950,7 +2951,7 @@ class MiniEdit( Frame ):
|
||||
opts = self.switchOpts[name]
|
||||
if 'netflow' in opts:
|
||||
if opts['netflow'] == '1':
|
||||
print name+' has Netflow enabled'
|
||||
print( name+' has Netflow enabled' )
|
||||
nflowSwitches = nflowSwitches+' -- set Bridge '+name+' netflow=@MiniEditNF'
|
||||
nflowEnabled=True
|
||||
if nflowEnabled:
|
||||
@@ -2959,13 +2960,13 @@ class MiniEdit( Frame ):
|
||||
nflowCmd = nflowCmd + ' add_id_to_interface=true'
|
||||
else:
|
||||
nflowCmd = nflowCmd + ' add_id_to_interface=false'
|
||||
print 'cmd = '+nflowCmd+nflowSwitches
|
||||
print( 'cmd = '+nflowCmd+nflowSwitches )
|
||||
call(nflowCmd+nflowSwitches, shell=True)
|
||||
|
||||
else:
|
||||
print 'No switches with Netflow'
|
||||
print( 'No switches with Netflow' )
|
||||
else:
|
||||
print 'No NetFlow targets specified.'
|
||||
print( 'No NetFlow targets specified.' )
|
||||
|
||||
# Configure sFlow
|
||||
sflowValues = self.appPrefs['sflow']
|
||||
@@ -2980,18 +2981,18 @@ class MiniEdit( Frame ):
|
||||
opts = self.switchOpts[name]
|
||||
if 'sflow' in opts:
|
||||
if opts['sflow'] == '1':
|
||||
print name+' has sflow enabled'
|
||||
print( name+' has sflow enabled' )
|
||||
sflowSwitches = sflowSwitches+' -- set Bridge '+name+' sflow=@MiniEditSF'
|
||||
sflowEnabled=True
|
||||
if sflowEnabled:
|
||||
sflowCmd = 'ovs-vsctl -- --id=@MiniEditSF create sFlow '+ 'target=\\\"'+sflowValues['sflowTarget']+'\\\" '+ 'header='+sflowValues['sflowHeader']+' '+ 'sampling='+sflowValues['sflowSampling']+' '+ 'polling='+sflowValues['sflowPolling']
|
||||
print 'cmd = '+sflowCmd+sflowSwitches
|
||||
print( 'cmd = '+sflowCmd+sflowSwitches )
|
||||
call(sflowCmd+sflowSwitches, shell=True)
|
||||
|
||||
else:
|
||||
print 'No switches with sflow'
|
||||
print( 'No switches with sflow' )
|
||||
else:
|
||||
print 'No sFlow targets specified.'
|
||||
print( 'No sFlow targets specified.' )
|
||||
|
||||
## NOTE: MAKE SURE THIS IS LAST THING CALLED
|
||||
# Start the CLI if enabled
|
||||
@@ -3217,7 +3218,7 @@ class MiniEdit( Frame ):
|
||||
raise Exception( 'could not find custom file: %s' % fileName )
|
||||
|
||||
def importTopo( self ):
|
||||
print 'topo='+self.options.topo
|
||||
print( 'topo='+self.options.topo )
|
||||
if self.options.topo == 'none':
|
||||
return
|
||||
self.newTopology()
|
||||
@@ -3231,7 +3232,7 @@ class MiniEdit( Frame ):
|
||||
currentY = 100
|
||||
|
||||
# Add Controllers
|
||||
print 'controllers:'+str(len(importNet.controllers))
|
||||
print( 'controllers:'+str(len(importNet.controllers)) )
|
||||
for controller in importNet.controllers:
|
||||
name = controller.name
|
||||
x = self.controllerCount*100+100
|
||||
@@ -3251,7 +3252,7 @@ class MiniEdit( Frame ):
|
||||
currentY = currentY + rowIncrement
|
||||
|
||||
# Add switches
|
||||
print 'switches:'+str(len(importNet.switches))
|
||||
print( 'switches:'+str(len(importNet.switches)) )
|
||||
columnCount = 0
|
||||
for switch in importNet.switches:
|
||||
name = switch.name
|
||||
@@ -3292,7 +3293,7 @@ class MiniEdit( Frame ):
|
||||
|
||||
currentY = currentY + rowIncrement
|
||||
# Add hosts
|
||||
print 'hosts:'+str(len(importNet.hosts))
|
||||
print( 'hosts:'+str(len(importNet.hosts)) )
|
||||
columnCount = 0
|
||||
for host in importNet.hosts:
|
||||
name = host.name
|
||||
@@ -3312,10 +3313,10 @@ class MiniEdit( Frame ):
|
||||
else:
|
||||
columnCount =columnCount+1
|
||||
|
||||
print 'links:'+str(len(topo.links()))
|
||||
print( 'links:'+str(len(topo.links())) )
|
||||
#[('h1', 's3'), ('h2', 's4'), ('s3', 's4')]
|
||||
for link in topo.links():
|
||||
print str(link)
|
||||
print( str(link) )
|
||||
srcNode = link[0]
|
||||
src = self.findWidgetByName(srcNode)
|
||||
sx, sy = self.canvas.coords( self.widgetToItem[ src ] )
|
||||
@@ -3325,7 +3326,7 @@ class MiniEdit( Frame ):
|
||||
dx, dy = self.canvas.coords( self.widgetToItem[ dest] )
|
||||
|
||||
params = topo.linkInfo( srcNode, destNode )
|
||||
print 'Link Parameters='+str(params)
|
||||
print( 'Link Parameters='+str(params) )
|
||||
|
||||
self.link = self.canvas.create_line( sx, sy, dx, dy, width=4,
|
||||
fill='blue', tag='link' )
|
||||
|
||||
+11
-9
@@ -19,6 +19,8 @@ to-do:
|
||||
- think about clearing last hop - why doesn't that work?
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import OVSSwitch
|
||||
from mininet.topo import LinearTopo
|
||||
@@ -105,27 +107,27 @@ def moveHost( host, oldSwitch, newSwitch, newPort=None ):
|
||||
|
||||
def mobilityTest():
|
||||
"A simple test of mobility"
|
||||
print '* Simple mobility test'
|
||||
print( '* Simple mobility test' )
|
||||
net = Mininet( topo=LinearTopo( 3 ), switch=MobilitySwitch )
|
||||
print '* Starting network:'
|
||||
print( '* Starting network:' )
|
||||
net.start()
|
||||
printConnections( net.switches )
|
||||
print '* Testing network'
|
||||
print( '* Testing network' )
|
||||
net.pingAll()
|
||||
print '* Identifying switch interface for h1'
|
||||
print( '* Identifying switch interface for h1' )
|
||||
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
|
||||
print( '* Moving', h1, 'from', old, 'to', new, 'port', port )
|
||||
hintf, sintf = moveHost( h1, old, new, newPort=port )
|
||||
print '*', hintf, 'is now connected to', sintf
|
||||
print '* Clearing out old flows'
|
||||
print( '*', hintf, 'is now connected to', sintf )
|
||||
print( '* Clearing out old flows' )
|
||||
for sw in net.switches:
|
||||
sw.dpctl( 'del-flows' )
|
||||
print '* New network:'
|
||||
print( '* New network:' )
|
||||
printConnections( net.switches )
|
||||
print '* Testing connectivity:'
|
||||
print( '* Testing connectivity:' )
|
||||
net.pingAll()
|
||||
old = new
|
||||
net.stop()
|
||||
|
||||
@@ -8,6 +8,8 @@ multiple hosts and monitor their output interactively for a period=
|
||||
of time.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Node
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
@@ -34,7 +36,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.cmd( cmd )
|
||||
@@ -69,7 +71,7 @@ def multiping( netsize, chunksize, seconds):
|
||||
readable = poller.poll(1000)
|
||||
for fd, _mask in readable:
|
||||
node = Node.outToNode[ fd ]
|
||||
print '%s:' % node.name, node.monitor().strip()
|
||||
print( '%s:' % node.name, node.monitor().strip() )
|
||||
|
||||
# Stop pings
|
||||
for host in hosts:
|
||||
|
||||
@@ -5,6 +5,8 @@ Simple example of sending output to multiple files and
|
||||
monitoring them
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
from mininet.net import Mininet
|
||||
from mininet.log import setLogLevel
|
||||
@@ -13,6 +15,7 @@ from time import time
|
||||
from select import poll, POLLIN
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
|
||||
def monitorFiles( outfiles, seconds, timeoutms ):
|
||||
"Monitor set of files and return [(host, line)...]"
|
||||
devnull = open( '/dev/null', 'w' )
|
||||
@@ -53,7 +56,7 @@ def monitorTest( N=3, seconds=3 ):
|
||||
net = Mininet( topo )
|
||||
net.start()
|
||||
hosts = net.hosts
|
||||
print "Starting test..."
|
||||
print( "Starting test..." )
|
||||
server = hosts[ 0 ]
|
||||
outfiles, errfiles = {}, {}
|
||||
for h in hosts:
|
||||
@@ -67,10 +70,10 @@ def monitorTest( N=3, seconds=3 ):
|
||||
'>', outfiles[ h ],
|
||||
'2>', errfiles[ h ],
|
||||
'&' )
|
||||
print "Monitoring output for", seconds, "seconds"
|
||||
print( "Monitoring output for", seconds, "seconds" )
|
||||
for h, line in monitorFiles( outfiles, seconds, timeoutms=500 ):
|
||||
if h:
|
||||
print '%s: %s' % ( h.name, line )
|
||||
print( '%s: %s' % ( h.name, line ) )
|
||||
for h in hosts:
|
||||
h.cmd('kill %ping')
|
||||
net.stop()
|
||||
|
||||
+5
-2
@@ -4,18 +4,21 @@
|
||||
Example to create a Mininet topology and connect it to the internet via NAT
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.cli import CLI
|
||||
from mininet.log import lg
|
||||
from mininet.topolib import TreeNet
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
lg.setLogLevel( 'info')
|
||||
net = TreeNet( depth=1, fanout=4 )
|
||||
# Add NAT connectivity
|
||||
net.addNAT().configDefault()
|
||||
net.start()
|
||||
print "*** Hosts are running and should have internet connectivity"
|
||||
print "*** Type 'exit' or control-D to shut down network"
|
||||
print( "*** Hosts are running and should have internet connectivity" )
|
||||
print( "*** Type 'exit' or control-D to shut down network" )
|
||||
CLI( net )
|
||||
# Shut down NAT
|
||||
net.stop()
|
||||
|
||||
@@ -6,6 +6,8 @@ Validate that the port numbers match to the interface name,
|
||||
and that the ovs ports match the mininet ports.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Controller
|
||||
from mininet.log import setLogLevel, info, warn
|
||||
@@ -65,11 +67,11 @@ def testPortNumbering():
|
||||
'is actually on port', s1.ports[intfs], '... ' )
|
||||
if validatePort( s1, intfs ):
|
||||
info( 'Validated.\n' )
|
||||
print '\n'
|
||||
print( '\n' )
|
||||
|
||||
# test the network with pingall
|
||||
net.pingAll()
|
||||
print '\n'
|
||||
print( '\n' )
|
||||
|
||||
info( '*** Stopping network' )
|
||||
net.stop()
|
||||
|
||||
+3
-1
@@ -5,6 +5,8 @@ This example monitors a number of hosts using host.popen() and
|
||||
pmonitor()
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import CPULimitedHost
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
@@ -27,7 +29,7 @@ def monitorhosts( hosts=5, sched='cfs' ):
|
||||
# Monitor them and print output
|
||||
for host, line in pmonitor( popens ):
|
||||
if host:
|
||||
print "<%s>: %s" % ( host.name, line.strip() )
|
||||
print( "<%s>: %s" % ( host.name, line.strip() ) )
|
||||
# Done
|
||||
net.stop()
|
||||
|
||||
|
||||
@@ -2,28 +2,31 @@
|
||||
|
||||
"Monitor multiple hosts using popen()/pmonitor()"
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
from mininet.util import pmonitor
|
||||
from time import time
|
||||
from signal import SIGINT
|
||||
|
||||
|
||||
def pmonitorTest( N=3, seconds=10 ):
|
||||
"Run pings and monitor multiple hosts using pmonitor"
|
||||
topo = SingleSwitchTopo( N )
|
||||
net = Mininet( topo )
|
||||
net.start()
|
||||
hosts = net.hosts
|
||||
print "Starting test..."
|
||||
print( "Starting test..." )
|
||||
server = hosts[ 0 ]
|
||||
popens = {}
|
||||
for h in hosts:
|
||||
popens[ h ] = h.popen('ping', server.IP() )
|
||||
print "Monitoring output for", seconds, "seconds"
|
||||
print( "Monitoring output for", seconds, "seconds" )
|
||||
endTime = time() + seconds
|
||||
for h, line in pmonitor( popens, timeoutms=500 ):
|
||||
if h:
|
||||
print '<%s>: %s' % ( h.name, line ),
|
||||
print( '<%s>: %s' % ( h.name, line ) )
|
||||
if time() >= endTime:
|
||||
for p in popens.values():
|
||||
p.send_signal( SIGINT )
|
||||
|
||||
@@ -8,6 +8,8 @@ but it exposes the configuration details and allows customization.
|
||||
For most tasks, the higher-level API will be preferable.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Node
|
||||
from mininet.link import Link
|
||||
@@ -40,7 +42,7 @@ def scratchNet( cname='controller', cargs='-v ptcp:' ):
|
||||
switch.cmd( 'ovs-vsctl del-br dp0' )
|
||||
switch.cmd( 'ovs-vsctl add-br dp0' )
|
||||
for intf in switch.intfs.values():
|
||||
print switch.cmd( 'ovs-vsctl add-port dp0 %s' % intf )
|
||||
print( switch.cmd( 'ovs-vsctl add-port dp0 %s' % intf ) )
|
||||
|
||||
# Note: controller and switch are in root namespace, and we
|
||||
# can connect via loopback interface
|
||||
|
||||
@@ -52,7 +52,7 @@ def scratchNetUser( cname='controller', cargs='ptcp:' ):
|
||||
info( '*** Starting controller and user datapath\n' )
|
||||
controller.cmd( cname + ' ' + cargs + '&' )
|
||||
switch.cmd( 'ifconfig lo 127.0.0.1' )
|
||||
intfs = [ str( i ) for i in sintf1, sintf2 ]
|
||||
intfs = str( sintf1 ), str( sintf2 )
|
||||
switch.cmd( 'ofdatapath -i ' + ','.join( intfs ) + ' ptcp: &' )
|
||||
switch.cmd( 'ofprotocol tcp:' + controller.IP() + ' tcp:localhost &' )
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ iperf will hang indefinitely if the TCP handshake fails
|
||||
to complete.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.topo import Topo
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import CPULimitedHost
|
||||
@@ -44,9 +46,9 @@ def perfTest( lossy=True ):
|
||||
host=CPULimitedHost, link=TCLink,
|
||||
autoStaticArp=True )
|
||||
net.start()
|
||||
print "Dumping host connections"
|
||||
print( "Dumping host connections" )
|
||||
dumpNodeConnections(net.hosts)
|
||||
print "Testing bandwidth between h1 and h4"
|
||||
print( "Testing bandwidth between h1 and h4" )
|
||||
h1, h4 = net.getNodeByName('h1', 'h4')
|
||||
net.iperf( ( h1, h4 ), l4Type='UDP' )
|
||||
net.stop()
|
||||
|
||||
+9
-7
@@ -16,6 +16,7 @@ demonstrates:
|
||||
- running server processes (sshd in this case) on hosts
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
from mininet.net import Mininet
|
||||
@@ -25,6 +26,7 @@ from mininet.node import Node
|
||||
from mininet.topolib import TreeTopo
|
||||
from mininet.util import waitListening
|
||||
|
||||
|
||||
def TreeNet( depth=1, fanout=2, **kwargs ):
|
||||
"Convenience function for creating tree networks."
|
||||
topo = TreeTopo( depth, fanout )
|
||||
@@ -59,17 +61,17 @@ def sshd( network, cmd='/usr/sbin/sshd', opts='-D',
|
||||
connectToRootNS( network, switch, ip, routes )
|
||||
for host in network.hosts:
|
||||
host.cmd( cmd + ' ' + opts + '&' )
|
||||
print "*** Waiting for ssh daemons to start"
|
||||
print( "*** Waiting for ssh daemons to start" )
|
||||
for server in network.hosts:
|
||||
waitListening( server=server, port=22, timeout=5 )
|
||||
|
||||
print
|
||||
print "*** Hosts are running sshd at the following addresses:"
|
||||
print
|
||||
print()
|
||||
print( "*** Hosts are running sshd at the following addresses:" )
|
||||
print()
|
||||
for host in network.hosts:
|
||||
print host.name, host.IP()
|
||||
print
|
||||
print "*** Type 'exit' or control-D to shut down network"
|
||||
print( host.name, host.IP() )
|
||||
print()
|
||||
print( "*** Type 'exit' or control-D to shut down network" )
|
||||
CLI( network )
|
||||
for host in network.hosts:
|
||||
host.cmd( 'kill %' + cmd )
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Test for sshd.py
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import unittest
|
||||
import pexpect
|
||||
from mininet.clean import sh
|
||||
@@ -20,7 +21,7 @@ class testSSHD( unittest.TestCase ):
|
||||
while True:
|
||||
index = p.expect( self.opts )
|
||||
if index == 0:
|
||||
print p.match.group(0)
|
||||
print( p.match.group(0) )
|
||||
p.sendline( 'yes' )
|
||||
elif index == 1:
|
||||
return False
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
"Create a 64-node tree network, and test connectivity using ping."
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.log import setLogLevel
|
||||
from mininet.node import UserSwitch, OVSKernelSwitch # , KernelSwitch
|
||||
from mininet.topolib import TreeNet
|
||||
@@ -15,17 +17,17 @@ def treePing64():
|
||||
'Open vSwitch kernel': OVSKernelSwitch }
|
||||
|
||||
for name in switches:
|
||||
print "*** Testing", name, "datapath"
|
||||
print( "*** Testing", name, "datapath" )
|
||||
switch = switches[ name ]
|
||||
network = TreeNet( depth=2, fanout=8, switch=switch )
|
||||
result = network.run( network.pingAll )
|
||||
results[ name ] = result
|
||||
|
||||
print
|
||||
print "*** Tree network ping results:"
|
||||
print()
|
||||
print( "*** Tree network ping results:" )
|
||||
for name in switches:
|
||||
print "%s: %d%% packet loss" % ( name, results[ name ] )
|
||||
print
|
||||
print( "%s: %d%% packet loss" % ( name, results[ name ] ) )
|
||||
print()
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'info' )
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class Cleanup( object ):
|
||||
).splitlines()
|
||||
# Delete blocks of links
|
||||
n = 1000 # chunk size
|
||||
for i in xrange( 0, len( links ), n ):
|
||||
for i in range( 0, len( links ), n ):
|
||||
cmd = ';'.join( 'ip link del %s' % link
|
||||
for link in links[ i : i + n ] )
|
||||
sh( '( %s ) 2> /dev/null' % cmd )
|
||||
|
||||
+5
-4
@@ -25,6 +25,7 @@ list all nodes ('nodes'), to print out the network topology
|
||||
and bandwidth ('iperf'.)
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
from subprocess import call
|
||||
from cmd import Cmd
|
||||
from os import isatty
|
||||
@@ -176,7 +177,7 @@ class CLI( Cmd ):
|
||||
output( result + '\n' )
|
||||
else:
|
||||
output( repr( result ) + '\n' )
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
output( str( e ) + '\n' )
|
||||
|
||||
# We are in fact using the exec() pseudo-function
|
||||
@@ -187,7 +188,7 @@ class CLI( Cmd ):
|
||||
Node names may be used, e.g.: px print h1.cmd('ls')"""
|
||||
try:
|
||||
exec( line, globals(), self.getLocals() )
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
output( str( e ) + '\n' )
|
||||
|
||||
# pylint: enable=broad-except,exec-used
|
||||
@@ -371,7 +372,7 @@ class CLI( Cmd ):
|
||||
def do_links( self, _line ):
|
||||
"Report on links"
|
||||
for link in self.mn.links:
|
||||
print link, link.status()
|
||||
print( link, link.status() )
|
||||
|
||||
def do_switch( self, line ):
|
||||
"Starts or stops a switch"
|
||||
@@ -405,7 +406,7 @@ class CLI( Cmd ):
|
||||
|
||||
if first in self.mn:
|
||||
if not args:
|
||||
print "*** Enter a command for node: %s <cmd>" % first
|
||||
print( "*** Enter a command for node: %s <cmd>" % first )
|
||||
return
|
||||
node = self.mn[ first ]
|
||||
rest = args.split( ' ' )
|
||||
|
||||
+5
-5
@@ -160,7 +160,7 @@ def makeListCompatible( fn ):
|
||||
"Generated function. Closure-ish."
|
||||
if len( args ) == 1:
|
||||
return fn( *args )
|
||||
args = ' '.join( [ str( arg ) for arg in args ] )
|
||||
args = ' '.join( map( str, args ) )
|
||||
return fn( args )
|
||||
|
||||
# Fix newfn's name and docstring
|
||||
@@ -168,9 +168,9 @@ def makeListCompatible( fn ):
|
||||
setattr( newfn, '__doc__', fn.__doc__ )
|
||||
return newfn
|
||||
|
||||
info, output, warn, error, debug = (
|
||||
lg.info, lg.output, lg.warn, lg.error, lg.debug ) = [
|
||||
makeListCompatible( f ) for f in
|
||||
lg.info, lg.output, lg.warn, lg.error, lg.debug ]
|
||||
_loggers = lg.info, lg.output, lg.warn, lg.error, lg.debug
|
||||
_loggers = tuple( map( makeListCompatible, _loggers ) )
|
||||
lg.info, lg.output, lg.warn, lg.error, lg.debug = _loggers
|
||||
info, output, warn, error, debug = _loggers
|
||||
|
||||
setLogLevel = lg.setLogLevel
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
"Utility functions for Mininet."
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from mininet.log import output, info, error, warn, debug
|
||||
|
||||
from time import sleep
|
||||
@@ -587,7 +589,7 @@ def ensureRoot():
|
||||
Probably we should only sudo when needed as per Big Switch's patch.
|
||||
"""
|
||||
if os.getuid() != 0:
|
||||
print "*** Mininet must run as root."
|
||||
print( "*** Mininet must run as root." )
|
||||
exit( 1 )
|
||||
return
|
||||
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ Bob Lantz, rlantz@cs.stanford.edu
|
||||
1/24/2010
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import re, sys
|
||||
|
||||
def fixUnderscoreTriplet( match ):
|
||||
@@ -195,4 +196,4 @@ def convertFromPep8( program ):
|
||||
return program
|
||||
|
||||
if __name__ == '__main__':
|
||||
print convertFromPep8( sys.stdin.read() )
|
||||
print( convertFromPep8( sys.stdin.read() ) )
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from __future__ import print_function
|
||||
from subprocess import check_output as co
|
||||
from sys import exit
|
||||
|
||||
@@ -16,8 +17,8 @@ for line in lines.split( '\n' ):
|
||||
if line and 'Binary' not in line:
|
||||
fname, fversion = line.split( ':' )
|
||||
if version != fversion:
|
||||
print "%s: incorrect version '%s' (should be '%s')" % (
|
||||
fname, fversion, version )
|
||||
print( "%s: incorrect version '%s' (should be '%s')" % (
|
||||
fname, fversion, version ) )
|
||||
error = True
|
||||
|
||||
if error:
|
||||
|
||||
+8
-7
@@ -26,6 +26,7 @@ Basic idea:
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
from os import stat, path
|
||||
from stat import ST_MODE, ST_SIZE
|
||||
@@ -112,9 +113,9 @@ def log( *args, **kwargs ):
|
||||
msg = ' '.join( str( arg ) for arg in args )
|
||||
output = '%s [ %.3f ] %s' % ( clocktime, elapsed, msg )
|
||||
if cr:
|
||||
print output
|
||||
print( output )
|
||||
else:
|
||||
print output,
|
||||
print( output, )
|
||||
# Optionally mirror to LogFile
|
||||
if type( LogFile ) is file:
|
||||
if cr:
|
||||
@@ -202,7 +203,7 @@ def attachNBD( cow, flags='' ):
|
||||
continue
|
||||
srun( 'modprobe nbd max-part=64' )
|
||||
srun( 'qemu-nbd %s -c %s %s' % ( flags, nbd, cow ) )
|
||||
print
|
||||
print()
|
||||
return nbd
|
||||
raise Exception( "Error: could not find unused /dev/nbdX device" )
|
||||
|
||||
@@ -221,7 +222,7 @@ def extractKernel( image, flavor, imageDir=VMImageDir ):
|
||||
return kernel, initrd
|
||||
log( '* Extracting kernel to', kernel )
|
||||
nbd = attachNBD( image, flags='-r' )
|
||||
print srun( 'partx ' + nbd )
|
||||
print( srun( 'partx ' + nbd ) )
|
||||
# Assume kernel is in partition 1/boot/vmlinuz*generic for now
|
||||
part = nbd + 'p1'
|
||||
mnt = mkdtemp()
|
||||
@@ -988,7 +989,7 @@ def parseArgs():
|
||||
if args.depend:
|
||||
depend()
|
||||
if args.list:
|
||||
print buildFlavorString()
|
||||
print( buildFlavorString() )
|
||||
if args.clean:
|
||||
cleanup()
|
||||
if args.verbose:
|
||||
@@ -1009,8 +1010,8 @@ def parseArgs():
|
||||
Chown = args.chown
|
||||
for flavor in args.flavor:
|
||||
if flavor not in isoURLs:
|
||||
print "Unknown build flavor:", flavor
|
||||
print buildFlavorString()
|
||||
print( "Unknown build flavor:", flavor )
|
||||
print( buildFlavorString() )
|
||||
break
|
||||
try:
|
||||
build( flavor, tests=args.test, pre=args.run, post=args.post,
|
||||
|
||||
Reference in New Issue
Block a user