Rename and document customNode

Now customConstructor, because it general to both links and nodes.
This commit is contained in:
Brandon Heller
2012-05-29 23:57:52 -07:00
parent f509ae282d
commit 30b4b4e7f9
+11 -7
View File
@@ -29,8 +29,12 @@ from mininet.topolib import TreeTopo
from mininet.util import makeNumeric, custom from mininet.util import makeNumeric, custom
def customNode( constructors, argStr ): def customConstructor( constructors, argStr ):
"Return custom Node constructor based on argStr" """Return custom constructor based on argStr
The args and key/val pairs in argsStr will be automatically applied
when the generated constructor is later used.
"""
cname, newargs, kwargs = splitArgs( argStr ) cname, newargs, kwargs = splitArgs( argStr )
constructor = constructors.get( cname, None ) constructor = constructors.get( cname, None )
@@ -39,7 +43,7 @@ def customNode( constructors, argStr ):
( cname, constructors.keys() ) ) ( cname, constructors.keys() ) )
def customized( name, *args, **params ): def customized( name, *args, **params ):
"Customized Node constructor" "Customized constructor, useful for Node, Link, and other classes"
params.update( kwargs ) params.update( kwargs )
if not newargs: if not newargs:
return constructor( name, *args, **params ) return constructor( name, *args, **params )
@@ -245,10 +249,10 @@ class MininetRunner( object ):
start = time.time() start = time.time()
topo = buildTopo( self.options.topo ) topo = buildTopo( self.options.topo )
switch = customNode( SWITCHES, self.options.switch ) switch = customConstructor( SWITCHES, self.options.switch )
host = customNode( HOSTS, self.options.host ) host = customConstructor( HOSTS, self.options.host )
controller = customNode( CONTROLLERS, self.options.controller ) controller = customConstructor( CONTROLLERS, self.options.controller )
link = customNode( LINKS, self.options.link ) link = customConstructor( LINKS, self.options.link )
if self.validate: if self.validate:
self.validate( self.options ) self.validate( self.options )