Merge branch 'cdburkard-devel/defaultController'
This commit is contained in:
@@ -25,7 +25,8 @@ from mininet.cli import CLI
|
|||||||
from mininet.log import lg, LEVELS, info, debug, error
|
from mininet.log import lg, LEVELS, info, debug, error
|
||||||
from mininet.net import Mininet, MininetWithControlNet, VERSION
|
from mininet.net import Mininet, MininetWithControlNet, VERSION
|
||||||
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
|
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
|
||||||
NOX, RemoteController, UserSwitch, OVSSwitch,
|
NOX, RemoteController, DefaultController,
|
||||||
|
UserSwitch, OVSSwitch,
|
||||||
OVSLegacyKernelSwitch, IVSSwitch )
|
OVSLegacyKernelSwitch, IVSSwitch )
|
||||||
from mininet.nodelib import LinuxBridge
|
from mininet.nodelib import LinuxBridge
|
||||||
from mininet.link import Link, TCLink
|
from mininet.link import Link, TCLink
|
||||||
@@ -58,11 +59,12 @@ HOSTS = { 'proc': Host,
|
|||||||
'rt': custom( CPULimitedHost, sched='rt' ),
|
'rt': custom( CPULimitedHost, sched='rt' ),
|
||||||
'cfs': custom( CPULimitedHost, sched='cfs' ) }
|
'cfs': custom( CPULimitedHost, sched='cfs' ) }
|
||||||
|
|
||||||
CONTROLLERDEF = 'ovsc'
|
CONTROLLERDEF = 'default'
|
||||||
CONTROLLERS = { 'ref': Controller,
|
CONTROLLERS = { 'ref': Controller,
|
||||||
'ovsc': OVSController,
|
'ovsc': OVSController,
|
||||||
'nox': NOX,
|
'nox': NOX,
|
||||||
'remote': RemoteController,
|
'remote': RemoteController,
|
||||||
|
'default': DefaultController,
|
||||||
'none': lambda name: None }
|
'none': lambda name: None }
|
||||||
|
|
||||||
LINKDEF = 'default'
|
LINKDEF = 'default'
|
||||||
|
|||||||
+2
-2
@@ -96,7 +96,7 @@ from itertools import chain, groupby
|
|||||||
|
|
||||||
from mininet.cli import CLI
|
from mininet.cli import CLI
|
||||||
from mininet.log import info, error, debug, output, warn
|
from mininet.log import info, error, debug, output, warn
|
||||||
from mininet.node import Host, OVSKernelSwitch, Controller
|
from mininet.node import Host, OVSKernelSwitch, DefaultController, Controller
|
||||||
from mininet.link import Link, Intf
|
from mininet.link import Link, Intf
|
||||||
from mininet.util import quietRun, fixLimits, numCores, ensureRoot
|
from mininet.util import quietRun, fixLimits, numCores, ensureRoot
|
||||||
from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
|
from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
|
||||||
@@ -109,7 +109,7 @@ class Mininet( object ):
|
|||||||
"Network emulation with hosts spawned in network namespaces."
|
"Network emulation with hosts spawned in network namespaces."
|
||||||
|
|
||||||
def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
|
def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
|
||||||
controller=Controller, link=Link, intf=Intf,
|
controller=DefaultController, link=Link, intf=Intf,
|
||||||
build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
|
build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
|
||||||
inNamespace=False,
|
inNamespace=False,
|
||||||
autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
|
autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
|
||||||
|
|||||||
+15
-2
@@ -1277,13 +1277,19 @@ class Controller( Node ):
|
|||||||
return '<%s %s: %s:%s pid=%s> ' % (
|
return '<%s %s: %s:%s pid=%s> ' % (
|
||||||
self.__class__.__name__, self.name,
|
self.__class__.__name__, self.name,
|
||||||
self.IP(), self.port, self.pid )
|
self.IP(), self.port, self.pid )
|
||||||
|
@classmethod
|
||||||
|
def isAvailable( self ):
|
||||||
|
return quietRun( 'which controller' )
|
||||||
|
|
||||||
class OVSController( Controller ):
|
class OVSController( Controller ):
|
||||||
"Open vSwitch controller"
|
"Open vSwitch controller"
|
||||||
def __init__( self, name, command='ovs-controller', **kwargs ):
|
def __init__( self, name, command='ovs-controller', **kwargs ):
|
||||||
|
if quietRun( 'which test-controller' ):
|
||||||
|
command = 'test-controller'
|
||||||
Controller.__init__( self, name, command=command, **kwargs )
|
Controller.__init__( self, name, command=command, **kwargs )
|
||||||
|
@classmethod
|
||||||
|
def isAvailable( self ):
|
||||||
|
return quietRun( 'which ovs-controller' ) or quietRun( 'which test-controller' )
|
||||||
|
|
||||||
class NOX( Controller ):
|
class NOX( Controller ):
|
||||||
"Controller to run a NOX application."
|
"Controller to run a NOX application."
|
||||||
@@ -1338,3 +1344,10 @@ class RemoteController( Controller ):
|
|||||||
if 'Connected' not in listening:
|
if 'Connected' not in listening:
|
||||||
warn( "Unable to contact the remote controller"
|
warn( "Unable to contact the remote controller"
|
||||||
" at %s:%d\n" % ( self.ip, self.port ) )
|
" at %s:%d\n" % ( self.ip, self.port ) )
|
||||||
|
|
||||||
|
|
||||||
|
def DefaultController( name, order=[ Controller, OVSController ], **kwargs ):
|
||||||
|
"find any controller that is available and run it"
|
||||||
|
for controller in order:
|
||||||
|
if controller.isAvailable():
|
||||||
|
return controller( name, **kwargs )
|
||||||
|
|||||||
Reference in New Issue
Block a user