From 2db4268ba8dada74bc27590ff5ba91accdf0969e Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Thu, 8 Mar 2012 22:07:19 -0800 Subject: [PATCH] Fix NOX controller so that mn --controller nox,pyswitch,... works. --- bin/mn | 20 +++++++++++++------- mininet/node.py | 10 ++++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/bin/mn b/bin/mn index 8da7e50..be870fb 100755 --- a/bin/mn +++ b/bin/mn @@ -18,7 +18,7 @@ import time from mininet.clean import cleanup from mininet.cli import CLI -from mininet.log import lg, LEVELS, info +from mininet.log import lg, LEVELS, info, warn from mininet.net import Mininet, init from mininet.node import Host, CPULimitedHost, Controller, NOX from mininet.node import RemoteController, UserSwitch, OVSKernelSwitch @@ -29,19 +29,25 @@ from mininet.util import makeNumeric, custom def customNode( constructors, argStr ): "Return custom Node constructor based on argStr" - cname, noargs, kwargs = splitArgs( argStr ) + cname, newargs, kwargs = splitArgs( argStr ) constructor = constructors.get( cname, None ) - if noargs: - raise Exception( "please specify keyword arguments for " + cname ) + #if args: + # raise Exception( "please specify keyword arguments for " + cname ) if not constructor: raise Exception( "error: %s is unknown - please specify one of %s" % ( cname, constructors.keys() ) ) - def custom( *args, **params ): + def custom( name, *args, **params ): params.update( kwargs ) - # print 'CONSTRUCTOR', constructor, 'ARGS', args, 'PARAMS', params - return constructor( *args, **params ) + 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 ) return custom + + # built in topologies, created only when run TOPODEF = 'minimal' TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ), diff --git a/mininet/node.py b/mininet/node.py index 27235d8..1990695 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -50,7 +50,7 @@ import signal import select from subprocess import Popen, PIPE, STDOUT -from mininet.log import info, error, debug +from mininet.log import info, error, warn, debug from mininet.util import quietRun, errRun, errFail, moveIntf, isShellBuiltin from mininet.util import numCores from mininet.moduledeps import moduleDeps, pathCheck, OVS_KMOD, OF_KMOD, TUN @@ -864,13 +864,15 @@ class ControllerParams( object ): class NOX( Controller ): "Controller to run a NOX application." - def __init__( self, name, noxArgs=[], **kwargs ): + def __init__( self, name, *noxArgs, **kwargs ): """Init. name: name to give controller - noxArgs: list of args, or single arg, to pass to NOX""" + noxArgs: arguments (strings) to pass to NOX""" if not noxArgs: + warn( 'warning: no NOX modules specified; ' + 'running packetdump only\n' ) noxArgs = [ 'packetdump' ] - elif type( noxArgs ) != list: + elif type( noxArgs ) not in ( list, tuple ): noxArgs = [ noxArgs ] if 'NOX_CORE_DIR' not in os.environ: