Revision 72fd120d

View differences:

bin/mn
25 25
from mininet.log import lg, LEVELS, info, debug, error
26 26
from mininet.net import Mininet, MininetWithControlNet, VERSION
27 27
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
28
                           NOX, RemoteController, UserSwitch, OVSKernelSwitch,
28
                           NOX, RemoteController, DefaultController, UserSwitch, OVSKernelSwitch,
29 29
                           OVSLegacyKernelSwitch, IVSSwitch )
30 30
from mininet.link import Link, TCLink
31 31
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
......
53 53
          'rt': custom( CPULimitedHost, sched='rt' ),
54 54
          'cfs': custom( CPULimitedHost, sched='cfs' ) }
55 55

  
56
CONTROLLERDEF = 'ovsc'
56
CONTROLLERDEF = 'default'
57 57
CONTROLLERS = { 'ref': Controller,
58 58
                'ovsc': OVSController,
59 59
                'nox': NOX,
60 60
                'remote': RemoteController,
61
                'default': DefaultController,
61 62
                'none': lambda name: None }
62 63

  
63 64
LINKDEF = 'default'
mininet/net.py
95 95

  
96 96
from mininet.cli import CLI
97 97
from mininet.log import info, error, debug, output
98
from mininet.node import Host, OVSKernelSwitch, Controller
98
from mininet.node import Host, OVSKernelSwitch, DefaultController, Controller
99 99
from mininet.link import Link, Intf
100 100
from mininet.util import quietRun, fixLimits, numCores, ensureRoot
101 101
from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
......
213 213
        if not controller:
214 214
            controller = self.controller
215 215
        # Construct new controller if one is not given
216
        if isinstance(name, Controller):
216
        if isinstance( name, Controller ):
217 217
            controller_new = name
218 218
            # Pylint thinks controller is a str()
219 219
            # pylint: disable=E1103
220 220
            name = controller_new.name
221 221
            # pylint: enable=E1103
222 222
        else:
223
            # bookmark
223 224
            controller_new = controller( name, **params )
224 225
        # Add new controller to net
225
        if controller_new:  # allow controller-less setups
226
        if controller_new: # allow controller-less setups
226 227
            self.controllers.append( controller_new )
227 228
            self.nameToNode[ name ] = controller_new
228 229
        return controller_new
mininet/node.py
1278 1278
            self.__class__.__name__, self.name,
1279 1279
            self.IP(), self.port, self.pid )
1280 1280

  
1281
class DefaultController( Controller ):
1282
    "find any controller that is available and run it"
1283
    def __init__( self, name, **kwargs ):
1284
        "search for any installed controller"
1285
        controllers = [ 'controller', 'ovs-controller', 'test-controller' ] # , 'pox', 'ryu' ] # test-controller is the important part
1286
        for c in controllers:
1287
            if quietRun( "which " + c ):
1288
                Controller.__init__( self, name, controller=c, **kwargs )
1289
                break
1281 1290

  
1282 1291
class OVSController( Controller ):
1283 1292
    "Open vSwitch controller"

Also available in: Unified diff