Spacing tweaks for pep8 checker
This commit is contained in:
@@ -6,7 +6,7 @@ BIN = $(MN)
|
|||||||
PYSRC = $(MININET) $(TEST) $(EXAMPLES) $(BIN)
|
PYSRC = $(MININET) $(TEST) $(EXAMPLES) $(BIN)
|
||||||
MNEXEC = mnexec
|
MNEXEC = mnexec
|
||||||
MANPAGES = mn.1 mnexec.1
|
MANPAGES = mn.1 mnexec.1
|
||||||
P8IGN = E251,E201,E302,E202
|
P8IGN = E251,E201,E302,E202,E126,E127,E203,E226
|
||||||
BINDIR = /usr/bin
|
BINDIR = /usr/bin
|
||||||
MANDIR = /usr/share/man/man1
|
MANDIR = /usr/share/man/man1
|
||||||
DOCDIRS = doc/html doc/latex
|
DOCDIRS = doc/html doc/latex
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
|
|||||||
|
|
||||||
SWITCHDEF = 'default'
|
SWITCHDEF = 'default'
|
||||||
SWITCHES = { 'user': UserSwitch,
|
SWITCHES = { 'user': UserSwitch,
|
||||||
'ovs': OVSSwitch,
|
'ovs': OVSSwitch,
|
||||||
'ovsbr' : OVSBridge,
|
'ovsbr' : OVSBridge,
|
||||||
# Keep ovsk for compatibility with 2.0
|
# Keep ovsk for compatibility with 2.0
|
||||||
'ovsk': OVSSwitch,
|
'ovsk': OVSSwitch,
|
||||||
@@ -206,7 +206,9 @@ class MininetRunner( object ):
|
|||||||
opts.add_option( '--custom', action='callback',
|
opts.add_option( '--custom', action='callback',
|
||||||
callback=self.custom,
|
callback=self.custom,
|
||||||
type='string',
|
type='string',
|
||||||
help='read custom classes or params from .py file(s)' )
|
help='read custom classes or params from .py file(s)'
|
||||||
|
)
|
||||||
|
|
||||||
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 ) )
|
||||||
@@ -329,7 +331,7 @@ class MininetRunner( object ):
|
|||||||
cli = ClusterCLI if cluster else CLI
|
cli = ClusterCLI if cluster else CLI
|
||||||
if cluster:
|
if cluster:
|
||||||
warn( '*** WARNING: Experimental cluster mode!\n'
|
warn( '*** WARNING: Experimental cluster mode!\n'
|
||||||
'*** Using RemoteHost, RemoteOVSSwitch, RemoteLink\n' )
|
'*** Using RemoteHost, RemoteOVSSwitch, RemoteLink\n' )
|
||||||
host, switch, link = RemoteHost, RemoteOVSSwitch, RemoteLink
|
host, switch, link = RemoteHost, RemoteOVSSwitch, RemoteLink
|
||||||
Net = partial( MininetCluster, servers=cluster.split( ',' ),
|
Net = partial( MininetCluster, servers=cluster.split( ',' ),
|
||||||
placement=PLACEMENT[ self.options.placement ] )
|
placement=PLACEMENT[ self.options.placement ] )
|
||||||
@@ -344,7 +346,8 @@ class MininetRunner( object ):
|
|||||||
listenPort=listenPort )
|
listenPort=listenPort )
|
||||||
|
|
||||||
if self.options.ensure_value( 'nat', False ):
|
if self.options.ensure_value( 'nat', False ):
|
||||||
nat = mn.addNAT( *self.options.nat_args, **self.options.nat_kwargs )
|
nat = mn.addNAT( *self.options.nat_args,
|
||||||
|
**self.options.nat_kwargs )
|
||||||
nat.configDefault()
|
nat.configDefault()
|
||||||
|
|
||||||
if self.options.pre:
|
if self.options.pre:
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ def testHostWithPrivateDirs():
|
|||||||
net.start()
|
net.start()
|
||||||
directories = [ directory[ 0 ] if isinstance( directory, tuple )
|
directories = [ directory[ 0 ] if isinstance( directory, tuple )
|
||||||
else directory for directory in privateDirs ]
|
else directory for directory in privateDirs ]
|
||||||
info( 'Private Directories:', directories, '\n' )
|
info( 'Private Directories:', directories, '\n' )
|
||||||
CLI( net )
|
CLI( net )
|
||||||
net.stop()
|
net.stop()
|
||||||
|
|
||||||
|
|||||||
+17
-16
@@ -254,8 +254,10 @@ class RemoteMixin( object ):
|
|||||||
|
|
||||||
def addIntf( self, *args, **kwargs ):
|
def addIntf( self, *args, **kwargs ):
|
||||||
"Override: use RemoteLink.moveIntf"
|
"Override: use RemoteLink.moveIntf"
|
||||||
return super( RemoteMixin, self).addIntf( *args,
|
return super( RemoteMixin,
|
||||||
moveIntfFn=RemoteLink.moveIntf, **kwargs )
|
self).addIntf( *args,
|
||||||
|
moveIntfFn=RemoteLink.moveIntf,
|
||||||
|
**kwargs )
|
||||||
|
|
||||||
def cleanup( self ):
|
def cleanup( self ):
|
||||||
"Help python collect its garbage."
|
"Help python collect its garbage."
|
||||||
@@ -277,7 +279,9 @@ class RemoteHost( RemoteNode ):
|
|||||||
|
|
||||||
class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
|
class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
|
||||||
"Remote instance of Open vSwitch"
|
"Remote instance of Open vSwitch"
|
||||||
|
|
||||||
OVSVersions = {}
|
OVSVersions = {}
|
||||||
|
|
||||||
def isOldOVS( self ):
|
def isOldOVS( self ):
|
||||||
"Is remote switch using an old OVS version?"
|
"Is remote switch using an old OVS version?"
|
||||||
cls = type( self )
|
cls = type( self )
|
||||||
@@ -288,12 +292,10 @@ class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
|
|||||||
cls.OVSVersions[ self.server ] = re.findall(
|
cls.OVSVersions[ self.server ] = re.findall(
|
||||||
r'\d+\.\d+', vers )[ 0 ]
|
r'\d+\.\d+', vers )[ 0 ]
|
||||||
return ( StrictVersion( cls.OVSVersions[ self.server ] ) <
|
return ( StrictVersion( cls.OVSVersions[ self.server ] ) <
|
||||||
StrictVersion( '1.10' ) )
|
StrictVersion( '1.10' ) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RemoteLink( Link ):
|
class RemoteLink( Link ):
|
||||||
|
|
||||||
"A RemoteLink is a link between nodes which may be on different servers"
|
"A RemoteLink is a link between nodes which may be on different servers"
|
||||||
|
|
||||||
def __init__( self, node1, node2, **kwargs ):
|
def __init__( self, node1, node2, **kwargs ):
|
||||||
@@ -349,7 +351,7 @@ class RemoteLink( Link ):
|
|||||||
if not ' %s:' % intf in links:
|
if not ' %s:' % intf in links:
|
||||||
if printError:
|
if printError:
|
||||||
error( '*** Error: RemoteLink.moveIntf: ' + intf +
|
error( '*** Error: RemoteLink.moveIntf: ' + intf +
|
||||||
' not successfully moved to ' + node.name + '\n' )
|
' not successfully moved to ' + node.name + '\n' )
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -388,7 +390,7 @@ class RemoteLink( Link ):
|
|||||||
'Tunnel setup failed for',
|
'Tunnel setup failed for',
|
||||||
'%s:%s' % ( node1, node1.dest ), 'to',
|
'%s:%s' % ( node1, node1.dest ), 'to',
|
||||||
'%s:%s\n' % ( node2, node2.dest ),
|
'%s:%s\n' % ( node2, node2.dest ),
|
||||||
'command was:', cmd, '\n' )
|
'command was:', cmd, '\n' )
|
||||||
tunnel.terminate()
|
tunnel.terminate()
|
||||||
tunnel.wait()
|
tunnel.wait()
|
||||||
error( ch + tunnel.stdout.read() )
|
error( ch + tunnel.stdout.read() )
|
||||||
@@ -400,7 +402,7 @@ class RemoteLink( Link ):
|
|||||||
retry( 3, .01, RemoteLink.moveIntf, 'tap9', node )
|
retry( 3, .01, RemoteLink.moveIntf, 'tap9', node )
|
||||||
# 4. Rename tap interfaces to desired names
|
# 4. Rename tap interfaces to desired names
|
||||||
for node, intf, addr in ( ( node1, intfname1, addr1 ),
|
for node, intf, addr in ( ( node1, intfname1, addr1 ),
|
||||||
( node2, intfname2, addr2 ) ):
|
( node2, intfname2, addr2 ) ):
|
||||||
if not addr:
|
if not addr:
|
||||||
node.cmd( 'ip link set tap9 name', intf )
|
node.cmd( 'ip link set tap9 name', intf )
|
||||||
else:
|
else:
|
||||||
@@ -429,7 +431,7 @@ class Placer( object ):
|
|||||||
"Node placement algorithm for MininetCluster"
|
"Node placement algorithm for MininetCluster"
|
||||||
|
|
||||||
def __init__( self, servers=None, nodes=None, hosts=None,
|
def __init__( self, servers=None, nodes=None, hosts=None,
|
||||||
switches=None, controllers=None, links=None ):
|
switches=None, controllers=None, links=None ):
|
||||||
"""Initialize placement object
|
"""Initialize placement object
|
||||||
servers: list of servers
|
servers: list of servers
|
||||||
nodes: list of all nodes
|
nodes: list of all nodes
|
||||||
@@ -494,7 +496,7 @@ class SwitchBinPlacer( Placer ):
|
|||||||
self.sset = frozenset( self.switches )
|
self.sset = frozenset( self.switches )
|
||||||
self.cset = frozenset( self.controllers )
|
self.cset = frozenset( self.controllers )
|
||||||
# Server and switch placement indices
|
# Server and switch placement indices
|
||||||
self.placement = self.calculatePlacement()
|
self.placement = self.calculatePlacement()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bin( nodes, servers ):
|
def bin( nodes, servers ):
|
||||||
@@ -561,7 +563,7 @@ class HostSwitchBinPlacer( Placer ):
|
|||||||
scount = len( self.servers )
|
scount = len( self.servers )
|
||||||
self.hbin = max( int( len( self.hosts ) / scount ), 1 )
|
self.hbin = max( int( len( self.hosts ) / scount ), 1 )
|
||||||
self.sbin = max( int( len( self.switches ) / scount ), 1 )
|
self.sbin = max( int( len( self.switches ) / scount ), 1 )
|
||||||
self.cbin = max( int( len( self.controllers ) / scount ) , 1 )
|
self.cbin = max( int( len( self.controllers ) / scount ), 1 )
|
||||||
info( 'scount:', scount )
|
info( 'scount:', scount )
|
||||||
info( 'bins:', self.hbin, self.sbin, self.cbin, '\n' )
|
info( 'bins:', self.hbin, self.sbin, self.cbin, '\n' )
|
||||||
self.servdict = dict( enumerate( self.servers ) )
|
self.servdict = dict( enumerate( self.servers ) )
|
||||||
@@ -589,7 +591,6 @@ class HostSwitchBinPlacer( Placer ):
|
|||||||
return server
|
return server
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# The MininetCluster class is not strictly necessary.
|
# The MininetCluster class is not strictly necessary.
|
||||||
# However, it has several purposes:
|
# However, it has several purposes:
|
||||||
# 1. To set up ssh connection sharing/multiplexing
|
# 1. To set up ssh connection sharing/multiplexing
|
||||||
@@ -667,7 +668,8 @@ class MininetCluster( Mininet ):
|
|||||||
result |= code
|
result |= code
|
||||||
if result:
|
if result:
|
||||||
error( '*** Server precheck failed.\n'
|
error( '*** Server precheck failed.\n'
|
||||||
'*** Make sure that the above ssh command works correctly.\n'
|
'*** Make sure that the above ssh command works'
|
||||||
|
' correctly.\n'
|
||||||
'*** You may also need to run mn -c on all nodes, and/or\n'
|
'*** You may also need to run mn -c on all nodes, and/or\n'
|
||||||
'*** use sudo -E.\n' )
|
'*** use sudo -E.\n' )
|
||||||
sys.exit( 1 )
|
sys.exit( 1 )
|
||||||
@@ -679,7 +681,6 @@ class MininetCluster( Mininet ):
|
|||||||
kwargs[ 'splitInit' ] = True
|
kwargs[ 'splitInit' ] = True
|
||||||
return Mininet.addHost( *args, **kwargs )
|
return Mininet.addHost( *args, **kwargs )
|
||||||
|
|
||||||
|
|
||||||
def placeNodes( self ):
|
def placeNodes( self ):
|
||||||
"""Place nodes on servers (if they don't have a server), and
|
"""Place nodes on servers (if they don't have a server), and
|
||||||
start shell processes"""
|
start shell processes"""
|
||||||
@@ -695,7 +696,7 @@ class MininetCluster( Mininet ):
|
|||||||
for node in nodes:
|
for node in nodes:
|
||||||
config = self.topo.nodeInfo( node )
|
config = self.topo.nodeInfo( node )
|
||||||
# keep local server name consistent accross nodes
|
# keep local server name consistent accross nodes
|
||||||
if 'server' in config.keys() and config[ 'server' ] == None:
|
if 'server' in config.keys() and config[ 'server' ] is None:
|
||||||
config[ 'server' ] = 'localhost'
|
config[ 'server' ] = 'localhost'
|
||||||
server = config.setdefault( 'server', placer.place( node ) )
|
server = config.setdefault( 'server', placer.place( node ) )
|
||||||
if server:
|
if server:
|
||||||
@@ -805,7 +806,7 @@ def testRemoteTopo():
|
|||||||
"Test remote Node classes using Mininet()/Topo() API"
|
"Test remote Node classes using Mininet()/Topo() API"
|
||||||
topo = LinearTopo( 2 )
|
topo = LinearTopo( 2 )
|
||||||
net = Mininet( topo=topo, host=HostPlacer, switch=SwitchPlacer,
|
net = Mininet( topo=topo, host=HostPlacer, switch=SwitchPlacer,
|
||||||
link=RemoteLink, controller=ClusterController )
|
link=RemoteLink, controller=ClusterController )
|
||||||
net.start()
|
net.start()
|
||||||
net.pingAll()
|
net.pingAll()
|
||||||
net.stop()
|
net.stop()
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ def clusterSanity():
|
|||||||
CLI( net )
|
CLI( net )
|
||||||
net.stop()
|
net.stop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
clusterSanity()
|
clusterSanity()
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ class ClusterCLI( CLI ):
|
|||||||
def colorsFor( seq ):
|
def colorsFor( seq ):
|
||||||
"Return a list of background colors for a sequence"
|
"Return a list of background colors for a sequence"
|
||||||
colors = [ 'red', 'lightgreen', 'cyan', 'yellow', 'orange',
|
colors = [ 'red', 'lightgreen', 'cyan', 'yellow', 'orange',
|
||||||
'magenta', 'pink', 'grey', 'brown',
|
'magenta', 'pink', 'grey', 'brown',
|
||||||
'white' ]
|
'white' ]
|
||||||
slen, clen = len( seq ), len( colors )
|
slen, clen = len( seq ), len( colors )
|
||||||
reps = max( 1, slen / clen )
|
reps = max( 1, slen / clen )
|
||||||
colors = colors * reps
|
colors = colors * reps
|
||||||
@@ -55,7 +55,7 @@ class ClusterCLI( CLI ):
|
|||||||
# Plot it!
|
# Plot it!
|
||||||
pos = nx.graphviz_layout( g )
|
pos = nx.graphviz_layout( g )
|
||||||
opts = { 'ax': None, 'font_weight': 'bold',
|
opts = { 'ax': None, 'font_weight': 'bold',
|
||||||
'width': 2, 'edge_color': 'darkblue' }
|
'width': 2, 'edge_color': 'darkblue' }
|
||||||
hcolors = [ color[ getattr( h, 'server', 'localhost' ) ]
|
hcolors = [ color[ getattr( h, 'server', 'localhost' ) ]
|
||||||
for h in hosts ]
|
for h in hosts ]
|
||||||
scolors = [ color[ getattr( s, 'server', 'localhost' ) ]
|
scolors = [ color[ getattr( s, 'server', 'localhost' ) ]
|
||||||
@@ -88,7 +88,6 @@ class ClusterCLI( CLI ):
|
|||||||
else:
|
else:
|
||||||
output( 'All nodes are still running.\n' )
|
output( 'All nodes are still running.\n' )
|
||||||
|
|
||||||
|
|
||||||
def do_placement( self, _line ):
|
def do_placement( self, _line ):
|
||||||
"Describe node placement"
|
"Describe node placement"
|
||||||
mn = self.mn
|
mn = self.mn
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ def demo():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
demo()
|
demo()
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ class ConsoleApp( Frame ):
|
|||||||
elif units[0] == 'b':
|
elif units[0] == 'b':
|
||||||
val *= 10 ** -9
|
val *= 10 ** -9
|
||||||
self.updates += 1
|
self.updates += 1
|
||||||
self.bw += val
|
self.bw += val
|
||||||
if self.updates >= self.hostCount:
|
if self.updates >= self.hostCount:
|
||||||
self.graph.addBar( self.bw )
|
self.graph.addBar( self.bw )
|
||||||
self.bw = 0
|
self.bw = 0
|
||||||
|
|||||||
+2
-1
@@ -5,7 +5,8 @@ This example shows how to add an interface (for example a real
|
|||||||
hardware interface) to a network after the network is created.
|
hardware interface) to a network after the network is created.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re, sys
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
from mininet.cli import CLI
|
from mininet.cli import CLI
|
||||||
from mininet.log import setLogLevel, info, error
|
from mininet.log import setLogLevel, info, error
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class NetworkTopo( Topo ):
|
|||||||
def run():
|
def run():
|
||||||
"Test linux router"
|
"Test linux router"
|
||||||
topo = NetworkTopo()
|
topo = NetworkTopo()
|
||||||
net = Mininet( topo=topo, controller=None ) # no controller needed
|
net = Mininet( topo=topo, controller=None ) # no controller needed
|
||||||
net.start()
|
net.start()
|
||||||
info( '*** Routing Table on Router\n' )
|
info( '*** Routing Table on Router\n' )
|
||||||
print net[ 'r0' ].cmd( 'route' )
|
print net[ 'r0' ].cmd( 'route' )
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class customOvs(OVSSwitch):
|
|||||||
"Customized OVS switch"
|
"Customized OVS switch"
|
||||||
|
|
||||||
def __init__( self, name, failMode='secure', datapath='kernel', **params ):
|
def __init__( self, name, failMode='secure', datapath='kernel', **params ):
|
||||||
OVSSwitch.__init__( self, name, failMode=failMode, datapath=datapath, **params )
|
OVSSwitch.__init__( self, name, failMode=failMode, datapath=datapath,**params )
|
||||||
self.switchIP = None
|
self.switchIP = None
|
||||||
|
|
||||||
def getSwitchIP(self):
|
def getSwitchIP(self):
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class MobilitySwitch( OVSSwitch ):
|
|||||||
def validatePort( self, intf ):
|
def validatePort( self, intf ):
|
||||||
"Validate intf's OF port number"
|
"Validate intf's OF port number"
|
||||||
ofport = int( self.cmd( 'ovs-vsctl get Interface', intf,
|
ofport = int( self.cmd( 'ovs-vsctl get Interface', intf,
|
||||||
'ofport' ) )
|
'ofport' ) )
|
||||||
if ofport != self.ports[ intf ]:
|
if ofport != self.ports[ intf ]:
|
||||||
warn( 'WARNING: ofport for', intf, 'is actually', ofport,
|
warn( 'WARNING: ofport for', intf, 'is actually', ofport,
|
||||||
'\n' )
|
'\n' )
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ def startNAT( root, inetIntf='eth0', subnet='10.0/8' ):
|
|||||||
subnet: Mininet subnet (default 10.0/8)="""
|
subnet: Mininet subnet (default 10.0/8)="""
|
||||||
|
|
||||||
# Identify the interface connecting to the mininet network
|
# Identify the interface connecting to the mininet network
|
||||||
localIntf = root.defaultIntf()
|
localIntf = root.defaultIntf()
|
||||||
|
|
||||||
# Flush any currently active rules
|
# Flush any currently active rules
|
||||||
root.cmd( 'iptables -F' )
|
root.cmd( 'iptables -F' )
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from mininet.log import setLogLevel, info, warn
|
|||||||
def validatePort( switch, intf ):
|
def validatePort( switch, intf ):
|
||||||
"Validate intf's OF port number"
|
"Validate intf's OF port number"
|
||||||
ofport = int( switch.cmd( 'ovs-vsctl get Interface', intf,
|
ofport = int( switch.cmd( 'ovs-vsctl get Interface', intf,
|
||||||
'ofport' ) )
|
'ofport' ) )
|
||||||
if ofport != switch.ports[ intf ]:
|
if ofport != switch.ports[ intf ]:
|
||||||
warn( 'WARNING: ofport for', intf, 'is actually', ofport, '\n' )
|
warn( 'WARNING: ofport for', intf, 'is actually', ofport, '\n' )
|
||||||
return 0
|
return 0
|
||||||
@@ -60,8 +60,8 @@ def testPortNumbering():
|
|||||||
for intfs in s1.intfList():
|
for intfs in s1.intfList():
|
||||||
if not intfs.name == "lo":
|
if not intfs.name == "lo":
|
||||||
info( intfs, ': ', s1.ports[intfs],
|
info( intfs, ': ', s1.ports[intfs],
|
||||||
'\n' )
|
'\n' )
|
||||||
info ( 'Validating that', intfs,
|
info( 'Validating that', intfs,
|
||||||
'is actually on port', s1.ports[intfs], '... ' )
|
'is actually on port', s1.ports[intfs], '... ' )
|
||||||
if validatePort( s1, intfs ):
|
if validatePort( s1, intfs ):
|
||||||
info( 'Validated.\n' )
|
info( 'Validated.\n' )
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ def perfTest():
|
|||||||
"Create network and run simple performance test"
|
"Create network and run simple performance test"
|
||||||
topo = SingleSwitchTopo( n=4 )
|
topo = SingleSwitchTopo( n=4 )
|
||||||
net = Mininet( topo=topo,
|
net = Mininet( topo=topo,
|
||||||
host=CPULimitedHost, link=TCLink,
|
host=CPULimitedHost, link=TCLink,
|
||||||
autoStaticArp=True )
|
autoStaticArp=True )
|
||||||
net.start()
|
net.start()
|
||||||
print "Dumping host connections"
|
print "Dumping host connections"
|
||||||
dumpNodeConnections(net.hosts)
|
dumpNodeConnections(net.hosts)
|
||||||
|
|||||||
+2
-2
@@ -73,7 +73,7 @@ def cleanup():
|
|||||||
dps = sh("ovs-vsctl --timeout=1 list-br").strip().splitlines()
|
dps = sh("ovs-vsctl --timeout=1 list-br").strip().splitlines()
|
||||||
if dps:
|
if dps:
|
||||||
sh( "ovs-vsctl " + " -- ".join( "--if-exists del-br " + dp
|
sh( "ovs-vsctl " + " -- ".join( "--if-exists del-br " + dp
|
||||||
for dp in dps if dp ) )
|
for dp in dps if dp ) )
|
||||||
# And in case the above didn't work...
|
# And in case the above didn't work...
|
||||||
dps = sh("ovs-vsctl --timeout=1 list-br").strip().splitlines()
|
dps = sh("ovs-vsctl --timeout=1 list-br").strip().splitlines()
|
||||||
for dp in dps:
|
for dp in dps:
|
||||||
@@ -89,7 +89,7 @@ def cleanup():
|
|||||||
info( "*** Killing stale mininet node processes\n" )
|
info( "*** Killing stale mininet node processes\n" )
|
||||||
killprocs( 'mininet:' )
|
killprocs( 'mininet:' )
|
||||||
|
|
||||||
info ( "*** Shutting down stale tunnels\n" )
|
info( "*** Shutting down stale tunnels\n" )
|
||||||
killprocs( 'Tunnel=Ethernet' )
|
killprocs( 'Tunnel=Ethernet' )
|
||||||
killprocs( '.ssh/mn')
|
killprocs( '.ssh/mn')
|
||||||
sh( 'rm -f ~/.ssh/mn/*' )
|
sh( 'rm -f ~/.ssh/mn/*' )
|
||||||
|
|||||||
+4
-3
@@ -37,7 +37,7 @@ import atexit
|
|||||||
from mininet.log import info, output, error
|
from mininet.log import info, output, error
|
||||||
from mininet.term import makeTerms, runX11
|
from mininet.term import makeTerms, runX11
|
||||||
from mininet.util import ( quietRun, dumpNodeConnections,
|
from mininet.util import ( quietRun, dumpNodeConnections,
|
||||||
dumpPorts )
|
dumpPorts )
|
||||||
|
|
||||||
class CLI( Cmd ):
|
class CLI( Cmd ):
|
||||||
"Simple command-line interface to talk to nodes."
|
"Simple command-line interface to talk to nodes."
|
||||||
@@ -357,7 +357,7 @@ class CLI( Cmd ):
|
|||||||
return
|
return
|
||||||
sw = args[ 0 ]
|
sw = args[ 0 ]
|
||||||
command = args[ 1 ]
|
command = args[ 1 ]
|
||||||
if sw not in self.mn or self.mn.get( sw ) not in self.mn.switches :
|
if sw not in self.mn or self.mn.get( sw ) not in self.mn.switches:
|
||||||
error( 'invalid switch: %s\n' % args[ 1 ] )
|
error( 'invalid switch: %s\n' % args[ 1 ] )
|
||||||
else:
|
else:
|
||||||
sw = args[ 0 ]
|
sw = args[ 0 ]
|
||||||
@@ -367,7 +367,8 @@ class CLI( Cmd ):
|
|||||||
elif command == 'stop':
|
elif command == 'stop':
|
||||||
self.mn.get( sw ).stop( deleteIntfs=False )
|
self.mn.get( sw ).stop( deleteIntfs=False )
|
||||||
else:
|
else:
|
||||||
error( 'invalid command: switch <switch name> {start, stop}\n' )
|
error( 'invalid command: '
|
||||||
|
'switch <switch name> {start, stop}\n' )
|
||||||
|
|
||||||
def default( self, line ):
|
def default( self, line ):
|
||||||
"""Called on an input line when the command prefix is not recognized.
|
"""Called on an input line when the command prefix is not recognized.
|
||||||
|
|||||||
+5
-3
@@ -91,7 +91,8 @@ class Intf( object ):
|
|||||||
"Return updated IP address based on ifconfig"
|
"Return updated IP address based on ifconfig"
|
||||||
# use pexec instead of node.cmd so that we dont read
|
# use pexec instead of node.cmd so that we dont read
|
||||||
# backgrounded output from the cli.
|
# backgrounded output from the cli.
|
||||||
ifconfig, _err, _exitCode = self.node.pexec( 'ifconfig %s' % self.name )
|
ifconfig, _err, _exitCode = self.node.pexec(
|
||||||
|
'ifconfig %s' % self.name )
|
||||||
ips = self._ipMatchRegex.findall( ifconfig )
|
ips = self._ipMatchRegex.findall( ifconfig )
|
||||||
self.ip = ips[ 0 ] if ips else None
|
self.ip = ips[ 0 ] if ips else None
|
||||||
return self.ip
|
return self.ip
|
||||||
@@ -333,8 +334,9 @@ class TCIntf( Intf ):
|
|||||||
|
|
||||||
# Delay/jitter/loss/max_queue_size using netem
|
# Delay/jitter/loss/max_queue_size using netem
|
||||||
delaycmds, parent = self.delayCmds( delay=delay, jitter=jitter,
|
delaycmds, parent = self.delayCmds( delay=delay, jitter=jitter,
|
||||||
loss=loss, max_queue_size=max_queue_size,
|
loss=loss,
|
||||||
parent=parent )
|
max_queue_size=max_queue_size,
|
||||||
|
parent=parent )
|
||||||
cmds += delaycmds
|
cmds += delaycmds
|
||||||
|
|
||||||
# Ugly but functional: display configuration info
|
# Ugly but functional: display configuration info
|
||||||
|
|||||||
+3
-4
@@ -99,7 +99,7 @@ from math import ceil
|
|||||||
from mininet.cli import CLI
|
from mininet.cli import CLI
|
||||||
from mininet.log import info, error, debug, output, warn
|
from mininet.log import info, error, debug, output, warn
|
||||||
from mininet.node import ( Node, Host, OVSKernelSwitch, DefaultController,
|
from mininet.node import ( Node, Host, OVSKernelSwitch, DefaultController,
|
||||||
Controller )
|
Controller )
|
||||||
from mininet.nodelib import NAT
|
from mininet.nodelib import NAT
|
||||||
from mininet.link import Link, Intf
|
from mininet.link import Link, Intf
|
||||||
from mininet.util import quietRun, fixLimits, numCores, ensureRoot
|
from mininet.util import quietRun, fixLimits, numCores, ensureRoot
|
||||||
@@ -170,7 +170,6 @@ class Mininet( object ):
|
|||||||
if topo and build:
|
if topo and build:
|
||||||
self.build()
|
self.build()
|
||||||
|
|
||||||
|
|
||||||
def waitConnected( self, timeout=None, delay=.5 ):
|
def waitConnected( self, timeout=None, delay=.5 ):
|
||||||
"""wait for each switch to connect to a controller,
|
"""wait for each switch to connect to a controller,
|
||||||
up to 5 seconds
|
up to 5 seconds
|
||||||
@@ -260,7 +259,7 @@ class Mininet( object ):
|
|||||||
else:
|
else:
|
||||||
controller_new = controller( name, **params )
|
controller_new = controller( name, **params )
|
||||||
# Add new controller to net
|
# Add new controller to net
|
||||||
if controller_new: # allow controller-less setups
|
if controller_new: # allow controller-less setups
|
||||||
self.controllers.append( controller_new )
|
self.controllers.append( controller_new )
|
||||||
self.nameToNode[ name ] = controller_new
|
self.nameToNode[ name ] = controller_new
|
||||||
return controller_new
|
return controller_new
|
||||||
@@ -335,7 +334,7 @@ class Mininet( object ):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def randMac():
|
def randMac():
|
||||||
"Return a random, non-multicast MAC address"
|
"Return a random, non-multicast MAC address"
|
||||||
return macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff |
|
return macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff |
|
||||||
0x020000000000 )
|
0x020000000000 )
|
||||||
|
|
||||||
def addLink( self, node1, node2, port1=None, port2=None,
|
def addLink( self, node1, node2, port1=None, port2=None,
|
||||||
|
|||||||
+22
-20
@@ -129,7 +129,7 @@ class Node( object ):
|
|||||||
# bash -m: enable job control, i: force interactive
|
# bash -m: enable job control, i: force interactive
|
||||||
# -s: pass $* to shell, and make process easy to find in ps
|
# -s: pass $* to shell, and make process easy to find in ps
|
||||||
# prompt is set to sentinel chr( 127 )
|
# prompt is set to sentinel chr( 127 )
|
||||||
cmd = [ 'mnexec', opts, 'env', 'PS1=' + chr( 127 ),
|
cmd = [ 'mnexec', opts, 'env', 'PS1=' + chr( 127 ),
|
||||||
'bash', '--norc', '-mis', 'mininet:' + self.name ]
|
'bash', '--norc', '-mis', 'mininet:' + self.name ]
|
||||||
# Spawn a shell subprocess in a pseudo-tty, to disable buffering
|
# Spawn a shell subprocess in a pseudo-tty, to disable buffering
|
||||||
# in the subprocess and insulate it from signals (e.g. SIGINT)
|
# in the subprocess and insulate it from signals (e.g. SIGINT)
|
||||||
@@ -380,7 +380,7 @@ class Node( object ):
|
|||||||
"""Execute a command using popen
|
"""Execute a command using popen
|
||||||
returns: out, err, exitcode"""
|
returns: out, err, exitcode"""
|
||||||
popen = self.popen( *args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
|
popen = self.popen( *args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
|
||||||
**kwargs )
|
**kwargs )
|
||||||
# Warning: this can fail with large numbers of fds!
|
# Warning: this can fail with large numbers of fds!
|
||||||
out, err = popen.communicate()
|
out, err = popen.communicate()
|
||||||
exitcode = popen.wait()
|
exitcode = popen.wait()
|
||||||
@@ -950,12 +950,12 @@ class UserSwitch( Switch ):
|
|||||||
we re-create the user switch's configuration, but as a
|
we re-create the user switch's configuration, but as a
|
||||||
leaf of the TCIntf-created configuration."""
|
leaf of the TCIntf-created configuration."""
|
||||||
if isinstance( intf, TCIntf ):
|
if isinstance( intf, TCIntf ):
|
||||||
ifspeed = 10000000000 # 10 Gbps
|
ifspeed = 10000000000 # 10 Gbps
|
||||||
minspeed = ifspeed * 0.001
|
minspeed = ifspeed * 0.001
|
||||||
|
|
||||||
res = intf.config( **intf.params )
|
res = intf.config( **intf.params )
|
||||||
|
|
||||||
if res is None: # link may not have TC parameters
|
if res is None: # link may not have TC parameters
|
||||||
return
|
return
|
||||||
|
|
||||||
# Re-add qdisc, root, and default classes user switch created, but
|
# Re-add qdisc, root, and default classes user switch created, but
|
||||||
@@ -988,7 +988,7 @@ class UserSwitch( Switch ):
|
|||||||
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
|
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
|
||||||
if "no-slicing" not in self.dpopts:
|
if "no-slicing" not in self.dpopts:
|
||||||
# Only TCReapply if slicing is enable
|
# Only TCReapply if slicing is enable
|
||||||
sleep(1) # Allow ofdatapath to start before re-arranging qdisc's
|
sleep(1) # Allow ofdatapath to start before re-arranging qdisc's
|
||||||
for intf in self.intfList():
|
for intf in self.intfList():
|
||||||
if not intf.IP():
|
if not intf.IP():
|
||||||
self.TCReapply( intf )
|
self.TCReapply( intf )
|
||||||
@@ -1055,7 +1055,7 @@ class OVSSwitch( Switch ):
|
|||||||
"Open vSwitch switch. Depends on ovs-vsctl."
|
"Open vSwitch switch. Depends on ovs-vsctl."
|
||||||
|
|
||||||
def __init__( self, name, failMode='secure', datapath='kernel',
|
def __init__( self, name, failMode='secure', datapath='kernel',
|
||||||
inband=False, protocols=None, **params ):
|
inband=False, protocols=None, **params ):
|
||||||
"""Init.
|
"""Init.
|
||||||
name: name for switch
|
name: name for switch
|
||||||
failMode: controller loss behavior (secure|open)
|
failMode: controller loss behavior (secure|open)
|
||||||
@@ -1087,13 +1087,13 @@ class OVSSwitch( Switch ):
|
|||||||
'"service openvswitch-switch start".\n' )
|
'"service openvswitch-switch start".\n' )
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
version = quietRun( 'ovs-vsctl --version' )
|
version = quietRun( 'ovs-vsctl --version' )
|
||||||
cls.OVSVersion = findall( r'\d+\.\d+', version )[ 0 ]
|
cls.OVSVersion = findall( r'\d+\.\d+', version )[ 0 ]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def isOldOVS( cls ):
|
def isOldOVS( cls ):
|
||||||
"Is OVS ersion < 1.10?"
|
"Is OVS ersion < 1.10?"
|
||||||
return ( StrictVersion( cls.OVSVersion ) <
|
return ( StrictVersion( cls.OVSVersion ) <
|
||||||
StrictVersion( '1.10' ) )
|
StrictVersion( '1.10' ) )
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def batchShutdown( cls, switches ):
|
def batchShutdown( cls, switches ):
|
||||||
@@ -1128,7 +1128,7 @@ class OVSSwitch( Switch ):
|
|||||||
"Return ovsdb UUIDs for our controllers"
|
"Return ovsdb UUIDs for our controllers"
|
||||||
uuids = []
|
uuids = []
|
||||||
controllers = self.cmd( 'ovs-vsctl -- get Bridge', self,
|
controllers = self.cmd( 'ovs-vsctl -- get Bridge', self,
|
||||||
'Controller' ).strip()
|
'Controller' ).strip()
|
||||||
if controllers.startswith( '[' ) and controllers.endswith( ']' ):
|
if controllers.startswith( '[' ) and controllers.endswith( ']' ):
|
||||||
controllers = controllers[ 1 : -1 ]
|
controllers = controllers[ 1 : -1 ]
|
||||||
uuids = [ c.strip() for c in controllers.split( ',' ) ]
|
uuids = [ c.strip() for c in controllers.split( ',' ) ]
|
||||||
@@ -1137,7 +1137,7 @@ class OVSSwitch( Switch ):
|
|||||||
def connected( self ):
|
def connected( self ):
|
||||||
"Are we connected to at least one of our controllers?"
|
"Are we connected to at least one of our controllers?"
|
||||||
results = [ 'true' in self.cmd( 'ovs-vsctl -- get Controller',
|
results = [ 'true' in self.cmd( 'ovs-vsctl -- get Controller',
|
||||||
uuid, 'is_connected' )
|
uuid, 'is_connected' )
|
||||||
for uuid in self.controllerUUIDs() ]
|
for uuid in self.controllerUUIDs() ]
|
||||||
return reduce( or_, results, False )
|
return reduce( or_, results, False )
|
||||||
|
|
||||||
@@ -1148,15 +1148,15 @@ class OVSSwitch( Switch ):
|
|||||||
'OVS kernel switch does not work in a namespace' )
|
'OVS kernel switch does not work in a namespace' )
|
||||||
# Annoyingly, --if-exists option seems not to work
|
# Annoyingly, --if-exists option seems not to work
|
||||||
self.cmd( 'ovs-vsctl del-br', self )
|
self.cmd( 'ovs-vsctl del-br', self )
|
||||||
int( self.dpid, 16 ) # DPID must be a hex string
|
int( self.dpid, 16 ) # DPID must be a hex string
|
||||||
# Interfaces and controllers
|
# Interfaces and controllers
|
||||||
intfs = ' '.join( '-- add-port %s %s ' % ( self, intf ) +
|
intfs = ' '.join( '-- add-port %s %s ' % ( self, intf ) +
|
||||||
'-- set Interface %s ' % intf +
|
'-- set Interface %s ' % intf +
|
||||||
'ofport_request=%s ' % self.ports[ intf ]
|
'ofport_request=%s ' % self.ports[ intf ]
|
||||||
for intf in self.intfList()
|
for intf in self.intfList()
|
||||||
if self.ports[ intf ] and not intf.IP() )
|
if self.ports[ intf ] and not intf.IP() )
|
||||||
clist = ' '.join( '%s:%s:%d' % ( c.protocol, c.IP(), c.port )
|
clist = ' '.join( '%s:%s:%d' % ( c.protocol, c.IP(), c.port )
|
||||||
for c in controllers )
|
for c in controllers )
|
||||||
if self.listenPort:
|
if self.listenPort:
|
||||||
clist += ' ptcp:%s' % self.listenPort
|
clist += ' ptcp:%s' % self.listenPort
|
||||||
# Construct big ovs-vsctl command for new versions of OVS
|
# Construct big ovs-vsctl command for new versions of OVS
|
||||||
@@ -1196,7 +1196,6 @@ class OVSSwitch( Switch ):
|
|||||||
for intf in self.intfList():
|
for intf in self.intfList():
|
||||||
self.TCReapply( intf )
|
self.TCReapply( intf )
|
||||||
|
|
||||||
|
|
||||||
def stop( self, deleteIntfs=True ):
|
def stop( self, deleteIntfs=True ):
|
||||||
"""Terminate OVS switch.
|
"""Terminate OVS switch.
|
||||||
deleteIntfs: delete interfaces? (True)"""
|
deleteIntfs: delete interfaces? (True)"""
|
||||||
@@ -1354,17 +1353,20 @@ class Controller( Node ):
|
|||||||
return '<%s %s: %s:%s pid=%s> ' % (
|
return '<%s %s: %s:%s pid=%s> ' % (
|
||||||
self.__class__.__name__, self.name,
|
self.__class__.__name__, self.name,
|
||||||
self.IP(), self.port, self.pid )
|
self.IP(), self.port, self.pid )
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def isAvailable( cls ):
|
def isAvailable( cls ):
|
||||||
"Is controller available?"
|
"Is controller available?"
|
||||||
return quietRun( 'which controller' )
|
return quietRun( 'which controller' )
|
||||||
|
|
||||||
|
|
||||||
class OVSController( Controller ):
|
class OVSController( Controller ):
|
||||||
"Open vSwitch controller"
|
"Open vSwitch controller"
|
||||||
def __init__( self, name, command='ovs-controller', **kwargs ):
|
def __init__( self, name, command='ovs-controller', **kwargs ):
|
||||||
if quietRun( 'which test-controller' ):
|
if quietRun( 'which test-controller' ):
|
||||||
command = 'test-controller'
|
command = 'test-controller'
|
||||||
Controller.__init__( self, name, command=command, **kwargs )
|
Controller.__init__( self, name, command=command, **kwargs )
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def isAvailable( cls ):
|
def isAvailable( cls ):
|
||||||
return ( quietRun( 'which ovs-controller' ) or
|
return ( quietRun( 'which ovs-controller' ) or
|
||||||
@@ -1411,11 +1413,11 @@ class RYU( Controller ):
|
|||||||
ryuArgs = [ ryuArgs ]
|
ryuArgs = [ ryuArgs ]
|
||||||
|
|
||||||
Controller.__init__( self, name,
|
Controller.__init__( self, name,
|
||||||
command='ryu-manager',
|
command='ryu-manager',
|
||||||
cargs='--ofp-tcp-listen-port %s ' +
|
cargs='--ofp-tcp-listen-port %s ' +
|
||||||
' '.join( ryuArgs ),
|
' '.join( ryuArgs ),
|
||||||
cdir=ryuCoreDir,
|
cdir=ryuCoreDir,
|
||||||
**kwargs )
|
**kwargs )
|
||||||
|
|
||||||
class RemoteController( Controller ):
|
class RemoteController( Controller ):
|
||||||
"Controller running outside of Mininet's control."
|
"Controller running outside of Mininet's control."
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ class NAT( Node ):
|
|||||||
super( NAT, self).config( **params )
|
super( NAT, self).config( **params )
|
||||||
|
|
||||||
if not self.localIntf:
|
if not self.localIntf:
|
||||||
self.localIntf = self.defaultIntf()
|
self.localIntf = self.defaultIntf()
|
||||||
|
|
||||||
self.cmd( 'sysctl net.ipv4.ip_forward=0' )
|
self.cmd( 'sysctl net.ipv4.ip_forward=0' )
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ def tunnelX11( node, display=None):
|
|||||||
port = 6000 + int( float( screen ) )
|
port = 6000 + int( float( screen ) )
|
||||||
connection = r'TCP\:%s\:%s' % ( host, port )
|
connection = r'TCP\:%s\:%s' % ( host, port )
|
||||||
cmd = [ "socat", "TCP-LISTEN:%d,fork,reuseaddr" % port,
|
cmd = [ "socat", "TCP-LISTEN:%d,fork,reuseaddr" % port,
|
||||||
"EXEC:'mnexec -a 1 socat STDIO %s'" % connection ]
|
"EXEC:'mnexec -a 1 socat STDIO %s'" % connection ]
|
||||||
return 'localhost:' + screen, node.popen( cmd )
|
return 'localhost:' + screen, node.popen( cmd )
|
||||||
|
|
||||||
def makeTerm( node, title='Node', term='xterm', display=None ):
|
def makeTerm( node, title='Node', term='xterm', display=None ):
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class testOptionsTopoCommon( object ):
|
|||||||
"""Verify ability to create networks with host and link options
|
"""Verify ability to create networks with host and link options
|
||||||
(common code)."""
|
(common code)."""
|
||||||
|
|
||||||
switchClass = None # overridden in subclasses
|
switchClass = None # overridden in subclasses
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tearDown():
|
def tearDown():
|
||||||
@@ -87,7 +87,7 @@ class testOptionsTopoCommon( object ):
|
|||||||
upperBound, lowerBound ) )
|
upperBound, lowerBound ) )
|
||||||
msg += info
|
msg += info
|
||||||
|
|
||||||
self.assertGreaterEqual( float( measured ),lowerBound, msg=msg )
|
self.assertGreaterEqual( float( measured ), lowerBound, msg=msg )
|
||||||
self.assertLessEqual( float( measured ), upperBound, msg=msg )
|
self.assertLessEqual( float( measured ), upperBound, msg=msg )
|
||||||
|
|
||||||
def testCPULimits( self ):
|
def testCPULimits( self ):
|
||||||
@@ -125,8 +125,8 @@ class testOptionsTopoCommon( object ):
|
|||||||
def testLinkBandwidth( self ):
|
def testLinkBandwidth( self ):
|
||||||
"Verify that link bandwidths are accurate within a bound."
|
"Verify that link bandwidths are accurate within a bound."
|
||||||
if self.switchClass is UserSwitch:
|
if self.switchClass is UserSwitch:
|
||||||
self.skipTest ( 'UserSwitch has very poor performance -'
|
self.skipTest( 'UserSwitch has very poor performance -'
|
||||||
' skipping for now' )
|
' skipping for now' )
|
||||||
BW = 5 # Mbps
|
BW = 5 # Mbps
|
||||||
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
|
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
|
||||||
# Verify ability to create limited-link topo first;
|
# Verify ability to create limited-link topo first;
|
||||||
@@ -195,7 +195,6 @@ class testOptionsTopoCommon( object ):
|
|||||||
self.assertWithinTolerance( rttval, DELAY_MS * 4.0,
|
self.assertWithinTolerance( rttval, DELAY_MS * 4.0,
|
||||||
DELAY_TOLERANCE, msg )
|
DELAY_TOLERANCE, msg )
|
||||||
|
|
||||||
|
|
||||||
def testLinkLoss( self ):
|
def testLinkLoss( self ):
|
||||||
"Verify that we see packet drops with a high configured loss rate."
|
"Verify that we see packet drops with a high configured loss rate."
|
||||||
LOSS_PERCENT = 99
|
LOSS_PERCENT = 99
|
||||||
@@ -257,9 +256,10 @@ class testOptionsTopoIVS( testOptionsTopoCommon, unittest.TestCase ):
|
|||||||
switchClass = IVSSwitch
|
switchClass = IVSSwitch
|
||||||
|
|
||||||
@unittest.skipUnless( quietRun( 'which ofprotocol' ),
|
@unittest.skipUnless( quietRun( 'which ofprotocol' ),
|
||||||
'Reference user switch is not installed' )
|
'Reference user switch is not installed' )
|
||||||
class testOptionsTopoUserspace( testOptionsTopoCommon, unittest.TestCase ):
|
class testOptionsTopoUserspace( testOptionsTopoCommon, unittest.TestCase ):
|
||||||
"Verify ability to create networks with host and link options (UserSwitch)."
|
"""Verify ability to create networks with host and link options
|
||||||
|
(UserSwitch)."""
|
||||||
longMessage = True
|
longMessage = True
|
||||||
switchClass = UserSwitch
|
switchClass = UserSwitch
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from mininet.clean import cleanup
|
|||||||
class testSingleSwitchCommon( object ):
|
class testSingleSwitchCommon( object ):
|
||||||
"Test ping with single switch topology (common code)."
|
"Test ping with single switch topology (common code)."
|
||||||
|
|
||||||
switchClass = None # overridden in subclasses
|
switchClass = None # overridden in subclasses
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tearDown():
|
def tearDown():
|
||||||
@@ -59,7 +59,7 @@ class testSingleSwitchIVS( testSingleSwitchCommon, unittest.TestCase ):
|
|||||||
switchClass = IVSSwitch
|
switchClass = IVSSwitch
|
||||||
|
|
||||||
@unittest.skipUnless( quietRun( 'which ofprotocol' ),
|
@unittest.skipUnless( quietRun( 'which ofprotocol' ),
|
||||||
'Reference user switch is not installed' )
|
'Reference user switch is not installed' )
|
||||||
class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ):
|
class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ):
|
||||||
"Test ping with single switch topology (Userspace switch)."
|
"Test ping with single switch topology (Userspace switch)."
|
||||||
switchClass = UserSwitch
|
switchClass = UserSwitch
|
||||||
@@ -71,7 +71,7 @@ class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ):
|
|||||||
class testLinearCommon( object ):
|
class testLinearCommon( object ):
|
||||||
"Test all-pairs ping with LinearNet (common code)."
|
"Test all-pairs ping with LinearNet (common code)."
|
||||||
|
|
||||||
switchClass = None # overridden in subclasses
|
switchClass = None # overridden in subclasses
|
||||||
|
|
||||||
def testLinear5( self ):
|
def testLinear5( self ):
|
||||||
"Ping test on a 5-switch topology"
|
"Ping test on a 5-switch topology"
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import sys
|
|||||||
|
|
||||||
from mininet.net import Mininet
|
from mininet.net import Mininet
|
||||||
from mininet.node import Host, Controller
|
from mininet.node import Host, Controller
|
||||||
from mininet.node import UserSwitch, OVSSwitch, OVSLegacyKernelSwitch, IVSSwitch
|
from mininet.node import ( UserSwitch, OVSSwitch, OVSLegacyKernelSwitch,
|
||||||
|
IVSSwitch )
|
||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
from mininet.log import setLogLevel
|
from mininet.log import setLogLevel
|
||||||
from mininet.util import quietRun
|
from mininet.util import quietRun
|
||||||
@@ -18,7 +19,7 @@ from mininet.clean import cleanup
|
|||||||
class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
|
class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
|
||||||
"Verify Switch dpid assignment."
|
"Verify Switch dpid assignment."
|
||||||
|
|
||||||
switchClass = OVSSwitch # overridden in subclasses
|
switchClass = OVSSwitch # overridden in subclasses
|
||||||
|
|
||||||
def tearDown( self ):
|
def tearDown( self ):
|
||||||
"Clean up if necessary"
|
"Clean up if necessary"
|
||||||
@@ -27,11 +28,12 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
|
|||||||
if sys.exc_info != ( None, None, None ):
|
if sys.exc_info != ( None, None, None ):
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
def testDefaultDpid ( self ):
|
def testDefaultDpid( self ):
|
||||||
"""Verify that the default dpid is assigned using a valid provided
|
"""Verify that the default dpid is assigned using a valid provided
|
||||||
canonical switchname if no dpid is passed in switch creation."""
|
canonical switchname if no dpid is passed in switch creation."""
|
||||||
switch = Mininet( Topo(),
|
switch = Mininet( Topo(),
|
||||||
self.switchClass, Host, Controller ).addSwitch( 's1' )
|
self.switchClass,
|
||||||
|
Host, Controller ).addSwitch( 's1' )
|
||||||
self.assertEqual( switch.defaultDpid(), switch.dpid )
|
self.assertEqual( switch.defaultDpid(), switch.dpid )
|
||||||
|
|
||||||
def dpidFrom( self, num ):
|
def dpidFrom( self, num ):
|
||||||
@@ -45,7 +47,7 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
|
|||||||
dpid = self.dpidFrom( 0xABCD )
|
dpid = self.dpidFrom( 0xABCD )
|
||||||
switch = Mininet( Topo(), self.switchClass,
|
switch = Mininet( Topo(), self.switchClass,
|
||||||
Host, Controller ).addSwitch(
|
Host, Controller ).addSwitch(
|
||||||
's1', dpid=dpid )
|
's1', dpid=dpid )
|
||||||
self.assertEqual( switch.dpid, dpid )
|
self.assertEqual( switch.dpid, dpid )
|
||||||
|
|
||||||
def testDefaultDpidAssignmentFailure( self ):
|
def testDefaultDpidAssignmentFailure( self ):
|
||||||
|
|||||||
+3
-3
@@ -78,7 +78,6 @@ class MultiGraph( object ):
|
|||||||
"Return list of graph edges"
|
"Return list of graph edges"
|
||||||
return list( self.edges_iter( data=data, keys=keys ) )
|
return list( self.edges_iter( data=data, keys=keys ) )
|
||||||
|
|
||||||
|
|
||||||
def __getitem__( self, node ):
|
def __getitem__( self, node ):
|
||||||
"Return link dict for given src node"
|
"Return link dict for given src node"
|
||||||
return self.edge[ node ]
|
return self.edge[ node ]
|
||||||
@@ -147,7 +146,7 @@ class Topo( object ):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def addLink( self, node1, node2, port1=None, port2=None,
|
def addLink( self, node1, node2, port1=None, port2=None,
|
||||||
key=None, **opts ):
|
key=None, **opts ):
|
||||||
"""node1, node2: nodes to link together
|
"""node1, node2: nodes to link together
|
||||||
port1, port2: ports (optional)
|
port1, port2: ports (optional)
|
||||||
opts: link options (optional)
|
opts: link options (optional)
|
||||||
@@ -306,7 +305,8 @@ class SingleSwitchTopo( Topo ):
|
|||||||
class SingleSwitchReversedTopo( Topo ):
|
class SingleSwitchReversedTopo( Topo ):
|
||||||
"""Single switch connected to k hosts, with reversed ports.
|
"""Single switch connected to k hosts, with reversed ports.
|
||||||
The lowest-numbered host is connected to the highest-numbered port.
|
The lowest-numbered host is connected to the highest-numbered port.
|
||||||
Useful to verify that Mininet properly handles custom port numberings."""
|
Useful to verify that Mininet properly handles custom port
|
||||||
|
numberings."""
|
||||||
|
|
||||||
def build( self, k=2 ):
|
def build( self, k=2 ):
|
||||||
"k: number of hosts"
|
"k: number of hosts"
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ class TorusTopo( Topo ):
|
|||||||
def build( self, x, y ):
|
def build( self, x, y ):
|
||||||
if x < 3 or y < 3:
|
if x < 3 or y < 3:
|
||||||
raise Exception( 'Please use 3x3 or greater for compatibility '
|
raise Exception( 'Please use 3x3 or greater for compatibility '
|
||||||
'with 2.1' )
|
'with 2.1' )
|
||||||
hosts, switches, dpid = {}, {}, 0
|
hosts, switches, dpid = {}, {}, 0
|
||||||
# Create and wire interior
|
# Create and wire interior
|
||||||
for i in range( 0, x ):
|
for i in range( 0, x ):
|
||||||
|
|||||||
+3
-3
@@ -200,7 +200,7 @@ def moveIntfNoRetry( intf, dstNode, printError=False ):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def moveIntf( intf, dstNode, printError=True,
|
def moveIntf( intf, dstNode, printError=True,
|
||||||
retries=3, delaySecs=0.001 ):
|
retries=3, delaySecs=0.001 ):
|
||||||
"""Move interface to node, retrying on failure.
|
"""Move interface to node, retrying on failure.
|
||||||
intf: string, interface
|
intf: string, interface
|
||||||
dstNode: destination Node
|
dstNode: destination Node
|
||||||
@@ -546,13 +546,13 @@ def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ):
|
|||||||
"""Wait until server is listening on port.
|
"""Wait until server is listening on port.
|
||||||
returns True if server is listening"""
|
returns True if server is listening"""
|
||||||
runCmd = ( client.cmd if client else
|
runCmd = ( client.cmd if client else
|
||||||
partial( quietRun, shell=True ) )
|
partial( quietRun, shell=True ) )
|
||||||
if not runCmd( 'which telnet' ):
|
if not runCmd( 'which telnet' ):
|
||||||
raise Exception('Could not find telnet' )
|
raise Exception('Could not find telnet' )
|
||||||
# pylint: disable=maybe-no-member
|
# pylint: disable=maybe-no-member
|
||||||
serverIP = server if isinstance( server, basestring ) else server.IP()
|
serverIP = server if isinstance( server, basestring ) else server.IP()
|
||||||
cmd = ( 'sh -c "echo A | telnet -e A %s %s"' %
|
cmd = ( 'sh -c "echo A | telnet -e A %s %s"' %
|
||||||
( serverIP, port ) )
|
( serverIP, port ) )
|
||||||
time = 0
|
time = 0
|
||||||
while 'Connected' not in runCmd( cmd ):
|
while 'Connected' not in runCmd( cmd ):
|
||||||
if timeout:
|
if timeout:
|
||||||
|
|||||||
Reference in New Issue
Block a user