+[ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
+NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
+for i in `seq 1 ${NUM_OPENSTACK_SITES}`
+do
+ # Get full list of ODL nodes for this site
+ odl_node_list=
+ for j in `seq 1 ${NUM_ODLS_PER_SITE}`
+ do
+ odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
+ odl_node_list="${odl_node_list} ${!odl_ip}"
+ done
+
+ for j in `seq 1 ${NUM_ODLS_PER_SITE}`
+ do
+ odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
+ # Copy over the config script to controller and execute it (parameters are used only for cluster)
+ echo "Execute the configuration script on controller ${!odl_ip} for index $j with node list ${odl_node_list}"
+ scp ${WORKSPACE}/configuration-script.sh ${!odl_ip}:/tmp
+ ssh ${!odl_ip} "bash /tmp/configuration-script.sh ${j} '${odl_node_list}'"
+ done
+done
+
+echo "Locating config plan to use..."
+configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
+if [ ! -f "${configplan_filepath}" ]; then
+ configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
+fi
+
+if [ -f "${configplan_filepath}" ]; then
+ echo "configplan exists!!!"
+ echo "Changing the configplan path..."
+ cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
+ cat configplan.txt
+ for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
+ echo "Executing ${line}..."
+ source ${line}
+ done
+fi
+
+# Copy over the startup script to controller and execute it.
+for i in `seq 1 ${NUM_ODL_SYSTEM}`
+do
+ CONTROLLERIP=ODL_SYSTEM_${i}_IP
+ echo "Execute the startup script on controller ${!CONTROLLERIP}"
+ scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp
+ ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
+done
+
+seed_index=1
+for i in `seq 1 ${NUM_ODL_SYSTEM}`
+do
+ CONTROLLERIP=ODL_SYSTEM_${i}_IP
+ echo "Execute the post startup script on controller ${!CONTROLLERIP}"
+ scp ${WORKSPACE}/post-startup-script.sh ${!CONTROLLERIP}:/tmp
+ ssh ${!CONTROLLERIP} "bash /tmp/post-startup-script.sh $(( seed_index++ ))"
+ if [ $(( $i % (${NUM_ODL_SYSTEM} / ${NUM_OPENSTACK_SITES}) )) == 0 ]; then
+ seed_index=1
+ fi
+done
+
+echo "Cool down for ${COOLDOWN_PERIOD} seconds :)..."
+sleep ${COOLDOWN_PERIOD}
+
+if [ ${NUM_OPENSTACK_SYSTEM} -gt 0 ]; then
+ echo "Exiting without running tests to deploy openstack for testing"
+ exit
+fi
+
+echo "Generating controller variables..."
+for i in `seq 1 ${NUM_ODL_SYSTEM}`
+do
+ CONTROLLERIP=ODL_SYSTEM_${i}_IP
+ odl_variables=${odl_variables}" -v ${CONTROLLERIP}:${!CONTROLLERIP}"
+ echo "Lets's take the karaf thread dump"
+ KARAF_PID=$(ssh ${!CONTROLLERIP} "ps aux | grep 'distribution-karaf' | grep -v grep | tr -s ' ' | cut -f2 -d' '")
+ ssh ${!CONTROLLERIP} "jstack $KARAF_PID"> ${WORKSPACE}/karaf_${i}_threads_before.log || true
+done
+
+echo "Generating mininet variables..."
+for i in `seq 1 ${NUM_TOOLS_SYSTEM}`
+do
+ MININETIP=TOOLS_SYSTEM_${i}_IP
+ tools_variables=${tools_variables}" -v ${MININETIP}:${!MININETIP}"
+done