Skip to content
Snippets Groups Projects
Commit e8623fdc authored by Tomasz Buchert's avatar Tomasz Buchert
Browse files

introducing OVSBridge

parent a56d9a66
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ from mininet.log import lg, LEVELS, info, debug, error ...@@ -26,7 +26,7 @@ from mininet.log import lg, LEVELS, info, debug, error
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, DefaultController, NOX, RemoteController, DefaultController,
UserSwitch, OVSSwitch, UserSwitch, OVSBridge, OVSSwitch,
OVSLegacyKernelSwitch, IVSSwitch ) OVSLegacyKernelSwitch, IVSSwitch )
from mininet.nodelib import LinuxBridge from mininet.nodelib import LinuxBridge
from mininet.link import Link, TCLink from mininet.link import Link, TCLink
...@@ -48,6 +48,7 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ), ...@@ -48,6 +48,7 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
SWITCHDEF = 'ovsk' SWITCHDEF = 'ovsk'
SWITCHES = { 'user': UserSwitch, SWITCHES = { 'user': UserSwitch,
'ovs': OVSSwitch, 'ovs': OVSSwitch,
'ovsb' : OVSBridge,
# Keep ovsk for compatibility with 2.0 # Keep ovsk for compatibility with 2.0
'ovsk': OVSSwitch, 'ovsk': OVSSwitch,
'ovsl': OVSLegacyKernelSwitch, 'ovsl': OVSLegacyKernelSwitch,
......
...@@ -996,20 +996,8 @@ def stop( self ): ...@@ -996,20 +996,8 @@ def stop( self ):
self.deleteIntfs() self.deleteIntfs()
class OVSSwitch( Switch ): class OVSSwitchBase( Switch ):
"Open vSwitch switch. Depends on ovs-vsctl." 'a base class for OVS switches; does not contain OpenFlow code at all'
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
@classmethod @classmethod
def setup( cls ): def setup( cls ):
...@@ -1045,10 +1033,6 @@ def batchShutdown( cls, switches ): ...@@ -1045,10 +1033,6 @@ def batchShutdown( cls, switches ):
' -- '.join( '--if-exists del-br %s' % s ' -- '.join( '--if-exists del-br %s' % s
for s in switches ) ) for s in switches ) )
def dpctl( self, *args ):
"Run ovs-ofctl command"
return self.cmd( 'ovs-ofctl', args[ 0 ], self, *args[ 1: ] )
@staticmethod @staticmethod
def TCReapply( intf ): def TCReapply( intf ):
"""Unfortunately OVS and Mininet are fighting """Unfortunately OVS and Mininet are fighting
...@@ -1067,6 +1051,52 @@ def detach( self, intf ): ...@@ -1067,6 +1051,52 @@ def detach( self, intf ):
"Disconnect a data port" "Disconnect a data port"
self.cmd( 'ovs-vsctl del-port', self, intf ) 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 ): def controllerUUIDs( self ):
"Return ovsdb UUIDs for our controllers" "Return ovsdb UUIDs for our controllers"
uuids = [] uuids = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment