-echo "##################################################"
-echo "## include-raw-integration-configure-clustering ##"
-echo "##################################################"
-
-# this script configures replication on a single ODL controller.
-# files touched are akka.conf modules-shards.conf
-
-
-
-echo "##################################"
-echo "## Loop through controller IPs #"
-echo "##################################"
-
-declare CONTROLLERIPS=($(cat slave_addresses.txt | grep CONTROLLER | awk -F = '{print $2}'))
-declare -p CONTROLLERIPS
-
-echo "######################################################"
-echo "## include-raw-integration-configuration_functions ##"
-echo "######################################################"
-
-# writes the functions needed for configuring clustering to
-# configuration-functions in the WORKSPACE
-env
-
-set -x
+echo "#################################################"
+echo "## Configure Cluster and Start ##"
+echo "#################################################"
+
+AKKACONF=/tmp/${BUNDLEFOLDER}/configuration/initial/akka.conf
+MODULESCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/modules.conf
+MODULESHARDSCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/module-shards.conf
+CONTROLLERMEM="2048m"
+
+if [ ${CONTROLLERSCOPE} == 'all' ]; then
+ ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
+ CONTROLLERMEM="3072m"
+else
+ ACTUALFEATURES="${CONTROLLERFEATURES}"
+fi
+# Some versions of jenkins job builder result in feature list containing spaces
+# and ending in newline. Remove all that.
+ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
-cat > ${WORKSPACE}/configuration-functions <<EOF
+# Utility function for joining strings.
+function join {
+ delim=' '
+ final=$1; shift
+ for str in $* ; do
+ final=${final}${delim}${str}
+ done
-function getslaveaddresses
-{
- declare -a CONTROLLERIPS=($CONTROLLER0, $CONTROLLER1, $CONTROLLER2)
- declare -p CONTROLLERIPS
- export CONTROLLERIPS
+ echo ${final}
}
+# Create the string for nodes
+for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
+ CONTROLLERIP=ODL_SYSTEM_${i}_IP
+ nodes[$i]=${!CONTROLLERIP}
+done
-function editakkaconf
-{
-set -x
- echo "##### editakkaconf #####"
- echo "The number of args recieved \${#} \${1} \${2}"
-# Expects 2 argument \$LOOPINCR and IPADDRESS of controller.
-# \$CONTROLLERIPS[] is set by getslaveaddresses().
-# \$BUNDLEFOLDER is set in "include-raw-integration-deploy-controller.sh"
-# A single copy of akka.conf is assumed to be available in \$BUNDLEFOLDER
+nodes_list=$(join ${nodes[@]})
-if [ -z ${BUNDLEFOLDER} ] || [ -f ${BUNDLEFOLDER} ]; then
- echo "WARNING: Location of ODL BUNDLEFOLDER:\$BUNDLEFOLDER is not defined"
+echo ${nodes_list}
+# Run script plan in case it exists
+if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
+ echo "scriptplan exists!!!"
+ echo "Changing the scriptplan path..."
+ cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
+ cat scriptplan.txt
+ for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
+ echo "Executing ${line}..."
+ source ${line}
+ done
fi
-if [ -z \${CONTROLLERIPS} ]; then
- echo "WARNING: Cluster IPs not known due to UNBOUND varible: CONTROLLERIPS[@] does not exist"
- echo "WARNING: Calling getslaveaddresses to populate CONTROLLERIPS[@]"
- getslaveaddresses
-fi
-
-
-
-
-############################
-# BEGIN function variables #
-############################
-
- # make local copies of global varibles because globals may produce interesting bugs.
- echo "# set the IP of the current controller."
-
- local LOOPINCR=\$1
- local CURRENTCONTROLLERIPADDR=\$2
- local AKKACONF=\$(find /tmp/${BUNDLEFOLDER} -name akka.conf)
-
- # used to verify IP address of current VM
- local HOSTIPADDR0=\$(/sbin/ifconfig eth0 | grep "inet " | awk '{print \$2}' | awk '{print \$1}')
- local HOSTIPADDR=\${HOSTIPADDR0#'addr:'}
- local TEMPIP = \$(/sbin/ifconfig eth0 | grep "inet " | awk '{print \$0}' )
- local CLUSTERDATAORIG="\"akka.tcp:\/\/opendaylight-cluster-data@127.0.0.1:2550"\"
- local CLUSTERDATANEW="\"akka.tcp:\/\/opendaylight-cluster-data@$CONTROLLER0:2550\",\"akka.tcp:\/\/opendaylight-cluster-data@$CONTROLLER1:2550\",\"akka.tcp:\/\/opendaylight-cluster-data@$CONTROLLER2:2550"\"
-
- local CLUSTERRPCORIG="\"akka.tcp:\/\/odl-cluster-rpc@127.0.0.1:2551"\"
- local CLUSTERRPCNEW="\"akka.tcp:\/\/odl-cluster-rpc@$CONTROLLER0:2551\",\"akka.tcp:\/\/odl-cluster-rpc@$CONTROLLER1:2551\",\"akka.tcp:\/\/odl-cluster-rpc@$CONTROLLER2:2551\""
-
- local UIDORIG="member-1"
- local UIDNEW="member-\$1"
-
-##########################
-# END function variables #
-##########################
-
-#####################################
-# sanity test hostname in akka.conf #
-#####################################
-# probably overkill as SCP depends on IPaddress being correct.
-
-#set -x
- if [ -z \${HOSTIPADDR} ]; then
- echo "WARNING: HOSTIPADDR is empty."
- fi
-
-#set +x
-
- if [ "\${CURRENTCONTROLLERIPADDR}" == "\${HOSTIPADDR}" ]
- then
- echo "CURRENTCONTROLLERIPADRR:\${CURRENTCONTROLLERIPADDR} == HOSTIPADDR:\${HOSTIPADDR}"
- else
- echo "WARNING: CURRENTCONTROLLERIPADRR:\${CURRENTCONTROLLERIPADDR} != HOSTIPADDR:\${HOSTIPADDR}"
- fi
-
-####################################
-# configure hostname in akka.conf #
-####################################
- cp \${AKKACONF} \${AKKACONF}.bak
- sed -ri "s:hostname = \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\":hostname = \
-\$HOSTIPADDR:" \${AKKACONF}.bak
+# Create the configuration script to be run on controllers.
+cat > ${WORKSPACE}/configuration-script.sh <<EOF
-####################################
-# configure seednode in akka.conf #
-####################################
+echo "Changing to /tmp"
+cd /tmp
+
+echo "Downloading the distribution from ${ACTUALBUNDLEURL}"
+wget --progress=dot:mega '${ACTUALBUNDLEURL}'
+
+echo "Extracting the new controller..."
+unzip -q ${BUNDLE}
+
+echo "Configuring the startup features..."
+FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
+CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
+sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
+sed -ie "s%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-integration-test/${BUNDLEVERSION}/xml/features%g" \${FEATURESCONF}
+cat \${FEATURESCONF}
+
+echo "Configuring the log..."
+LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
+sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
+# FIXME: Make log size limit configurable from build parameter.
+sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=100GB/g' \${LOGCONF}
+cat \${LOGCONF}
+
+if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
+ echo "Enable the l3.fwd in custom.properties.."
+ echo "ovsdb.l3.fwd.enabled=yes" >> \${CUSTOMPROP}
+ cat \${CUSTOMPROP}
+fi
- sed -i "s/\$CLUSTERDATAORIG/\$CLUSTERDATANEW/g" \${AKKACONF}.bak
- sed -i "s/\$CLUSTERRPCORIG/\$CLUSTERRPCNEW/g" \${AKKACONF}.bak
+echo "Configure java home and max memory..."
+MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
+sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' \${MEMCONF}
+sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
+cat \${MEMCONF}
+
+echo "Set Java version"
+sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
+sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
+echo "JDK default version ..."
+java -version
+
+echo "Set JAVA_HOME"
+export JAVA_HOME="${JAVA_HOME}"
+# Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
+JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
+echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
+
+# Copy shard file if exists
+if [ -f /tmp/custom_shard_config.txt ]; then
+ echo "Custom shard config exists!!!"
+ echo "Copying the shard config..."
+ cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
+fi
-####################################
-# define unique name for each node #
-####################################
-
- sed -i "s/\$UIDORIG/\$UIDNEW/g" \${AKKACONF}.bak
- cp \${AKKACONF}.bak \${AKKACONF}
- cat \${AKKACONF}
-echo "##### END editakkaconf #####"
-set +x
-}
-function configuremoduleshardsconf
-{
- echo"### configuremoduleshardsconf ###"
- set -x
- if [ -z ${BUNDLEFOLDER} ] || [ -f ${BUNDLEFOLDER} ]; then
- echo "MODULESHARDSCONF WARNING: Location of ODL BUNDLEFOLDER:\$BUNDLEFOLDER is not defined"
- fi
-
- local REPLICACONFORIG='"member-1"'
- local REPLICACONFNEW='"member-0",\n\t\t\t"member-1",\n\t\t\t"member-2"'
-
-
- MODULESHARDSCONF=\$(find /tmp/${BUNDLEFOLDER} -name module-shards.conf)
-
- if [ -z \${MODULESHARDSCONF} ]
- then
- printf "source file module-shards.conf was not found\n"
- else
- printf "MODULESHARDSCONF: \${MODULESHARDSCONF}"
- cp \${MODULESHARDSCONF} \${MODULESHARDSCONF}.bak
- printf \$REPLICACONFNEW
- sed -i "s/\$REPLICACONFORIG/\$REPLICACONFNEW/g" \${MODULESHARDSCONF}.bak
-
- cp \${MODULESHARDSCONF}.bak \${MODULESHARDSCONF}
- cat \${MODULESHARDSCONF}
- fi
- set +x
-}
+echo "Configuring cluster"
+/tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
+echo "Dump akka.conf"
+cat ${AKKACONF}
+echo "Dump modules.conf"
+cat ${MODULESCONF}
-function runcontrollerscript
-{
- local CONTROLLERIP=\$1
- local SCRIPT=\$2
- echo "run controller \$CONTROLLERIP on \$i"
- ssh -v \$CONTROLLERIP 'bash /tmp/\$SCRIPT'
-}
+echo "Dump module-shards.conf"
+cat ${MODULESHARDSCONF}
EOF
-set +x
-
-
-#less configuration-functions
-echo "#########################################################"
-echo "## END include-raw-integration-configuration_functions ##"
-echo "#########################################################"
-
-echo "##################################"
-echo "## Less configuration functions #"
-echo "##################################"
-
-#less ${WORKSPACE}/configuration-functions
-
-echo "######################################"
-echo "## END Less configuration functions #"
-echo "######################################"
-
-## Describe the script run on guest vm (node) to configure clustering
+# Create the startup script to be run on controllers.
+cat > ${WORKSPACE}/startup-script.sh <<EOF
-cat > ${WORKSPACE}/configuration-script.sh <<EOF
- source /tmp/configuration-functions
- source /tmp/bundle_vars.txt
- source /tmp/slave_addresses.txt
-
- # Calling the Functions used to edit akka.comf and module-shards
- # $1 is loop increment and $2 is the ipaddress of current
- # controller
-
- editakkaconf \$1 \$2
- configuremoduleshardsconf \$1 \$2
+echo "Starting controller..."
+/tmp/${BUNDLEFOLDER}/bin/start
EOF
-
-
-# Describe CONFIGURATION FUNCTIONS available for the script above
-# CONFIGURATIONFUNCTIONS='configuration-functions'
-
-set -x
-for i in "${!CONTROLLERIPS[@]}"
+# Copy over the configuration script and configuration files to each controller
+# Execute the configuration script on each controller.
+for i in `seq 1 ${NUM_ODL_SYSTEM}`
do
- echo "IP address of node is: ${CONTROLLERIPS[$i]} and index is $i"
- scp ${WORKSPACE}/slave_addresses.txt ${CONTROLLERIPS[$i]}:/tmp
- scp ${WORKSPACE}/bundle_vars.txt ${CONTROLLERIPS[$i]}:/tmp
-
- scp ${WORKSPACE}/configuration-functions ${CONTROLLERIPS[$i]}:/tmp
- scp ${WORKSPACE}/configuration-script.sh ${CONTROLLERIPS[$i]}:/tmp
-
- echo "configure controller ${CONTROLLERIPS[$i]} on $i"
-
-
- ssh -v ${CONTROLLERIPS[$i]} "bash /tmp/configuration-script.sh $i ${CONTROLLERIPS[$i]}"
+ CONTROLLERIP=ODL_SYSTEM_${i}_IP
+ echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
+ scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
+ ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
done
-set +x
+# Copy over the startup script to each controller and execute it.
+for i in `seq 1 ${NUM_ODL_SYSTEM}`
+do
+ CONTROLLERIP=ODL_SYSTEM_${i}_IP
+ echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
+ scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
+ ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
+done
-echo "######################################################"
-echo "## END include-raw-integration-configure-clustering ##"
-echo "######################################################"
-
+# vim: ts=4 sw=4 sts=4 et ft=sh :