From 2e40981c3d592b7a7bf23df5ddadc73b951af407 Mon Sep 17 00:00:00 2001 From: Neela Krishna Teja Tadikonda Date: Tue, 4 Oct 2016 00:08:19 -0400 Subject: [PATCH] Fix for adding multiple controllers and swtiches For adding multiple controllers and switches with custom mapping, the implementation suggested in the examples is not straight forward. The implementation here is mapping the swithes to controllers in start. --- mininet/net.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mininet/net.py b/mininet/net.py index 8acba201..b3c2160f 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -532,7 +532,7 @@ def staticArp( self ): if src != dst: src.setARP( ip=dst.IP(), mac=dst.MAC() ) - def start( self ): + def start( self , switchControllerMap={}): "Start controller and switches." if not self.built: self.build() @@ -541,10 +541,20 @@ def start( self ): info( controller.name + ' ') controller.start() info( '\n' ) + if switchControllerMap: + info( 'Custom Switch Controller map is provided and being used' ) + self.switchControllerMap=switchControllerMap info( '*** Starting %s switches\n' % len( self.switches ) ) for switch in self.switches: info( switch.name + ' ') - switch.start( self.controllers ) + if switchControllerMap: + if type( switchControllerMap[switch.name] ) is list: + controllers = switchControllerMap[switch.name] + else: + controllers = [switchControllerMap[switch.name]] + else: + controllers=self.controllers + switch.start( controllers ) started = {} for swclass, switches in groupby( sorted( self.switches, key=type ), type ):