CustomConstructor -> CustomClass, which calls specialClass

specialClass is an analog of functools.partial but for classes.
We can now use it instead of partial() in mn, so that Mininet
can introspect on the actual base class.

Fixes #488
This commit is contained in:
Bob Lantz committed 2015-03-13 21:17:43 -07:00
1 parent 5224884e5e
commit f6f6d9282b
2 files changed
+45 -32

No files matched your search

+7 -7
View File
@@ -33,7 +33,7 @@ from mininet.nodelib import LinuxBridge
from mininet.link import Link, TCLink, OVSLink
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
from mininet.topolib import TreeTopo, TorusTopo
from mininet.util import customConstructor, splitArgs
from mininet.util import customClass, specialClass, splitArgs
from mininet.util import buildTopo
from functools import partial
@@ -69,8 +69,8 @@ SWITCHES = { 'user': UserSwitch,
HOSTDEF = 'proc'
HOSTS = { 'proc': Host,
'rt': partial( CPULimitedHost, sched='rt' ),
'cfs': partial( CPULimitedHost, sched='cfs' ) }
'rt': specialClass( CPULimitedHost, defaults=dict( sched='rt' ) ),
'cfs': specialClass( CPULimitedHost, defaults=dict( sched='cfs' ) ) }
CONTROLLERDEF = 'default'
CONTROLLERS = { 'ref': Controller,
@@ -311,10 +311,10 @@ class MininetRunner( object ):
self.options.switch )
topo = buildTopo( TOPOS, self.options.topo )
switch = customConstructor( SWITCHES, self.options.switch )
host = customConstructor( HOSTS, self.options.host )
controller = customConstructor( CONTROLLERS, self.options.controller )
link = customConstructor( LINKS, self.options.link )
switch = customClass( SWITCHES, self.options.switch )
host = customClass( HOSTS, self.options.host )
controller = customClass( CONTROLLERS, self.options.controller )
link = customClass( LINKS, self.options.link )
if self.validate:
self.validate( self.options )