add support for the IVS virtual switch

IVS is an open source virtual switch available for download at
https://github.com/floodlight/ivs. It uses the openvswitch
kernel module.
This commit is contained in:
Rich Lane
2013-06-27 14:50:59 -07:00
parent 33e39a2471
commit 27da832d6d
2 changed files with 68 additions and 2 deletions
+3 -2
View File
@@ -26,7 +26,7 @@ from mininet.log import lg, LEVELS, info
from mininet.net import Mininet, MininetWithControlNet, VERSION from mininet.net import Mininet, MininetWithControlNet, VERSION
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController, from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
NOX, RemoteController, UserSwitch, OVSKernelSwitch, NOX, RemoteController, UserSwitch, OVSKernelSwitch,
OVSLegacyKernelSwitch ) OVSLegacyKernelSwitch, IVSSwitch )
from mininet.link import Link, TCLink from mininet.link import Link, TCLink
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
from mininet.topolib import TreeTopo from mininet.topolib import TreeTopo
@@ -45,7 +45,8 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
SWITCHDEF = 'ovsk' SWITCHDEF = 'ovsk'
SWITCHES = { 'user': UserSwitch, SWITCHES = { 'user': UserSwitch,
'ovsk': OVSKernelSwitch, 'ovsk': OVSKernelSwitch,
'ovsl': OVSLegacyKernelSwitch } 'ovsl': OVSLegacyKernelSwitch,
'ivs': IVSSwitch }
HOSTDEF = 'proc' HOSTDEF = 'proc'
HOSTS = { 'proc': Host, HOSTS = { 'proc': Host,
+65
View File
@@ -1018,6 +1018,71 @@ class OVSSwitch( Switch ):
OVSKernelSwitch = OVSSwitch OVSKernelSwitch = OVSSwitch
class IVSSwitch(Switch):
"""IVS virtual switch
Currently only works in the root namespace.
"""
def __init__( self, name, **kwargs ):
Switch.__init__( self, name, **kwargs )
self.process = None
if self.inNamespace:
error( "IVSSwitch currently only works"
" in the root namespace.\n" )
exit( 1 )
@classmethod
def setup( cls ):
"Make sure IVS is installed"
pathCheck( 'ivs-ctl', 'ivs',
moduleName="Indigo Virtual Switch (projectfloodlight.org)" )
out, err, exitcode = errRun( 'ivs-ctl show' )
if exitcode:
error( out + err +
'ivs-ctl exited with code %d\n' % exitcode +
'*** The openvswitch kernel module might '
'not be loaded. Try modprobe openvswitch.\n' )
exit( 1 )
def start( self, controllers ):
"Start up a new IVS switch"
args = ['ivs']
args.extend( ['--name', self.name] )
args.extend( ['--dpid', self.dpid] )
args.extend( ['--verbose'] )
for intf in self.intfs.values():
if not intf.IP():
args.extend( ['-i', intf.name] )
for c in controllers:
args.extend( ['-c', '%s:%d' % (c.IP(), c.port)] )
with open( '/tmp/ivs.%s.log' % self.name, 'w' ) as logfile:
with open( '/dev/null', 'w' ) as nullfile:
self.process = Popen( args, stdout=logfile, stderr=STDOUT,
stdin=nullfile, preexec_fn=os.setsid )
self.execed = False
def stop( self ):
"Terminate IVS switch."
if self.process:
self.process.terminate()
self.process.wait()
self.process = None
self.deleteIntfs()
def attach( self, intf ):
"Connect a data port"
self.cmd( 'ivs-ctl', 'add-port', '--datapath', self.name, intf )
def detach( self, intf ):
"Disconnect a data port"
self.cmd( 'ivs-ctl', 'del-port', '--datapath', self.name, intf )
def dpctl( self, *args ):
"Run dpctl command"
return "dpctl not supported\n" or args or self # satisfy pylint
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
OpenFlow controller.""" OpenFlow controller."""