Merge pull request #432 from mininet/devel/fallback
Fall back to OVSBridge if no controller is available for default switch
This commit is contained in:
+27
-4
@@ -1188,9 +1188,21 @@ class OVSSwitch( Switch ):
|
||||
self.cmd( 'ip link del', self )
|
||||
self.deleteIntfs()
|
||||
|
||||
|
||||
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):
|
||||
"""IVS virtual switch"""
|
||||
|
||||
@@ -1413,8 +1425,19 @@ class RemoteController( Controller ):
|
||||
warn( "Unable to contact the remote controller"
|
||||
" at %s:%d\n" % ( self.ip, self.port ) )
|
||||
|
||||
def DefaultController( name, order=[ Controller, OVSController ], **kwargs ):
|
||||
"find any controller that is available and run it"
|
||||
for controller in order:
|
||||
|
||||
DefaultControllers = [ Controller, OVSController ]
|
||||
|
||||
def findController( controllers=DefaultControllers ):
|
||||
"Return first available controller from list, if any"
|
||||
for controller in controllers:
|
||||
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 )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user