Configure LINC-OE to use multiple controllers
Change-Id: I69b1c8935acdc8869cd19eb916e310965d8a2f48
diff --git a/tools/test/topos/opticalUtils.py b/tools/test/topos/opticalUtils.py
index 18a08e2..f0c78fa 100644
--- a/tools/test/topos/opticalUtils.py
+++ b/tools/test/topos/opticalUtils.py
@@ -197,18 +197,12 @@
return configDict
-def startOE( net, controllerIP=None, controllerPort=None ):
+def startOE( net ):
"Start the LINC optical emulator within a mininet instance"
opticalJSON = {}
linkConfig = []
devices = []
- # if we are not given a controller IP or Port, we use the first found in Mininet
- if controllerIP is None:
- controllerIP = net.controllers[ 0 ].ip
- if controllerPort is None:
- controllerPort = net.controllers[ 0 ].port
-
for switch in net.switches:
if isinstance( switch, OpticalSwitch ):
devices.append( switch.json() )
@@ -248,11 +242,20 @@
error( "***ERROR: Could not find LINC-config-generator in user's home directory\n" )
return False
output = quietRun( '%s/config_generator TopoConfig.json %s/sys.config.template %s %s'
- % ( configGen, configGen, controllerIP, controllerPort ), shell=True )
+ % ( configGen, configGen, net.controllers[ 0 ].ip, net.controllers[ 0 ].port ), shell=True )
if output:
error( '***ERROR: Error creating sys.config file: %s\n' % output )
return False
+ info ('*** Setting multiple controllers in sys.config...\n' )
+ searchStr = '{controllers,.*$'
+ ctrlStr = ''
+ for index in range(len(net.controllers)):
+ ctrlStr += '{"Switch%d-Controller","%s",%d,tcp},' % (index, net.controllers[index].ip, net.controllers[index].port)
+ replaceStr = '{controllers,[%s]},' % ctrlStr[:-1] # Cut off last comma
+ sedCmd = 'sed -i \'s/%s/%s/\' sys.config' % (searchStr, replaceStr)
+ output = quietRun( sedCmd, shell=True )
+
info( '*** Copying sys.config to linc-oe directory: ', output + '\n' )
lincDir = findDir( 'linc-oe' )
if not lincDir:
@@ -285,7 +288,7 @@
info( '*** Press ENTER to push Topology.json to onos...\n' )
raw_input() # FIXME... we should eventually remove this
info( '*** Pushing Topology.json to ONOS\n' )
- output = quietRun( '%s/tools/test/bin/onos-topo-cfg %s Topology.json' % ( onosDir, controllerIP ), shell=True )
+ output = quietRun( '%s/tools/test/bin/onos-topo-cfg %s Topology.json' % ( onosDir, net.controllers[ 0 ].ip ), shell=True )
# successful output contains the two characters '{}'
# if there is more output than this, there is an issue
if output.strip( '{}' ):