Skip to content
Snippets Groups Projects
Commit c7921fe4 authored by Brian O'Connor's avatar Brian O'Connor
Browse files

Merge pull request #432 from mininet/devel/fallback

Fall back to OVSBridge if no controller is available for default switch
parents 4f8aa1d8 ccd3276d
No related branches found
No related tags found
No related merge requests found
...@@ -25,8 +25,8 @@ from mininet.cli import CLI ...@@ -25,8 +25,8 @@ from mininet.cli import CLI
from mininet.log import lg, LEVELS, info, debug, warn, error from mininet.log import lg, LEVELS, info, debug, warn, 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,
RYU, NOX, RemoteController, DefaultController, RYU, NOX, RemoteController, findController, DefaultController,
UserSwitch, OVSSwitch, UserSwitch, OVSSwitch, OVSBridge,
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
...@@ -54,14 +54,16 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ), ...@@ -54,14 +54,16 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
'tree': TreeTopo, 'tree': TreeTopo,
'torus': TorusTopo } 'torus': TorusTopo }
SWITCHDEF = 'ovsk' SWITCHDEF = 'default'
SWITCHES = { 'user': UserSwitch, SWITCHES = { 'user': UserSwitch,
'ovs': OVSSwitch, 'ovs': OVSSwitch,
'ovsbr' : OVSBridge,
# Keep ovsk for compatibility with 2.0 # Keep ovsk for compatibility with 2.0
'ovsk': OVSSwitch, 'ovsk': OVSSwitch,
'ovsl': OVSLegacyKernelSwitch, 'ovsl': OVSLegacyKernelSwitch,
'ivs': IVSSwitch, 'ivs': IVSSwitch,
'lxbr': LinuxBridge } 'lxbr': LinuxBridge,
'default': OVSSwitch }
HOSTDEF = 'proc' HOSTDEF = 'proc'
HOSTS = { 'proc': Host, HOSTS = { 'proc': Host,
...@@ -73,8 +75,8 @@ CONTROLLERS = { 'ref': Controller, ...@@ -73,8 +75,8 @@ CONTROLLERS = { 'ref': Controller,
'ovsc': OVSController, 'ovsc': OVSController,
'nox': NOX, 'nox': NOX,
'remote': RemoteController, 'remote': RemoteController,
'default': DefaultController,
'ryu': RYU, 'ryu': RYU,
'default': DefaultController, # Note: replaced below
'none': lambda name: None } 'none': lambda name: None }
LINKDEF = 'default' LINKDEF = 'default'
...@@ -252,6 +254,22 @@ class MininetRunner( object ): ...@@ -252,6 +254,22 @@ class MininetRunner( object ):
start = time.time() start = time.time()
if self.options.controller == 'default':
# Update default based on available controllers
CONTROLLERS[ 'default' ] = findController()
if CONTROLLERS[ 'default' ] is None:
if self.options.switch == 'default':
# Fall back to OVS Bridge, which does not use an OF controller
info( '*** No default OpenFlow controller found for default switch!\n' )
info( '*** Falling back to OVS Bridge\n' )
self.options.switch = 'ovsbr'
self.options.controller = 'none'
elif self.options.switch in ( 'ovsbr', 'lxbr' ):
self.options.controller = 'none'
else:
raise Exception( "Could not find a default controller for switch %s" %
self.options.switch )
topo = buildTopo( TOPOS, self.options.topo ) topo = buildTopo( TOPOS, self.options.topo )
switch = customConstructor( SWITCHES, self.options.switch ) switch = customConstructor( SWITCHES, self.options.switch )
host = customConstructor( HOSTS, self.options.host ) host = customConstructor( HOSTS, self.options.host )
......
...@@ -1188,9 +1188,21 @@ def stop( self ): ...@@ -1188,9 +1188,21 @@ def stop( self ):
self.cmd( 'ip link del', self ) self.cmd( 'ip link del', self )
self.deleteIntfs() self.deleteIntfs()
OVSKernelSwitch = OVSSwitch OVSKernelSwitch = OVSSwitch
class OVSBridge( OVSSwitch ):
"OVSBridge is an OVSSwitch in standalone/bridge mode"
def __init__( self, args, **kwargs ):
kwargs.update( failMode='standalone' )
OVSSwitch.__init__( self, args, **kwargs )
def start( self, controllers ):
OVSSwitch.start( self, controllers=[] )
class IVSSwitch(Switch): class IVSSwitch(Switch):
"""IVS virtual switch""" """IVS virtual switch"""
...@@ -1413,8 +1425,19 @@ def checkListening( self ): ...@@ -1413,8 +1425,19 @@ def checkListening( self ):
warn( "Unable to contact the remote controller" warn( "Unable to contact the remote controller"
" at %s:%d\n" % ( self.ip, self.port ) ) " at %s:%d\n" % ( self.ip, self.port ) )
def DefaultController( name, order=[ Controller, OVSController ], **kwargs ):
"find any controller that is available and run it" DefaultControllers = [ Controller, OVSController ]
for controller in order:
def findController( controllers=DefaultControllers ):
"Return first available controller from list, if any"
for controller in controllers:
if controller.isAvailable(): if controller.isAvailable():
return controller( name, **kwargs ) return controller
def DefaultController( name, controllers=DefaultControllers, **kwargs ):
"Find a controller that is available and instantiate it"
controller = findController( controllers )
if not controller:
raise Exception( 'Could not find a default OpenFlow controller' )
return controller( name, **kwargs )
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