Tolerate passing controller *objects* into Mininet()

This commit is contained in:
Bob Lantz
2014-07-15 08:28:05 -07:00
parent b5962e8ee9
commit b7268856d7
+5 -1
View File
@@ -246,7 +246,7 @@ class Mininet( object ):
if not controller: if not controller:
controller = self.controller controller = self.controller
# Construct new controller if one is not given # Construct new controller if one is not given
if isinstance(name, Controller): if issubclass( name.__class__, Controller ):
controller_new = name controller_new = name
# Pylint thinks controller is a str() # Pylint thinks controller is a str()
# pylint: disable=E1103 # pylint: disable=E1103
@@ -357,6 +357,10 @@ class Mininet( object ):
if type( classes ) is not list: if type( classes ) is not list:
classes = [ classes ] classes = [ classes ]
for i, cls in enumerate( classes ): for i, cls in enumerate( classes ):
# Allow Controller objects because nobody understands currying
if issubclass( cls.__class__, Controller ):
self.addController( cls )
else:
self.addController( 'c%d' % i, cls ) self.addController( 'c%d' % i, cls )
info( '*** Adding hosts:\n' ) info( '*** Adding hosts:\n' )