From b7268856d7b74dc6022bad120b27749f32e9253a Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Tue, 15 Jul 2014 08:28:05 -0700
Subject: [PATCH] Tolerate passing controller *objects* into Mininet()

---
 mininet/net.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mininet/net.py b/mininet/net.py
index 353fc579..b7b89f7e 100755
--- a/mininet/net.py
+++ b/mininet/net.py
@@ -246,7 +246,7 @@ def addController( self, name='c0', controller=None, **params ):
         if not controller:
             controller = self.controller
         # Construct new controller if one is not given
-        if isinstance(name, Controller):
+        if issubclass( name.__class__, Controller ):
             controller_new = name
             # Pylint thinks controller is a str()
             # pylint: disable=E1103
@@ -357,7 +357,11 @@ def buildFromTopo( self, topo=None ):
             if type( classes ) is not list:
                 classes = [ classes ]
             for i, cls in enumerate( classes ):
-                self.addController( 'c%d' % i, cls )
+                # Allow Controller objects because nobody understands currying
+                if issubclass( cls.__class__, Controller ):
+                    self.addController( cls )
+                else:
+                    self.addController( 'c%d' % i, cls )
 
         info( '*** Adding hosts:\n' )
         for hostName in topo.hosts():
-- 
GitLab