Revision 5ac3cde2 mininet/node.py
mininet/node.py | ||
---|---|---|
1277 | 1277 |
return '<%s %s: %s:%s pid=%s> ' % ( |
1278 | 1278 |
self.__class__.__name__, self.name, |
1279 | 1279 |
self.IP(), self.port, self.pid ) |
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', |
|
1286 |
'test-controller' ] |
|
1287 |
for c in controllers: |
|
1288 |
if quietRun( "which " + c ): |
|
1289 |
Controller.__init__( self, name, command=c, **kwargs ) |
|
1290 |
break |
|
1280 |
@classmethod |
|
1281 |
def isAvailable( self ): |
|
1282 |
return quietRun( 'which controller' ) |
|
1291 | 1283 |
|
1292 | 1284 |
class OVSController( Controller ): |
1293 | 1285 |
"Open vSwitch controller" |
1294 | 1286 |
def __init__( self, name, command='ovs-controller', **kwargs ): |
1287 |
if quietRun( 'which test-controller' ): |
|
1288 |
command = 'test-controller' |
|
1295 | 1289 |
Controller.__init__( self, name, command=command, **kwargs ) |
1296 |
|
|
1290 |
@classmethod |
|
1291 |
def isAvailable( self ): |
|
1292 |
return quietRun( 'which ovs-controller' ) or quietRun( 'which test-controller' ) |
|
1297 | 1293 |
|
1298 | 1294 |
class NOX( Controller ): |
1299 | 1295 |
"Controller to run a NOX application." |
... | ... | |
1348 | 1344 |
if 'Connected' not in listening: |
1349 | 1345 |
warn( "Unable to contact the remote controller" |
1350 | 1346 |
" at %s:%d\n" % ( self.ip, self.port ) ) |
1347 |
|
|
1348 |
|
|
1349 |
def DefaultController( name, order=[ Controller, OVSController ], **kwargs ): |
|
1350 |
"find a default controller for mininet" |
|
1351 |
for controller in order: |
|
1352 |
if controller.isAvailable(): |
|
1353 |
return controller( name, **kwargs ) |
Also available in: Unified diff