introducing OVSBridge

This commit is contained in:
Tomasz Buchert
2014-08-13 16:55:00 +02:00
parent a56d9a6661
commit e8623fdc91
2 changed files with 50 additions and 19 deletions
+2 -1
View File
@@ -26,7 +26,7 @@ from mininet.log import lg, LEVELS, info, debug, error
from mininet.net import Mininet, MininetWithControlNet, VERSION
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
NOX, RemoteController, DefaultController,
UserSwitch, OVSSwitch,
UserSwitch, OVSBridge, OVSSwitch,
OVSLegacyKernelSwitch, IVSSwitch )
from mininet.nodelib import LinuxBridge
from mininet.link import Link, TCLink
@@ -48,6 +48,7 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
SWITCHDEF = 'ovsk'
SWITCHES = { 'user': UserSwitch,
'ovs': OVSSwitch,
'ovsb' : OVSBridge,
# Keep ovsk for compatibility with 2.0
'ovsk': OVSSwitch,
'ovsl': OVSLegacyKernelSwitch,
+48 -18
View File
@@ -996,20 +996,8 @@ class OVSLegacyKernelSwitch( Switch ):
self.deleteIntfs()
class OVSSwitch( Switch ):
"Open vSwitch switch. Depends on ovs-vsctl."
def __init__( self, name, failMode='secure', datapath='kernel',
inband=False, **params ):
"""Init.
name: name for switch
failMode: controller loss behavior (secure|open)
datapath: userspace or kernel mode (kernel|user)
inband: use in-band control (False)"""
Switch.__init__( self, name, **params )
self.failMode = failMode
self.datapath = datapath
self.inband = inband
class OVSSwitchBase( Switch ):
'a base class for OVS switches; does not contain OpenFlow code at all'
@classmethod
def setup( cls ):
@@ -1045,10 +1033,6 @@ class OVSSwitch( Switch ):
' -- '.join( '--if-exists del-br %s' % s
for s in switches ) )
def dpctl( self, *args ):
"Run ovs-ofctl command"
return self.cmd( 'ovs-ofctl', args[ 0 ], self, *args[ 1: ] )
@staticmethod
def TCReapply( intf ):
"""Unfortunately OVS and Mininet are fighting
@@ -1067,6 +1051,52 @@ class OVSSwitch( Switch ):
"Disconnect a data port"
self.cmd( 'ovs-vsctl del-port', self, intf )
class OVSBridge( OVSSwitchBase ):
"OpenVSwitch Bridge (similar to OVSSwitch, but no OpenFlow)"
def __init__( self, name, **kwargs ):
OVSSwitchBase.__init__( self, name, **kwargs )
def connected( self ):
return True
def start( self, controllers ):
if self.inNamespace:
raise Exception(
'OVS kernel switch does not work in a namespace' )
self.cmd( 'ovs-vsctl del-br', self )
intfs = ' '.join( '-- add-port %s %s ' % ( self, intf )
for intf in self.intfList() if not intf.IP() )
cmd = ( 'ovs-vsctl add-br %s ' % self + intfs )
self.cmd( cmd )
for intf in self.intfList():
self.TCReapply( intf )
def stop( self ):
self.cmd( 'ovs-vsctl del-br', self )
self.deleteIntfs()
class OVSSwitch( OVSSwitchBase ):
"Open vSwitch switch using OpenFlow controller. Depends on ovs-vsctl."
def __init__( self, name, failMode='secure', datapath='kernel',
inband=False, **params ):
"""Init.
name: name for switch
failMode: controller loss behavior (secure|open)
datapath: userspace or kernel mode (kernel|user)
inband: use in-band control (False)"""
OVSSwitchBase.__init__( self, name, **params )
self.failMode = failMode
self.datapath = datapath
self.inband = inband
def dpctl( self, *args ):
"Run ovs-ofctl command"
return self.cmd( 'ovs-ofctl', args[ 0 ], self, *args[ 1: ] )
def controllerUUIDs( self ):
"Return ovsdb UUIDs for our controllers"
uuids = []