fallback to ovsb when no OF controller is unavailable

This commit is contained in:
Tomasz Buchert
2014-08-13 17:04:24 +02:00
parent e8623fdc91
commit 39a3b73f85
2 changed files with 25 additions and 3 deletions
+11 -1
View File
@@ -1382,9 +1382,19 @@ class RemoteController( Controller ):
warn( "Unable to contact the remote controller"
" at %s:%d\n" % ( self.ip, self.port ) )
DEFAULT_CONTROLLERS = [ ('ref', Controller), ('ovsc', OVSController) ]
DEFAULT_CONTROLLERS_CLASSES = [ klass for _, klass in DEFAULT_CONTROLLERS ]
def DefaultController( name, order=[ Controller, OVSController ], **kwargs ):
def getAvailableController():
"find name of any default controller that is available; None if nothing is available"
for name, controller in DEFAULT_CONTROLLERS:
if controller.isAvailable():
return name
return None
def DefaultController( name, order = DEFAULT_CONTROLLERS_CLASSES, **kwargs ):
"find any controller that is available and run it"
for controller in order:
if controller.isAvailable():
return controller( name, **kwargs )
return None