More pylint changes
This commit is contained in:
+24
-14
@@ -123,7 +123,8 @@ class RemoteMixin( object ):
|
|||||||
**kwargs: see Node()"""
|
**kwargs: see Node()"""
|
||||||
# We connect to servers by IP address
|
# We connect to servers by IP address
|
||||||
self.server = server if server else 'localhost'
|
self.server = server if server else 'localhost'
|
||||||
self.serverIP = serverIP if serverIP else self.findServerIP( self.server )
|
self.serverIP = ( serverIP if serverIP
|
||||||
|
else self.findServerIP( self.server ) )
|
||||||
self.user = user if user else self.findUser()
|
self.user = user if user else self.findUser()
|
||||||
if controlPath is True:
|
if controlPath is True:
|
||||||
# Set a default control path for shared SSH connections
|
# Set a default control path for shared SSH connections
|
||||||
@@ -143,21 +144,20 @@ class RemoteMixin( object ):
|
|||||||
self.dest = None
|
self.dest = None
|
||||||
self.sshcmd = []
|
self.sshcmd = []
|
||||||
self.isRemote = False
|
self.isRemote = False
|
||||||
|
# Satisfy pylint
|
||||||
|
self.shell, self.pid, self.cmd = None, None, None
|
||||||
super( RemoteMixin, self ).__init__( name, **kwargs )
|
super( RemoteMixin, self ).__init__( name, **kwargs )
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def findUser():
|
def findUser():
|
||||||
"Try to return logged-in (usually non-root) user"
|
"Try to return logged-in (usually non-root) user"
|
||||||
try:
|
return (
|
||||||
# If we're running sudo
|
# If we're running sudo
|
||||||
return os.environ[ 'SUDO_USER' ]
|
os.environ.get( 'SUDO_USER', False ) or
|
||||||
except:
|
|
||||||
try:
|
|
||||||
# Logged-in user (if we have a tty)
|
# Logged-in user (if we have a tty)
|
||||||
return quietRun( 'who am i' ).split()[ 0 ]
|
( quietRun( 'who am i' ).split() or [ False ] )[ 0 ] or
|
||||||
except:
|
|
||||||
# Give up and return effective user
|
# Give up and return effective user
|
||||||
return quietRun( 'whoami' )
|
quietRun( 'whoami' ) )
|
||||||
|
|
||||||
# Determine IP address of local host
|
# Determine IP address of local host
|
||||||
_ipMatchRegex = re.compile( r'\d+\.\d+\.\d+\.\d+' )
|
_ipMatchRegex = re.compile( r'\d+\.\d+\.\d+\.\d+' )
|
||||||
@@ -187,6 +187,8 @@ class RemoteMixin( object ):
|
|||||||
self.pid = int( self.cmd( 'echo $$' ) )
|
self.pid = int( self.cmd( 'echo $$' ) )
|
||||||
|
|
||||||
def finishInit( self ):
|
def finishInit( self ):
|
||||||
|
"Wait for split initialization to complete"
|
||||||
|
assert self # please pylint
|
||||||
self.pid = int( self.waitOutput() )
|
self.pid = int( self.waitOutput() )
|
||||||
|
|
||||||
def rpopen( self, *cmd, **opts ):
|
def rpopen( self, *cmd, **opts ):
|
||||||
@@ -282,7 +284,8 @@ class RemoteOVSSwitch( RemoteMixin, OVSSwitch ):
|
|||||||
cls = type( self )
|
cls = type( self )
|
||||||
if self.server not in cls.OVSVersions:
|
if self.server not in cls.OVSVersions:
|
||||||
vers = self.cmd( 'ovs-vsctl --version' )
|
vers = self.cmd( 'ovs-vsctl --version' )
|
||||||
cls.OVSVersions[ self.server ] = re.findall( r'\d+\.\d+', vers )[ 0 ]
|
cls.OVSVersions[ self.server ] = re.findall(
|
||||||
|
r'\d+\.\d+', vers )[ 0 ]
|
||||||
return ( StrictVersion( cls.OVSVersions[ self.server ] ) <
|
return ( StrictVersion( cls.OVSVersions[ self.server ] ) <
|
||||||
StrictVersion( '1.10' ) )
|
StrictVersion( '1.10' ) )
|
||||||
|
|
||||||
@@ -301,6 +304,7 @@ class RemoteLink( Link ):
|
|||||||
self.tunnel = None
|
self.tunnel = None
|
||||||
kwargs.setdefault( 'params1', {} )
|
kwargs.setdefault( 'params1', {} )
|
||||||
kwargs.setdefault( 'params2', {} )
|
kwargs.setdefault( 'params2', {} )
|
||||||
|
self.cmd = None # satisfy pylint
|
||||||
Link.__init__( self, node1, node2, **kwargs )
|
Link.__init__( self, node1, node2, **kwargs )
|
||||||
|
|
||||||
def stop( self ):
|
def stop( self ):
|
||||||
@@ -324,9 +328,10 @@ class RemoteLink( Link ):
|
|||||||
elif server1 == server2:
|
elif server1 == server2:
|
||||||
# Remote link on same remote server
|
# Remote link on same remote server
|
||||||
return makeIntfPair( intfname1, intfname2, addr1, addr2,
|
return makeIntfPair( intfname1, intfname2, addr1, addr2,
|
||||||
run=node1.rcmd )
|
runCmd=node1.rcmd )
|
||||||
# Otherwise, make a tunnel
|
# Otherwise, make a tunnel
|
||||||
self.tunnel = self.makeTunnel( node1, node2, intfname1, intfname2, addr1, addr2 )
|
self.tunnel = self.makeTunnel( node1, node2, intfname1, intfname2,
|
||||||
|
addr1, addr2 )
|
||||||
return self.tunnel
|
return self.tunnel
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -340,7 +345,7 @@ class RemoteLink( Link ):
|
|||||||
cmd = 'ip link set %s netns %s' % ( intf, node.pid )
|
cmd = 'ip link set %s netns %s' % ( intf, node.pid )
|
||||||
node.rcmd( cmd )
|
node.rcmd( cmd )
|
||||||
links = node.cmd( 'ip link show' )
|
links = node.cmd( 'ip link show' )
|
||||||
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' )
|
||||||
@@ -442,8 +447,9 @@ class Placer( object ):
|
|||||||
|
|
||||||
def place( self, node ):
|
def place( self, node ):
|
||||||
"Return server for a given node"
|
"Return server for a given node"
|
||||||
|
assert self, node # satisfy pylint
|
||||||
# Default placement: run locally
|
# Default placement: run locally
|
||||||
return None
|
return 'localhost'
|
||||||
|
|
||||||
|
|
||||||
class RandomPlacer( Placer ):
|
class RandomPlacer( Placer ):
|
||||||
@@ -451,6 +457,7 @@ class RandomPlacer( Placer ):
|
|||||||
def place( self, nodename ):
|
def place( self, nodename ):
|
||||||
"""Random placement function
|
"""Random placement function
|
||||||
nodename: node name"""
|
nodename: node name"""
|
||||||
|
assert nodename # please pylint
|
||||||
# This may be slow with lots of servers
|
# This may be slow with lots of servers
|
||||||
return self.servers[ randrange( 0, len( self.servers ) ) ]
|
return self.servers[ randrange( 0, len( self.servers ) ) ]
|
||||||
|
|
||||||
@@ -467,6 +474,7 @@ class RoundRobinPlacer( Placer ):
|
|||||||
def place( self, nodename ):
|
def place( self, nodename ):
|
||||||
"""Round-robin placement function
|
"""Round-robin placement function
|
||||||
nodename: node name"""
|
nodename: node name"""
|
||||||
|
assert nodename # please pylint
|
||||||
# This may be slow with lots of servers
|
# This may be slow with lots of servers
|
||||||
server = self.servers[ self.next ]
|
server = self.servers[ self.next ]
|
||||||
self.next = ( self.next + 1 ) % len( self.servers )
|
self.next = ( self.next + 1 ) % len( self.servers )
|
||||||
@@ -626,6 +634,7 @@ class MininetCluster( Mininet ):
|
|||||||
|
|
||||||
def popen( self, cmd ):
|
def popen( self, cmd ):
|
||||||
"Popen() for server connections"
|
"Popen() for server connections"
|
||||||
|
assert self # please pylint
|
||||||
old = signal( SIGINT, SIG_IGN )
|
old = signal( SIGINT, SIG_IGN )
|
||||||
conn = Popen( cmd, stdin=PIPE, stdout=PIPE, close_fds=True )
|
conn = Popen( cmd, stdin=PIPE, stdout=PIPE, close_fds=True )
|
||||||
signal( SIGINT, old )
|
signal( SIGINT, old )
|
||||||
@@ -649,7 +658,7 @@ class MininetCluster( Mininet ):
|
|||||||
cmd = [ 'sudo', '-E', '-u', self.user ]
|
cmd = [ 'sudo', '-E', '-u', self.user ]
|
||||||
cmd += self.sshcmd + [ '-n', dest, 'sudo true' ]
|
cmd += self.sshcmd + [ '-n', dest, 'sudo true' ]
|
||||||
debug( ' '.join( cmd ), '\n' )
|
debug( ' '.join( cmd ), '\n' )
|
||||||
out, err, code = errRun( cmd )
|
_out, _err, code = errRun( cmd )
|
||||||
if code != 0:
|
if code != 0:
|
||||||
error( '\nstartConnection: server connection check failed '
|
error( '\nstartConnection: server connection check failed '
|
||||||
'to %s using command:\n%s\n'
|
'to %s using command:\n%s\n'
|
||||||
@@ -665,6 +674,7 @@ class MininetCluster( Mininet ):
|
|||||||
|
|
||||||
def modifiedaddHost( self, *args, **kwargs ):
|
def modifiedaddHost( self, *args, **kwargs ):
|
||||||
"Slightly modify addHost"
|
"Slightly modify addHost"
|
||||||
|
assert self # please pylint
|
||||||
kwargs[ 'splitInit' ] = True
|
kwargs[ 'splitInit' ] = True
|
||||||
return Mininet.addHost( *args, **kwargs )
|
return Mininet.addHost( *args, **kwargs )
|
||||||
|
|
||||||
|
|||||||
+16
-10
@@ -5,6 +5,7 @@
|
|||||||
from mininet.cli import CLI
|
from mininet.cli import CLI
|
||||||
from mininet.log import output, error
|
from mininet.log import output, error
|
||||||
|
|
||||||
|
# pylint: disable=global-statement
|
||||||
nx, graphviz_layout, plt = None, None, None # Will be imported on demand
|
nx, graphviz_layout, plt = None, None, None # Will be imported on demand
|
||||||
|
|
||||||
|
|
||||||
@@ -23,17 +24,19 @@ class ClusterCLI( CLI ):
|
|||||||
colors = colors[ 0 : slen ]
|
colors = colors[ 0 : slen ]
|
||||||
return colors
|
return colors
|
||||||
|
|
||||||
def do_plot( self, line ):
|
def do_plot( self, _line ):
|
||||||
"Plot topology colored by node placement"
|
"Plot topology colored by node placement"
|
||||||
# Import networkx if needed
|
# Import networkx if needed
|
||||||
global nx, plt
|
global nx, plt
|
||||||
if not nx:
|
if not nx:
|
||||||
try:
|
try:
|
||||||
import networkx as nx
|
import networkx
|
||||||
import matplotlib.pyplot as plt
|
nx = networkx # satisfy pylint
|
||||||
|
from matplotlib import pyplot
|
||||||
|
plt = pyplot # satisfiy pylint
|
||||||
import pygraphviz
|
import pygraphviz
|
||||||
assert pygraphviz # silence pyflakes
|
assert pygraphviz # silence pyflakes
|
||||||
except:
|
except ImportError:
|
||||||
error( 'plot requires networkx, matplotlib and pygraphviz - '
|
error( 'plot requires networkx, matplotlib and pygraphviz - '
|
||||||
'please install them and try again\n' )
|
'please install them and try again\n' )
|
||||||
return
|
return
|
||||||
@@ -53,10 +56,13 @@ class ClusterCLI( CLI ):
|
|||||||
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' ) ] for h in hosts ]
|
hcolors = [ color[ getattr( h, 'server', 'localhost' ) ]
|
||||||
scolors = [ color[ getattr( s, 'server', 'localhost' ) ] for s in switches ]
|
for h in hosts ]
|
||||||
nx.draw_networkx( g, pos=pos, nodelist=hosts, node_size=800, label='host',
|
scolors = [ color[ getattr( s, 'server', 'localhost' ) ]
|
||||||
node_color=hcolors, node_shape='s', **opts )
|
for s in switches ]
|
||||||
|
nx.draw_networkx( g, pos=pos, nodelist=hosts, node_size=800,
|
||||||
|
label='host', node_color=hcolors, node_shape='s',
|
||||||
|
**opts )
|
||||||
nx.draw_networkx( g, pos=pos, nodelist=switches, node_size=1000,
|
nx.draw_networkx( g, pos=pos, nodelist=switches, node_size=1000,
|
||||||
node_color=scolors, node_shape='o', **opts )
|
node_color=scolors, node_shape='o', **opts )
|
||||||
# Get rid of axes, add title, and show
|
# Get rid of axes, add title, and show
|
||||||
@@ -68,7 +74,7 @@ class ClusterCLI( CLI ):
|
|||||||
plt.title( 'Node Placement', fontweight='bold' )
|
plt.title( 'Node Placement', fontweight='bold' )
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
def do_status( self, line ):
|
def do_status( self, _line ):
|
||||||
"Report on node shell status"
|
"Report on node shell status"
|
||||||
nodes = self.mn.hosts + self.mn.switches
|
nodes = self.mn.hosts + self.mn.switches
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
@@ -83,7 +89,7 @@ class ClusterCLI( CLI ):
|
|||||||
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
|
||||||
nodes = mn.hosts + mn.switches + mn.controllers
|
nodes = mn.hosts + mn.switches + mn.controllers
|
||||||
|
|||||||
+4
-2
@@ -27,9 +27,11 @@ def limit( bw=10, cpu=.1 ):
|
|||||||
info( '*** Testing with', sched, 'bandwidth limiting\n' )
|
info( '*** Testing with', sched, 'bandwidth limiting\n' )
|
||||||
if sched == 'rt':
|
if sched == 'rt':
|
||||||
release = quietRun( 'uname -r' ).strip('\r\n')
|
release = quietRun( 'uname -r' ).strip('\r\n')
|
||||||
output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release )
|
output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s'
|
||||||
|
% release )
|
||||||
if output == '# CONFIG_RT_GROUP_SCHED is not set\n':
|
if output == '# CONFIG_RT_GROUP_SCHED is not set\n':
|
||||||
info( '*** RT Scheduler is not enabled in your kernel. Skipping this test\n' )
|
info( '*** RT Scheduler is not enabled in your kernel. '
|
||||||
|
'Skipping this test\n' )
|
||||||
continue
|
continue
|
||||||
host = custom( CPULimitedHost, sched=sched, cpu=cpu )
|
host = custom( CPULimitedHost, sched=sched, cpu=cpu )
|
||||||
net = Mininet( topo=myTopo, intf=intf, host=host )
|
net = Mininet( topo=myTopo, intf=intf, host=host )
|
||||||
|
|||||||
+14
-7
@@ -44,16 +44,23 @@ class LinuxRouter( Node ):
|
|||||||
class NetworkTopo( Topo ):
|
class NetworkTopo( Topo ):
|
||||||
"A simple topology of a router with three subnets (one host in each)."
|
"A simple topology of a router with three subnets (one host in each)."
|
||||||
|
|
||||||
def build( self, n=2, h=1, **opts ):
|
def build( self, **opts ):
|
||||||
router = self.addNode( 'r0', cls=LinuxRouter, ip='192.168.1.1/24' )
|
router = self.addNode( 'r0', cls=LinuxRouter, ip='192.168.1.1/24' )
|
||||||
h1 = self.addHost( 'h1', ip='192.168.1.100/24', defaultRoute='via 192.168.1.1' )
|
h1 = self.addHost( 'h1', ip='192.168.1.100/24',
|
||||||
h2 = self.addHost( 'h2', ip='172.16.0.100/12', defaultRoute='via 172.16.0.1' )
|
defaultRoute='via 192.168.1.1' )
|
||||||
h3 = self.addHost( 'h3', ip='10.0.0.100/8', defaultRoute='via 10.0.0.1' )
|
h2 = self.addHost( 'h2', ip='172.16.0.100/12',
|
||||||
self.addLink( h1, router, intfName2='r0-eth1', params2={ 'ip' : '192.168.1.1/24' } )
|
defaultRoute='via 172.16.0.1' )
|
||||||
self.addLink( h2, router, intfName2='r0-eth2', params2={ 'ip' : '172.16.0.1/12' } )
|
h3 = self.addHost( 'h3', ip='10.0.0.100/8',
|
||||||
self.addLink( h3, router, intfName2='r0-eth3', params2={ 'ip' : '10.0.0.1/8' } )
|
defaultRoute='via 10.0.0.1' )
|
||||||
|
self.addLink( h1, router, intfName2='r0-eth1',
|
||||||
|
params2={ 'ip' : '192.168.1.1/24' } )
|
||||||
|
self.addLink( h2, router, intfName2='r0-eth2',
|
||||||
|
params2={ 'ip' : '172.16.0.1/12' } )
|
||||||
|
self.addLink( h3, router, intfName2='r0-eth3',
|
||||||
|
params2={ 'ip' : '10.0.0.1/8' } )
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
"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()
|
||||||
|
|||||||
+71
-58
@@ -13,6 +13,9 @@ Controller icon from http://semlabs.co.uk/
|
|||||||
OpenFlow icon from https://www.opennetworking.org/
|
OpenFlow icon from https://www.opennetworking.org/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# For now, tolerate long lines and long module
|
||||||
|
# pylint: disable=line-too-long,too-many-lines
|
||||||
|
|
||||||
MINIEDIT_VERSION = '2.2.0.1'
|
MINIEDIT_VERSION = '2.2.0.1'
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
@@ -83,34 +86,38 @@ HOSTS = { 'proc': Host,
|
|||||||
|
|
||||||
|
|
||||||
class InbandController( RemoteController ):
|
class InbandController( RemoteController ):
|
||||||
|
"RemoteController that ignores checkListening"
|
||||||
def checkListening( self ):
|
def checkListening( self ):
|
||||||
"Overridden to do nothing."
|
"Overridden to do nothing."
|
||||||
return
|
return
|
||||||
|
|
||||||
class CustomUserSwitch(UserSwitch):
|
class CustomUserSwitch(UserSwitch):
|
||||||
|
"Customized UserSwitch"
|
||||||
def __init__( self, name, dpopts='--no-slicing', **kwargs ):
|
def __init__( self, name, dpopts='--no-slicing', **kwargs ):
|
||||||
UserSwitch.__init__( self, name, **kwargs )
|
UserSwitch.__init__( self, name, **kwargs )
|
||||||
self.switchIP = None
|
self.switchIP = None
|
||||||
|
|
||||||
def getSwitchIP(self):
|
def getSwitchIP(self):
|
||||||
|
"Return management IP address"
|
||||||
return self.switchIP
|
return self.switchIP
|
||||||
|
|
||||||
def setSwitchIP(self, ip):
|
def setSwitchIP(self, ip):
|
||||||
|
"Set management IP address"
|
||||||
self.switchIP = ip
|
self.switchIP = ip
|
||||||
|
|
||||||
def start( self, controllers ):
|
def start( self, controllers ):
|
||||||
|
"Start and set management IP address"
|
||||||
# Call superclass constructor
|
# Call superclass constructor
|
||||||
UserSwitch.start( self, controllers )
|
UserSwitch.start( self, controllers )
|
||||||
# Set Switch IP address
|
# Set Switch IP address
|
||||||
if (self.switchIP is not None):
|
if self.switchIP is not None:
|
||||||
if not self.inNamespace:
|
if not self.inNamespace:
|
||||||
self.cmd( 'ifconfig', self, self.switchIP )
|
self.cmd( 'ifconfig', self, self.switchIP )
|
||||||
else:
|
else:
|
||||||
self.cmd( 'ifconfig lo', self.switchIP )
|
self.cmd( 'ifconfig lo', self.switchIP )
|
||||||
|
|
||||||
class LegacyRouter( Node ):
|
class LegacyRouter( Node ):
|
||||||
|
"Simple IP router"
|
||||||
def __init__( self, name, inNamespace=True, **params ):
|
def __init__( self, name, inNamespace=True, **params ):
|
||||||
Node.__init__( self, name, inNamespace, **params )
|
Node.__init__( self, name, inNamespace, **params )
|
||||||
|
|
||||||
@@ -122,31 +129,36 @@ class LegacyRouter( Node ):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
class LegacySwitch(OVSSwitch):
|
class LegacySwitch(OVSSwitch):
|
||||||
|
"OVS switch in standalone/bridge mode"
|
||||||
def __init__( self, name, **params ):
|
def __init__( self, name, **params ):
|
||||||
OVSSwitch.__init__( self, name, failMode='standalone', **params )
|
OVSSwitch.__init__( self, name, failMode='standalone', **params )
|
||||||
self.switchIP = None
|
self.switchIP = None
|
||||||
|
|
||||||
class customOvs(OVSSwitch):
|
class customOvs(OVSSwitch):
|
||||||
|
"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):
|
||||||
|
"Return management IP address"
|
||||||
return self.switchIP
|
return self.switchIP
|
||||||
|
|
||||||
def setSwitchIP(self, ip):
|
def setSwitchIP(self, ip):
|
||||||
|
"Set management IP address"
|
||||||
self.switchIP = ip
|
self.switchIP = ip
|
||||||
|
|
||||||
def start( self, controllers ):
|
def start( self, controllers ):
|
||||||
|
"Start and set management IP address"
|
||||||
# Call superclass constructor
|
# Call superclass constructor
|
||||||
OVSSwitch.start( self, controllers )
|
OVSSwitch.start( self, controllers )
|
||||||
# Set Switch IP address
|
# Set Switch IP address
|
||||||
if (self.switchIP is not None):
|
if self.switchIP is not None:
|
||||||
self.cmd( 'ifconfig', self, self.switchIP )
|
self.cmd( 'ifconfig', self, self.switchIP )
|
||||||
|
|
||||||
class PrefsDialog(tkSimpleDialog.Dialog):
|
class PrefsDialog(tkSimpleDialog.Dialog):
|
||||||
|
"Preferences dialog"
|
||||||
|
|
||||||
def __init__(self, parent, title, prefDefaults):
|
def __init__(self, parent, title, prefDefaults):
|
||||||
|
|
||||||
@@ -155,13 +167,13 @@ class PrefsDialog(tkSimpleDialog.Dialog):
|
|||||||
tkSimpleDialog.Dialog.__init__(self, parent, title)
|
tkSimpleDialog.Dialog.__init__(self, parent, title)
|
||||||
|
|
||||||
def body(self, master):
|
def body(self, master):
|
||||||
|
"Create dialog body"
|
||||||
self.rootFrame = master
|
self.rootFrame = master
|
||||||
self.leftfieldFrame = Frame(self.rootFrame, padx=5, pady=5)
|
self.leftfieldFrame = Frame(self.rootFrame, padx=5, pady=5)
|
||||||
self.leftfieldFrame.grid(row=0, column=0, sticky='nswe', columnspan=2)
|
self.leftfieldFrame.grid(row=0, column=0, sticky='nswe', columnspan=2)
|
||||||
self.rightfieldFrame = Frame(self.rootFrame, padx=5, pady=5)
|
self.rightfieldFrame = Frame(self.rootFrame, padx=5, pady=5)
|
||||||
self.rightfieldFrame.grid(row=0, column=2, sticky='nswe', columnspan=2)
|
self.rightfieldFrame.grid(row=0, column=2, sticky='nswe', columnspan=2)
|
||||||
|
|
||||||
|
|
||||||
# Field for Base IP
|
# Field for Base IP
|
||||||
Label(self.leftfieldFrame, text="IP Base:").grid(row=0, sticky=E)
|
Label(self.leftfieldFrame, text="IP Base:").grid(row=0, sticky=E)
|
||||||
self.ipEntry = Entry(self.leftfieldFrame)
|
self.ipEntry = Entry(self.leftfieldFrame)
|
||||||
@@ -363,6 +375,7 @@ class PrefsDialog(tkSimpleDialog.Dialog):
|
|||||||
self.result = None
|
self.result = None
|
||||||
|
|
||||||
def getOvsVersion(self):
|
def getOvsVersion(self):
|
||||||
|
"Return OVS version"
|
||||||
outp = quietRun("ovs-vsctl show")
|
outp = quietRun("ovs-vsctl show")
|
||||||
r = r'ovs_version: "(.*)"'
|
r = r'ovs_version: "(.*)"'
|
||||||
m = re.search(r, outp)
|
m = re.search(r, outp)
|
||||||
@@ -572,8 +585,8 @@ class HostDialog(CustomDialog):
|
|||||||
vlanInterfaces.append([self.vlanTableFrame.get(row, 0), self.vlanTableFrame.get(row, 1)])
|
vlanInterfaces.append([self.vlanTableFrame.get(row, 0), self.vlanTableFrame.get(row, 1)])
|
||||||
privateDirectories = []
|
privateDirectories = []
|
||||||
for row in range(self.mountTableFrame.rows):
|
for row in range(self.mountTableFrame.rows):
|
||||||
if (len(self.mountTableFrame.get(row, 0)) > 0 and row > 0):
|
if len(self.mountTableFrame.get(row, 0)) > 0 and row > 0:
|
||||||
if(len(self.mountTableFrame.get(row, 1)) > 0):
|
if len(self.mountTableFrame.get(row, 1)) > 0:
|
||||||
privateDirectories.append((self.mountTableFrame.get(row, 0), self.mountTableFrame.get(row, 1)))
|
privateDirectories.append((self.mountTableFrame.get(row, 0), self.mountTableFrame.get(row, 1)))
|
||||||
else:
|
else:
|
||||||
privateDirectories.append(self.mountTableFrame.get(row, 0))
|
privateDirectories.append(self.mountTableFrame.get(row, 0))
|
||||||
@@ -739,7 +752,7 @@ class SwitchDialog(CustomDialog):
|
|||||||
externalInterfaces = []
|
externalInterfaces = []
|
||||||
for row in range(self.tableFrame.rows):
|
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):
|
if len(self.tableFrame.get(row, 0)) > 0:
|
||||||
externalInterfaces.append(self.tableFrame.get(row, 0))
|
externalInterfaces.append(self.tableFrame.get(row, 0))
|
||||||
|
|
||||||
dpid = self.dpidEntry.get()
|
dpid = self.dpidEntry.get()
|
||||||
@@ -856,7 +869,7 @@ class TableFrame(Frame):
|
|||||||
label.grid(row=self.rows, column=column, sticky="wens", padx=1, pady=1)
|
label.grid(row=self.rows, column=column, sticky="wens", padx=1, pady=1)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
label.insert(0, value[column])
|
label.insert(0, value[column])
|
||||||
if (readonly == True):
|
if readonly == True:
|
||||||
label.configure(state='readonly')
|
label.configure(state='readonly')
|
||||||
current_row.append(label)
|
current_row.append(label)
|
||||||
self._widgets.append(current_row)
|
self._widgets.append(current_row)
|
||||||
@@ -916,17 +929,17 @@ class LinkDialog(tkSimpleDialog.Dialog):
|
|||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
self.result = {}
|
self.result = {}
|
||||||
if (len(self.e1.get()) > 0):
|
if len(self.e1.get()) > 0:
|
||||||
self.result['bw'] = int(self.e1.get())
|
self.result['bw'] = int(self.e1.get())
|
||||||
if (len(self.e2.get()) > 0):
|
if len(self.e2.get()) > 0:
|
||||||
self.result['delay'] = self.e2.get()
|
self.result['delay'] = self.e2.get()
|
||||||
if (len(self.e3.get()) > 0):
|
if len(self.e3.get()) > 0:
|
||||||
self.result['loss'] = int(self.e3.get())
|
self.result['loss'] = int(self.e3.get())
|
||||||
if (len(self.e4.get()) > 0):
|
if len(self.e4.get()) > 0:
|
||||||
self.result['max_queue_size'] = int(self.e4.get())
|
self.result['max_queue_size'] = int(self.e4.get())
|
||||||
if (len(self.e5.get()) > 0):
|
if len(self.e5.get()) > 0:
|
||||||
self.result['jitter'] = self.e5.get()
|
self.result['jitter'] = self.e5.get()
|
||||||
if (len(self.e6.get()) > 0):
|
if len(self.e6.get()) > 0:
|
||||||
self.result['speedup'] = int(self.e6.get())
|
self.result['speedup'] = int(self.e6.get())
|
||||||
|
|
||||||
class ControllerDialog(tkSimpleDialog.Dialog):
|
class ControllerDialog(tkSimpleDialog.Dialog):
|
||||||
@@ -1427,8 +1440,8 @@ class MiniEdit( Frame ):
|
|||||||
self.appPrefs["netflow"] = self.nflowDefaults
|
self.appPrefs["netflow"] = self.nflowDefaults
|
||||||
|
|
||||||
# Load controllers
|
# Load controllers
|
||||||
if ('controllers' in loadedTopology):
|
if 'controllers' in loadedTopology:
|
||||||
if (loadedTopology['version'] == '1'):
|
if loadedTopology['version'] == '1':
|
||||||
# This is old location of controller info
|
# This is old location of controller info
|
||||||
hostname = 'c0'
|
hostname = 'c0'
|
||||||
self.controllers = {}
|
self.controllers = {}
|
||||||
@@ -1509,7 +1522,7 @@ class MiniEdit( Frame ):
|
|||||||
self.switchOpts[hostname] = switch['opts']
|
self.switchOpts[hostname] = switch['opts']
|
||||||
|
|
||||||
# create links to controllers
|
# create links to controllers
|
||||||
if (int(loadedTopology['version']) > 1):
|
if int(loadedTopology['version']) > 1:
|
||||||
controllers = self.switchOpts[hostname]['controllers']
|
controllers = self.switchOpts[hostname]['controllers']
|
||||||
for controller in controllers:
|
for controller in controllers:
|
||||||
dest = self.findWidgetByName(controller)
|
dest = self.findWidgetByName(controller)
|
||||||
@@ -1774,7 +1787,7 @@ class MiniEdit( Frame ):
|
|||||||
if 'dpid' in opts:
|
if 'dpid' in opts:
|
||||||
f.write(", dpid='"+opts['dpid']+"'")
|
f.write(", dpid='"+opts['dpid']+"'")
|
||||||
f.write(")\n")
|
f.write(")\n")
|
||||||
if ('externalInterfaces' in opts):
|
if 'externalInterfaces' in opts:
|
||||||
for extInterface in opts['externalInterfaces']:
|
for extInterface in opts['externalInterfaces']:
|
||||||
f.write(" Intf( '"+extInterface+"', node="+name+" )\n")
|
f.write(" Intf( '"+extInterface+"', node="+name+" )\n")
|
||||||
|
|
||||||
@@ -1806,7 +1819,7 @@ class MiniEdit( Frame ):
|
|||||||
f.write(" "+name+".setCPUFrac(f="+str(opts['cpu'])+", sched='"+opts['sched']+"')\n")
|
f.write(" "+name+".setCPUFrac(f="+str(opts['cpu'])+", sched='"+opts['sched']+"')\n")
|
||||||
else:
|
else:
|
||||||
f.write(" "+name+" = net.addHost('"+name+"', cls=Host, ip='"+ip+"', defaultRoute="+defaultRoute+")\n")
|
f.write(" "+name+" = net.addHost('"+name+"', cls=Host, ip='"+ip+"', defaultRoute="+defaultRoute+")\n")
|
||||||
if ('externalInterfaces' in opts):
|
if 'externalInterfaces' in opts:
|
||||||
for extInterface in opts['externalInterfaces']:
|
for extInterface in opts['externalInterfaces']:
|
||||||
f.write(" Intf( '"+extInterface+"', node="+name+" )\n")
|
f.write(" Intf( '"+extInterface+"', node="+name+" )\n")
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
@@ -1893,28 +1906,28 @@ class MiniEdit( Frame ):
|
|||||||
opts = self.switchOpts[name]
|
opts = self.switchOpts[name]
|
||||||
if opts['switchType'] == 'default':
|
if opts['switchType'] == 'default':
|
||||||
if self.appPrefs['switchType'] == 'user':
|
if self.appPrefs['switchType'] == 'user':
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP'])>0):
|
if len(opts['switchIP']) > 0:
|
||||||
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
||||||
elif self.appPrefs['switchType'] == 'userns':
|
elif self.appPrefs['switchType'] == 'userns':
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP'])>0):
|
if len(opts['switchIP']) > 0:
|
||||||
f.write(" "+name+".cmd('ifconfig lo "+opts['switchIP']+"')\n")
|
f.write(" "+name+".cmd('ifconfig lo "+opts['switchIP']+"')\n")
|
||||||
elif self.appPrefs['switchType'] == 'ovs':
|
elif self.appPrefs['switchType'] == 'ovs':
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP'])>0):
|
if len(opts['switchIP']) > 0:
|
||||||
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
||||||
elif opts['switchType'] == 'user':
|
elif opts['switchType'] == 'user':
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP'])>0):
|
if len(opts['switchIP']) > 0:
|
||||||
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
||||||
elif opts['switchType'] == 'userns':
|
elif opts['switchType'] == 'userns':
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP'])>0):
|
if len(opts['switchIP']) > 0:
|
||||||
f.write(" "+name+".cmd('ifconfig lo "+opts['switchIP']+"')\n")
|
f.write(" "+name+".cmd('ifconfig lo "+opts['switchIP']+"')\n")
|
||||||
elif opts['switchType'] == 'ovs':
|
elif opts['switchType'] == 'ovs':
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP'])>0):
|
if len(opts['switchIP']) > 0:
|
||||||
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
f.write(" "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
|
||||||
for widget in self.widgetToItem:
|
for widget in self.widgetToItem:
|
||||||
name = widget[ 'text' ]
|
name = widget[ 'text' ]
|
||||||
@@ -1922,17 +1935,17 @@ class MiniEdit( Frame ):
|
|||||||
if 'Host' in tags:
|
if 'Host' in tags:
|
||||||
opts = self.hostOpts[name]
|
opts = self.hostOpts[name]
|
||||||
# Attach vlan interfaces
|
# Attach vlan interfaces
|
||||||
if ('vlanInterfaces' in opts):
|
if 'vlanInterfaces' in opts:
|
||||||
for vlanInterface in opts['vlanInterfaces']:
|
for vlanInterface in opts['vlanInterfaces']:
|
||||||
f.write(" "+name+".cmd('vconfig add "+name+"-eth0 "+vlanInterface[1]+"')\n")
|
f.write(" "+name+".cmd('vconfig add "+name+"-eth0 "+vlanInterface[1]+"')\n")
|
||||||
f.write(" "+name+".cmd('ifconfig "+name+"-eth0."+vlanInterface[1]+" "+vlanInterface[0]+"')\n")
|
f.write(" "+name+".cmd('ifconfig "+name+"-eth0."+vlanInterface[1]+" "+vlanInterface[0]+"')\n")
|
||||||
# Run User Defined Start Command
|
# Run User Defined Start Command
|
||||||
if ('startCommand' in opts):
|
if 'startCommand' in opts:
|
||||||
f.write(" "+name+".cmdPrint('"+opts['startCommand']+"')\n")
|
f.write(" "+name+".cmdPrint('"+opts['startCommand']+"')\n")
|
||||||
if 'Switch' in tags:
|
if 'Switch' in tags:
|
||||||
opts = self.switchOpts[name]
|
opts = self.switchOpts[name]
|
||||||
# Run User Defined Start Command
|
# Run User Defined Start Command
|
||||||
if ('startCommand' in opts):
|
if 'startCommand' in opts:
|
||||||
f.write(" "+name+".cmdPrint('"+opts['startCommand']+"')\n")
|
f.write(" "+name+".cmdPrint('"+opts['startCommand']+"')\n")
|
||||||
|
|
||||||
# Configure NetFlow
|
# Configure NetFlow
|
||||||
@@ -1987,12 +2000,12 @@ class MiniEdit( Frame ):
|
|||||||
if 'Host' in tags:
|
if 'Host' in tags:
|
||||||
opts = self.hostOpts[name]
|
opts = self.hostOpts[name]
|
||||||
# Run User Defined Stop Command
|
# Run User Defined Stop Command
|
||||||
if ('stopCommand' in opts):
|
if 'stopCommand' in opts:
|
||||||
f.write(" "+name+".cmdPrint('"+opts['stopCommand']+"')\n")
|
f.write(" "+name+".cmdPrint('"+opts['stopCommand']+"')\n")
|
||||||
if 'Switch' in tags:
|
if 'Switch' in tags:
|
||||||
opts = self.switchOpts[name]
|
opts = self.switchOpts[name]
|
||||||
# Run User Defined Stop Command
|
# Run User Defined Stop Command
|
||||||
if ('stopCommand' in opts):
|
if 'stopCommand' in opts:
|
||||||
f.write(" "+name+".cmdPrint('"+opts['stopCommand']+"')\n")
|
f.write(" "+name+".cmdPrint('"+opts['stopCommand']+"')\n")
|
||||||
|
|
||||||
f.write(" net.stop()\n")
|
f.write(" net.stop()\n")
|
||||||
@@ -2725,16 +2738,16 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
# Some post startup config
|
# Some post startup config
|
||||||
if switchClass == CustomUserSwitch:
|
if switchClass == CustomUserSwitch:
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP']) > 0):
|
if len(opts['switchIP']) > 0:
|
||||||
newSwitch.setSwitchIP(opts['switchIP'])
|
newSwitch.setSwitchIP(opts['switchIP'])
|
||||||
if switchClass == customOvs:
|
if switchClass == customOvs:
|
||||||
if ('switchIP' in opts):
|
if 'switchIP' in opts:
|
||||||
if (len(opts['switchIP']) > 0):
|
if len(opts['switchIP']) > 0:
|
||||||
newSwitch.setSwitchIP(opts['switchIP'])
|
newSwitch.setSwitchIP(opts['switchIP'])
|
||||||
|
|
||||||
# Attach external interfaces
|
# Attach external interfaces
|
||||||
if ('externalInterfaces' in opts):
|
if 'externalInterfaces' in opts:
|
||||||
for extInterface in opts['externalInterfaces']:
|
for extInterface in opts['externalInterfaces']:
|
||||||
if self.checkIntf(extInterface):
|
if self.checkIntf(extInterface):
|
||||||
Intf( extInterface, node=newSwitch )
|
Intf( extInterface, node=newSwitch )
|
||||||
@@ -2759,13 +2772,13 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
# Create the correct host class
|
# Create the correct host class
|
||||||
if 'cores' in opts or 'cpu' in opts:
|
if 'cores' in opts or 'cpu' in opts:
|
||||||
if ('privateDirectory' in opts):
|
if 'privateDirectory' in opts:
|
||||||
hostCls = partial( CPULimitedHost,
|
hostCls = partial( CPULimitedHost,
|
||||||
privateDirs=opts['privateDirectory'] )
|
privateDirs=opts['privateDirectory'] )
|
||||||
else:
|
else:
|
||||||
hostCls=CPULimitedHost
|
hostCls=CPULimitedHost
|
||||||
else:
|
else:
|
||||||
if ('privateDirectory' in opts):
|
if 'privateDirectory' in opts:
|
||||||
hostCls = partial( Host,
|
hostCls = partial( Host,
|
||||||
privateDirs=opts['privateDirectory'] )
|
privateDirs=opts['privateDirectory'] )
|
||||||
else:
|
else:
|
||||||
@@ -2784,11 +2797,11 @@ class MiniEdit( Frame ):
|
|||||||
newHost.setCPUFrac(f=opts['cpu'], sched=opts['sched'])
|
newHost.setCPUFrac(f=opts['cpu'], sched=opts['sched'])
|
||||||
|
|
||||||
# Attach external interfaces
|
# Attach external interfaces
|
||||||
if ('externalInterfaces' in opts):
|
if 'externalInterfaces' in opts:
|
||||||
for extInterface in opts['externalInterfaces']:
|
for extInterface in opts['externalInterfaces']:
|
||||||
if self.checkIntf(extInterface):
|
if self.checkIntf(extInterface):
|
||||||
Intf( extInterface, node=newHost )
|
Intf( extInterface, node=newHost )
|
||||||
if ('vlanInterfaces' in opts):
|
if 'vlanInterfaces' in opts:
|
||||||
if len(opts['vlanInterfaces']) > 0:
|
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')
|
self.pathCheck('vconfig', moduleName='vlan package')
|
||||||
@@ -2894,18 +2907,18 @@ class MiniEdit( Frame ):
|
|||||||
newHost = self.net.get(name)
|
newHost = self.net.get(name)
|
||||||
opts = self.hostOpts[name]
|
opts = self.hostOpts[name]
|
||||||
# Attach vlan interfaces
|
# Attach vlan interfaces
|
||||||
if ('vlanInterfaces' in opts):
|
if 'vlanInterfaces' in opts:
|
||||||
for vlanInterface in opts['vlanInterfaces']:
|
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])
|
newHost.cmdPrint('ifconfig '+name+'-eth0.'+vlanInterface[1]+' '+vlanInterface[0])
|
||||||
# Run User Defined Start Command
|
# Run User Defined Start Command
|
||||||
if ('startCommand' in opts):
|
if 'startCommand' in opts:
|
||||||
newHost.cmdPrint(opts['startCommand'])
|
newHost.cmdPrint(opts['startCommand'])
|
||||||
if 'Switch' in tags:
|
if 'Switch' in tags:
|
||||||
newNode = self.net.get(name)
|
newNode = self.net.get(name)
|
||||||
opts = self.switchOpts[name]
|
opts = self.switchOpts[name]
|
||||||
# Run User Defined Start Command
|
# Run User Defined Start Command
|
||||||
if ('startCommand' in opts):
|
if 'startCommand' in opts:
|
||||||
newNode.cmdPrint(opts['startCommand'])
|
newNode.cmdPrint(opts['startCommand'])
|
||||||
|
|
||||||
|
|
||||||
@@ -3018,13 +3031,13 @@ class MiniEdit( Frame ):
|
|||||||
newHost = self.net.get(name)
|
newHost = self.net.get(name)
|
||||||
opts = self.hostOpts[name]
|
opts = self.hostOpts[name]
|
||||||
# Run User Defined Stop Command
|
# Run User Defined Stop Command
|
||||||
if ('stopCommand' in opts):
|
if 'stopCommand' in opts:
|
||||||
newHost.cmdPrint(opts['stopCommand'])
|
newHost.cmdPrint(opts['stopCommand'])
|
||||||
if 'Switch' in tags:
|
if 'Switch' in tags:
|
||||||
newNode = self.net.get(name)
|
newNode = self.net.get(name)
|
||||||
opts = self.switchOpts[name]
|
opts = self.switchOpts[name]
|
||||||
# Run User Defined Stop Command
|
# Run User Defined Stop Command
|
||||||
if ('stopCommand' in opts):
|
if 'stopCommand' in opts:
|
||||||
newNode.cmdPrint(opts['stopCommand'])
|
newNode.cmdPrint(opts['stopCommand'])
|
||||||
|
|
||||||
self.net.stop()
|
self.net.stop()
|
||||||
@@ -3033,7 +3046,7 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
def do_linkPopup(self, event):
|
def do_linkPopup(self, event):
|
||||||
# display the popup menu
|
# display the popup menu
|
||||||
if ( self.net is None ):
|
if self.net is None:
|
||||||
try:
|
try:
|
||||||
self.linkPopup.tk_popup(event.x_root, event.y_root, 0)
|
self.linkPopup.tk_popup(event.x_root, event.y_root, 0)
|
||||||
finally:
|
finally:
|
||||||
@@ -3048,7 +3061,7 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
def do_controllerPopup(self, event):
|
def do_controllerPopup(self, event):
|
||||||
# display the popup menu
|
# display the popup menu
|
||||||
if ( self.net is None ):
|
if self.net is None:
|
||||||
try:
|
try:
|
||||||
self.controllerPopup.tk_popup(event.x_root, event.y_root, 0)
|
self.controllerPopup.tk_popup(event.x_root, event.y_root, 0)
|
||||||
finally:
|
finally:
|
||||||
@@ -3057,7 +3070,7 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
def do_legacyRouterPopup(self, event):
|
def do_legacyRouterPopup(self, event):
|
||||||
# display the popup menu
|
# display the popup menu
|
||||||
if ( self.net is not None ):
|
if self.net is not None:
|
||||||
try:
|
try:
|
||||||
self.legacyRouterRunPopup.tk_popup(event.x_root, event.y_root, 0)
|
self.legacyRouterRunPopup.tk_popup(event.x_root, event.y_root, 0)
|
||||||
finally:
|
finally:
|
||||||
@@ -3066,7 +3079,7 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
def do_hostPopup(self, event):
|
def do_hostPopup(self, event):
|
||||||
# display the popup menu
|
# display the popup menu
|
||||||
if ( self.net is None ):
|
if self.net is None:
|
||||||
try:
|
try:
|
||||||
self.hostPopup.tk_popup(event.x_root, event.y_root, 0)
|
self.hostPopup.tk_popup(event.x_root, event.y_root, 0)
|
||||||
finally:
|
finally:
|
||||||
@@ -3081,7 +3094,7 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
def do_legacySwitchPopup(self, event):
|
def do_legacySwitchPopup(self, event):
|
||||||
# display the popup menu
|
# display the popup menu
|
||||||
if ( self.net is not None ):
|
if self.net is not None:
|
||||||
try:
|
try:
|
||||||
self.switchRunPopup.tk_popup(event.x_root, event.y_root, 0)
|
self.switchRunPopup.tk_popup(event.x_root, event.y_root, 0)
|
||||||
finally:
|
finally:
|
||||||
@@ -3090,7 +3103,7 @@ class MiniEdit( Frame ):
|
|||||||
|
|
||||||
def do_switchPopup(self, event):
|
def do_switchPopup(self, event):
|
||||||
# display the popup menu
|
# display the popup menu
|
||||||
if ( self.net is None ):
|
if self.net is None:
|
||||||
try:
|
try:
|
||||||
self.switchPopup.tk_popup(event.x_root, event.y_root, 0)
|
self.switchPopup.tk_popup(event.x_root, event.y_root, 0)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from mininet.net import Mininet
|
|||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
|
|
||||||
def runMultiLink():
|
def runMultiLink():
|
||||||
|
"Create and run multiple link network"
|
||||||
topo = simpleMultiLinkTopo( n=2 )
|
topo = simpleMultiLinkTopo( n=2 )
|
||||||
net = Mininet( topo=topo )
|
net = Mininet( topo=topo )
|
||||||
net.start()
|
net.start()
|
||||||
@@ -19,6 +19,7 @@ def runMultiLink():
|
|||||||
net.stop()
|
net.stop()
|
||||||
|
|
||||||
class simpleMultiLinkTopo( Topo ):
|
class simpleMultiLinkTopo( Topo ):
|
||||||
|
"Simple topology with multiple links"
|
||||||
|
|
||||||
def __init__( self, n, **kwargs ):
|
def __init__( self, n, **kwargs ):
|
||||||
Topo.__init__( self, **kwargs )
|
Topo.__init__( self, **kwargs )
|
||||||
|
|||||||
+1
-2
@@ -27,7 +27,7 @@ from mininet.util import irange
|
|||||||
|
|
||||||
class InternetTopo(Topo):
|
class InternetTopo(Topo):
|
||||||
"Single switch connected to n hosts."
|
"Single switch connected to n hosts."
|
||||||
def __init__(self, n=2, h=1, **opts):
|
def __init__(self, n=2, **opts):
|
||||||
Topo.__init__(self, **opts)
|
Topo.__init__(self, **opts)
|
||||||
|
|
||||||
# set up inet switch
|
# set up inet switch
|
||||||
@@ -67,4 +67,3 @@ def run():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel('info')
|
setLogLevel('info')
|
||||||
run()
|
run()
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,12 @@ def validatePort( switch, intf ):
|
|||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def net():
|
def testPortNumbering():
|
||||||
|
|
||||||
"Create a network with 5 hosts."
|
"""Test port numbering:
|
||||||
|
Create a network with 5 hosts (using Mininet's
|
||||||
|
mid-level API) and check that implicit and
|
||||||
|
explicit port numbering works as expected."""
|
||||||
|
|
||||||
net = Mininet( controller=Controller )
|
net = Mininet( controller=Controller )
|
||||||
|
|
||||||
@@ -45,18 +48,21 @@ def net():
|
|||||||
net.addLink( h2, s1 )
|
net.addLink( h2, s1 )
|
||||||
net.addLink( h3, s1 )
|
net.addLink( h3, s1 )
|
||||||
net.addLink( h4, s1 )
|
net.addLink( h4, s1 )
|
||||||
net.addLink( h5, s1, port1 = 1, port2 = 9 ) # specify a different port to connect host 5 to on the switch.
|
# specify a different port to connect host 5 to on the switch.
|
||||||
|
net.addLink( h5, s1, port1=1, port2= 9)
|
||||||
|
|
||||||
info( '*** Starting network\n' )
|
info( '*** Starting network\n' )
|
||||||
net.start()
|
net.start()
|
||||||
|
|
||||||
# print the interfaces and their port numbers
|
# print the interfaces and their port numbers
|
||||||
info( '\n*** printing and validating the ports running on each interface\n' )
|
info( '\n*** printing and validating the ports '
|
||||||
|
'running on each interface\n' )
|
||||||
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, 'is actually on port', s1.ports[intfs], '... ' )
|
info ( 'Validating that', intfs,
|
||||||
|
'is actually on port', s1.ports[intfs], '... ' )
|
||||||
if validatePort( s1, intfs ):
|
if validatePort( s1, intfs ):
|
||||||
info( 'Validated.\n' )
|
info( 'Validated.\n' )
|
||||||
print '\n'
|
print '\n'
|
||||||
@@ -70,5 +76,4 @@ def net():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
net()
|
testPortNumbering()
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -81,6 +81,6 @@ if __name__ == '__main__':
|
|||||||
net = TreeNet( depth=1, fanout=4 )
|
net = TreeNet( depth=1, fanout=4 )
|
||||||
# get sshd args from the command line or use default args
|
# get sshd args from the command line or use default args
|
||||||
# useDNS=no -u0 to avoid reverse DNS lookup timeout
|
# useDNS=no -u0 to avoid reverse DNS lookup timeout
|
||||||
opts = ' '.join( sys.argv[ 1: ] ) if len( sys.argv ) > 1 else (
|
argvopts = ' '.join( sys.argv[ 1: ] ) if len( sys.argv ) > 1 else (
|
||||||
'-D -o UseDNS=no -u0' )
|
'-D -o UseDNS=no -u0' )
|
||||||
sshd( net, opts=opts )
|
sshd( net, opts=argvopts )
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class VLANHost( Host ):
|
|||||||
"""Configure VLANHost according to (optional) parameters:
|
"""Configure VLANHost according to (optional) parameters:
|
||||||
vlan: VLAN ID for default interface"""
|
vlan: VLAN ID for default interface"""
|
||||||
|
|
||||||
r = super( Host, self ).config( **params )
|
r = super( VLANHost, self ).config( **params )
|
||||||
|
|
||||||
intf = self.defaultIntf()
|
intf = self.defaultIntf()
|
||||||
# remove IP from default, "physical" interface
|
# remove IP from default, "physical" interface
|
||||||
|
|||||||
+1
-3
@@ -727,9 +727,7 @@ class Mininet( object ):
|
|||||||
if not quietRun( 'which telnet' ):
|
if not quietRun( 'which telnet' ):
|
||||||
error( 'Cannot find telnet in $PATH - required for iperf test' )
|
error( 'Cannot find telnet in $PATH - required for iperf test' )
|
||||||
return
|
return
|
||||||
if not hosts:
|
hosts = hosts or [ self.hosts[ 0 ], self.hosts[ -1 ] ]
|
||||||
hosts = [ self.hosts[ 0 ], self.hosts[ -1 ] ]
|
|
||||||
else:
|
|
||||||
assert len( hosts ) == 2
|
assert len( hosts ) == 2
|
||||||
client, server = hosts
|
client, server = hosts
|
||||||
output( '*** Iperf: testing ' + l4Type + ' bandwidth between ' )
|
output( '*** Iperf: testing ' + l4Type + ' bandwidth between ' )
|
||||||
|
|||||||
+3
-6
@@ -888,8 +888,9 @@ class Switch( Node ):
|
|||||||
|
|
||||||
def connected( self ):
|
def connected( self ):
|
||||||
"Is the switch connected to a controller? (override this method)"
|
"Is the switch connected to a controller? (override this method)"
|
||||||
raise NotImplementedError( "connected() needs to be implemented in"
|
warn( "Warning: connected() needs to be implemented in"
|
||||||
" Switch subclass %s" % self.__class__ )
|
" Switch subclass %s\n" % self.__class__ )
|
||||||
|
return True
|
||||||
|
|
||||||
def __repr__( self ):
|
def __repr__( self ):
|
||||||
"More informative string representation"
|
"More informative string representation"
|
||||||
@@ -1290,10 +1291,6 @@ class IVSSwitch( Switch ):
|
|||||||
return self.cmd( 'ovs-ofctl ' + ' '.join( args ) +
|
return self.cmd( 'ovs-ofctl ' + ' '.join( args ) +
|
||||||
' tcp:127.0.0.1:%i' % self.listenPort )
|
' tcp:127.0.0.1:%i' % self.listenPort )
|
||||||
|
|
||||||
def connected( self ):
|
|
||||||
"For now, return True since we can't tell if we're connected"
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class Controller( Node ):
|
class Controller( Node ):
|
||||||
"""A Controller is a Node that is running (or has execed?) an
|
"""A Controller is a Node that is running (or has execed?) an
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ def runTests( testDir, verbosity=1 ):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'warning' )
|
setLogLevel( 'warning' )
|
||||||
# get the directory containing example tests
|
# get the directory containing example tests
|
||||||
testDir = os.path.dirname( os.path.realpath( __file__ ) )
|
thisdir = os.path.dirname( os.path.realpath( __file__ ) )
|
||||||
verbosity = 2 if '-v' in sys.argv else 1
|
vlevel = 2 if '-v' in sys.argv else 1
|
||||||
runTests( testDir, verbosity )
|
runTests( testDir=thisdir, verbosity=vlevel )
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class testOptionsTopoCommon( object ):
|
|||||||
|
|
||||||
switchClass = None # overridden in subclasses
|
switchClass = None # overridden in subclasses
|
||||||
|
|
||||||
def tearDown( self ):
|
@staticmethod
|
||||||
|
def tearDown():
|
||||||
"Clean up if necessary"
|
"Clean up if necessary"
|
||||||
if sys.exc_info != ( None, None, None ):
|
if sys.exc_info != ( None, None, None ):
|
||||||
cleanup()
|
cleanup()
|
||||||
@@ -151,7 +152,7 @@ class testOptionsTopoCommon( object ):
|
|||||||
# As long as the kernel doesn't wait a long time before
|
# As long as the kernel doesn't wait a long time before
|
||||||
# delivering bytes to the iperf server, its reported data rate
|
# delivering bytes to the iperf server, its reported data rate
|
||||||
# should be close to the actual receive rate.
|
# should be close to the actual receive rate.
|
||||||
serverRate, clientRate = bw_strs
|
serverRate, _clientRate = bw_strs
|
||||||
bw = float( serverRate.split(' ')[0] )
|
bw = float( serverRate.split(' ')[0] )
|
||||||
self.assertWithinTolerance( bw, BW, BW_TOLERANCE, msg )
|
self.assertWithinTolerance( bw, BW, BW_TOLERANCE, msg )
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ class testSingleSwitchCommon( object ):
|
|||||||
|
|
||||||
switchClass = None # overridden in subclasses
|
switchClass = None # overridden in subclasses
|
||||||
|
|
||||||
def tearDown( self ):
|
@staticmethod
|
||||||
|
def tearDown():
|
||||||
"Clean up if necessary"
|
"Clean up if necessary"
|
||||||
if sys.exc_info != ( None, None, None ):
|
if sys.exc_info != ( None, None, None ):
|
||||||
cleanup()
|
cleanup()
|
||||||
@@ -74,7 +75,8 @@ class testLinearCommon( object ):
|
|||||||
|
|
||||||
def testLinear5( self ):
|
def testLinear5( self ):
|
||||||
"Ping test on a 5-switch topology"
|
"Ping test on a 5-switch topology"
|
||||||
mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host, Controller, waitConnected=True )
|
mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host,
|
||||||
|
Controller, waitConnected=True )
|
||||||
dropped = mn.run( mn.ping )
|
dropped = mn.run( mn.ping )
|
||||||
self.assertEqual( dropped, 0 )
|
self.assertEqual( dropped, 0 )
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ def tsharkVersion():
|
|||||||
versionMatch = re.findall( r'TShark \d+.\d+.\d+', versionStr )[0]
|
versionMatch = re.findall( r'TShark \d+.\d+.\d+', versionStr )[0]
|
||||||
return versionMatch.split()[ 1 ]
|
return versionMatch.split()[ 1 ]
|
||||||
|
|
||||||
|
# pylint doesn't understand pexpect.match, unfortunately!
|
||||||
|
# pylint:disable=maybe-no-member
|
||||||
|
|
||||||
class testWalkthrough( unittest.TestCase ):
|
class testWalkthrough( unittest.TestCase ):
|
||||||
"Test Mininet walkthrough"
|
"Test Mininet walkthrough"
|
||||||
|
|
||||||
@@ -33,7 +36,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
|
|
||||||
def testWireshark( self ):
|
def testWireshark( self ):
|
||||||
"Use tshark to test the of dissector"
|
"Use tshark to test the of dissector"
|
||||||
# Satisfy pylint:
|
# Satisfy pylint
|
||||||
assert self
|
assert self
|
||||||
if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ):
|
if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ):
|
||||||
tshark = pexpect.spawn( 'tshark -i lo -R of' )
|
tshark = pexpect.spawn( 'tshark -i lo -R of' )
|
||||||
@@ -78,7 +81,8 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
node = p.match.group( 1 )
|
node = p.match.group( 1 )
|
||||||
actual.append( node )
|
actual.append( node )
|
||||||
p.expect( '\n' )
|
p.expect( '\n' )
|
||||||
self.assertEqual( actual.sort(), nodes.sort(), '"nodes" and "dump" differ' )
|
self.assertEqual( actual.sort(), nodes.sort(),
|
||||||
|
'"nodes" and "dump" differ' )
|
||||||
p.expect( self.prompt )
|
p.expect( self.prompt )
|
||||||
p.sendline( 'exit' )
|
p.sendline( 'exit' )
|
||||||
p.wait()
|
p.wait()
|
||||||
@@ -202,7 +206,8 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
p.expect( self.prompt )
|
p.expect( self.prompt )
|
||||||
# test delay
|
# test delay
|
||||||
p.sendline( 'h1 ping -c 4 h2' )
|
p.sendline( 'h1 ping -c 4 h2' )
|
||||||
p.expect( r'rtt min/avg/max/mdev = ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
|
p.expect( r'rtt min/avg/max/mdev = '
|
||||||
|
r'([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
|
||||||
delay = float( p.match.group( 2 ) )
|
delay = float( p.match.group( 2 ) )
|
||||||
self.assertTrue( delay > 40, 'Delay < 40ms' )
|
self.assertTrue( delay > 40, 'Delay < 40ms' )
|
||||||
self.assertTrue( delay < 45, 'Delay > 40ms' )
|
self.assertTrue( delay < 45, 'Delay > 40ms' )
|
||||||
@@ -226,10 +231,13 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
|
|
||||||
def testCustomTopo( self ):
|
def testCustomTopo( self ):
|
||||||
"Start Mininet using a custom topo, then run pingall"
|
"Start Mininet using a custom topo, then run pingall"
|
||||||
|
# Satisfy pylint
|
||||||
|
assert self
|
||||||
custom = os.path.dirname( os.path.realpath( __file__ ) )
|
custom = os.path.dirname( os.path.realpath( __file__ ) )
|
||||||
custom = os.path.join( custom, '../../custom/topo-2sw-2host.py' )
|
custom = os.path.join( custom, '../../custom/topo-2sw-2host.py' )
|
||||||
custom = os.path.normpath( custom )
|
custom = os.path.normpath( custom )
|
||||||
p = pexpect.spawn( 'mn --custom %s --topo mytopo --test pingall' % custom )
|
p = pexpect.spawn(
|
||||||
|
'mn --custom %s --topo mytopo --test pingall' % custom )
|
||||||
p.expect( '0% dropped' )
|
p.expect( '0% dropped' )
|
||||||
p.expect( pexpect.EOF )
|
p.expect( pexpect.EOF )
|
||||||
|
|
||||||
@@ -331,11 +339,15 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
'Github is not reachable; cannot download Pox' )
|
'Github is not reachable; cannot download Pox' )
|
||||||
def testRemoteController( self ):
|
def testRemoteController( self ):
|
||||||
"Test Mininet using Pox controller"
|
"Test Mininet using Pox controller"
|
||||||
|
# Satisfy pylint
|
||||||
|
assert self
|
||||||
if not os.path.exists( '/tmp/pox' ):
|
if not os.path.exists( '/tmp/pox' ):
|
||||||
p = pexpect.spawn( 'git clone https://github.com/noxrepo/pox.git /tmp/pox' )
|
p = pexpect.spawn(
|
||||||
|
'git clone https://github.com/noxrepo/pox.git /tmp/pox' )
|
||||||
p.expect( pexpect.EOF )
|
p.expect( pexpect.EOF )
|
||||||
pox = pexpect.spawn( '/tmp/pox/pox.py forwarding.l2_learning' )
|
pox = pexpect.spawn( '/tmp/pox/pox.py forwarding.l2_learning' )
|
||||||
net = pexpect.spawn( 'mn --controller=remote,ip=127.0.0.1,port=6633 --test pingall' )
|
net = pexpect.spawn(
|
||||||
|
'mn --controller=remote,ip=127.0.0.1,port=6633 --test pingall' )
|
||||||
net.expect( '0% dropped' )
|
net.expect( '0% dropped' )
|
||||||
net.expect( pexpect.EOF )
|
net.expect( pexpect.EOF )
|
||||||
pox.sendintr()
|
pox.sendintr()
|
||||||
|
|||||||
@@ -427,6 +427,7 @@ def fixLimits():
|
|||||||
sysctlTestAndSet( 'net.ipv4.route.max_size', 32768 )
|
sysctlTestAndSet( 'net.ipv4.route.max_size', 32768 )
|
||||||
#Increase number of PTYs for nodes
|
#Increase number of PTYs for nodes
|
||||||
sysctlTestAndSet( 'kernel.pty.max', 20000 )
|
sysctlTestAndSet( 'kernel.pty.max', 20000 )
|
||||||
|
# pylint: disable=broad-except
|
||||||
except Exception:
|
except Exception:
|
||||||
warn( "*** Error setting resource limits. "
|
warn( "*** Error setting resource limits. "
|
||||||
"Mininet's performance may be affected.\n" )
|
"Mininet's performance may be affected.\n" )
|
||||||
@@ -549,6 +550,7 @@ def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ):
|
|||||||
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
|
||||||
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 ) )
|
||||||
|
|||||||
Reference in New Issue
Block a user