diff --git a/mininet/net.py b/mininet/net.py index b4263bd..7a01ecb 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -414,7 +414,12 @@ class Mininet( object ): info( '\n*** Adding switches:\n' ) for switchName in topo.switches(): - self.addSwitch( switchName, **topo.nodeInfo( switchName) ) + # A bit ugly: add batch parameter if appropriate + params = topo.nodeInfo( switchName) + cls = params.get( 'cls', self.switch ) + if hasattr( cls, 'batchStartup' ): + params.setdefault( 'batch', True ) + self.addSwitch( switchName, **params ) info( switchName + ' ' ) info( '\n*** Adding links:\n' ) diff --git a/mininet/node.py b/mininet/node.py index d3f4183..768ff68 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -1058,7 +1058,7 @@ class OVSSwitch( Switch ): def __init__( self, name, failMode='secure', datapath='kernel', inband=False, protocols=None, - reconnectms=1000, stp=False, batch=True, **params ): + reconnectms=1000, stp=False, batch=False, **params ): """name: name for switch failMode: controller loss behavior (secure|open) datapath: userspace or kernel mode (kernel|user) @@ -1067,7 +1067,7 @@ class OVSSwitch( Switch ): Unspecified (or old OVS version) uses OVS default reconnectms: max reconnect timeout in ms (0/None for default) stp: enable STP (False, requires failMode=standalone) - batch: enable batch startup (True)""" + batch: enable batch startup (False)""" Switch.__init__( self, name, **params ) self.failMode = failMode self.datapath = datapath diff --git a/mininet/util.py b/mininet/util.py index 1780632..1f5f64d 100644 --- a/mininet/util.py +++ b/mininet/util.py @@ -536,19 +536,28 @@ def customConstructor( constructors, argStr ): raise Exception( "error: %s is unknown - please specify one of %s" % ( cname, constructors.keys() ) ) - def customized( name, *args, **params ): - "Customized constructor, useful for Node, Link, and other classes" - params = params.copy() - params.update( kwargs ) - if not newargs: - return constructor( name, *args, **params ) - if args: - warn( 'warning: %s replacing %s with %s\n' % ( - constructor, args, newargs ) ) - return constructor( name, *newargs, **params ) + if not newargs and not kwargs: + return constructor - customized.__name__ = 'customConstructor(%s)' % argStr - return customized + if not isinstance( constructor, type ): + raise Exception( "error: invalid arguments %s" % argStr ) + + # Return a customized subclass + cls = constructor + class CustomClass( cls ): + "Customized subclass, useful for Node, Link, and other classes" + def __init__( self, name, *args, **params ): + params = params.copy() + params.update( kwargs ) + if not newargs: + return cls.__init__( self, name, *args, **params ) + if args: + warn( 'warning: %s replacing %s with %s\n' % + ( constructor, args, newargs ) ) + return cls.__init__( self, name, *newargs, **params ) + + CustomClass.__name__ = '%s%s' % ( cls.__name__, kwargs ) + return CustomClass def buildTopo( topos, topoStr ): """Create topology from string with format (object, arg1, arg2,...).