1 echo "##################################################"
2 echo "## include-raw-integration-configure-clustering ##"
3 echo "##################################################"
5 # this script configures replication on a single ODL controller.
6 # files touched are akka.conf modules-shards.conf
10 echo "##################################"
11 echo "## Loop through controller IPs #"
12 echo "##################################"
14 declare CONTROLLERIPS=($(cat slave_addresses.txt | grep CONTROLLER | awk -F = '{print $2}'))
15 declare -p CONTROLLERIPS
17 echo "######################################################"
18 echo "## include-raw-integration-configuration_functions ##"
19 echo "######################################################"
21 # writes the functions needed for configuring clustering to
22 # configuration-functions in the WORKSPACE
27 cat > ${WORKSPACE}/configuration-functions <<EOF
30 function getslaveaddresses
32 declare -a CONTROLLERIPS=($CONTROLLER0, $CONTROLLER1, $CONTROLLER2)
33 declare -p CONTROLLERIPS
41 echo "##### editakkaconf #####"
42 echo "The number of args recieved \${#} \${1} \${2}"
43 # Expects 2 argument \$LOOPINCR and IPADDRESS of controller.
44 # \$CONTROLLERIPS[] is set by getslaveaddresses().
45 # \$BUNDLEFOLDER is set in "include-raw-integration-deploy-controller.sh"
46 # A single copy of akka.conf is assumed to be available in \$BUNDLEFOLDER
48 if [ -z ${BUNDLEFOLDER} ] || [ -f ${BUNDLEFOLDER} ]; then
49 echo "WARNING: Location of ODL BUNDLEFOLDER:\$BUNDLEFOLDER is not defined"
52 if [ -z \${CONTROLLERIPS} ]; then
53 echo "WARNING: Cluster IPs not known due to UNBOUND varible: CONTROLLERIPS[@] does not exist"
54 echo "WARNING: Calling getslaveaddresses to populate CONTROLLERIPS[@]"
61 ############################
62 # BEGIN function variables #
63 ############################
65 # make local copies of global varibles because globals may produce interesting bugs.
66 echo "# set the IP of the current controller."
69 local CURRENTCONTROLLERIPADDR=\$2
70 local AKKACONF=\$(find /tmp/${BUNDLEFOLDER} -name akka.conf)
72 # used to verify IP address of current VM
73 local HOSTIPADDR0=\$(/sbin/ifconfig eth0 | grep "inet " | awk '{print \$2}' | awk '{print \$1}')
74 local HOSTIPADDR=\${HOSTIPADDR0#'addr:'}
75 local TEMPIP = \$(/sbin/ifconfig eth0 | grep "inet " | awk '{print \$0}' )
76 local CLUSTERDATAORIG="\"akka.tcp:\/\/opendaylight-cluster-data@127.0.0.1:2550"\"
77 local CLUSTERDATANEW="\"akka.tcp:\/\/opendaylight-cluster-data@$CONTROLLER0:2550\",\"akka.tcp:\/\/opendaylight-cluster-data@$CONTROLLER1:2550\",\"akka.tcp:\/\/opendaylight-cluster-data@$CONTROLLER2:2550"\"
79 local CLUSTERRPCORIG="\"akka.tcp:\/\/odl-cluster-rpc@127.0.0.1:2551"\"
80 local CLUSTERRPCNEW="\"akka.tcp:\/\/odl-cluster-rpc@$CONTROLLER0:2551\",\"akka.tcp:\/\/odl-cluster-rpc@$CONTROLLER1:2551\",\"akka.tcp:\/\/odl-cluster-rpc@$CONTROLLER2:2551\""
82 local UIDORIG="member-1"
83 local UIDNEW="member-\$1"
85 ##########################
86 # END function variables #
87 ##########################
89 #####################################
90 # sanity test hostname in akka.conf #
91 #####################################
92 # probably overkill as SCP depends on IPaddress being correct.
95 if [ -z \${HOSTIPADDR} ]; then
96 echo "WARNING: HOSTIPADDR is empty."
101 if [ "\${CURRENTCONTROLLERIPADDR}" == "\${HOSTIPADDR}" ]
103 echo "CURRENTCONTROLLERIPADRR:\${CURRENTCONTROLLERIPADDR} == HOSTIPADDR:\${HOSTIPADDR}"
105 echo "WARNING: CURRENTCONTROLLERIPADRR:\${CURRENTCONTROLLERIPADDR} != HOSTIPADDR:\${HOSTIPADDR}"
108 ####################################
109 # configure hostname in akka.conf #
110 ####################################
112 cp \${AKKACONF} \${AKKACONF}.bak
113 sed -ri "s:hostname = \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\":hostname = \
114 \$HOSTIPADDR:" \${AKKACONF}.bak
116 ####################################
117 # configure seednode in akka.conf #
118 ####################################
120 sed -i "s/\$CLUSTERDATAORIG/\$CLUSTERDATANEW/g" \${AKKACONF}.bak
121 sed -i "s/\$CLUSTERRPCORIG/\$CLUSTERRPCNEW/g" \${AKKACONF}.bak
123 ####################################
124 # define unique name for each node #
125 ####################################
127 sed -i "s/\$UIDORIG/\$UIDNEW/g" \${AKKACONF}.bak
128 cp \${AKKACONF}.bak \${AKKACONF}
130 echo "##### END editakkaconf #####"
133 function configuremoduleshardsconf
135 echo"### configuremoduleshardsconf ###"
137 if [ -z ${BUNDLEFOLDER} ] || [ -f ${BUNDLEFOLDER} ]; then
138 echo "MODULESHARDSCONF WARNING: Location of ODL BUNDLEFOLDER:\$BUNDLEFOLDER is not defined"
141 local REPLICACONFORIG='"member-1"'
142 local REPLICACONFNEW='"member-0",\n\t\t\t"member-1",\n\t\t\t"member-2"'
145 MODULESHARDSCONF=\$(find /tmp/${BUNDLEFOLDER} -name module-shards.conf)
147 if [ -z \${MODULESHARDSCONF} ]
149 printf "source file module-shards.conf was not found\n"
151 printf "MODULESHARDSCONF: \${MODULESHARDSCONF}"
152 cp \${MODULESHARDSCONF} \${MODULESHARDSCONF}.bak
153 printf \$REPLICACONFNEW
154 sed -i "s/\$REPLICACONFORIG/\$REPLICACONFNEW/g" \${MODULESHARDSCONF}.bak
156 cp \${MODULESHARDSCONF}.bak \${MODULESHARDSCONF}
157 cat \${MODULESHARDSCONF}
164 function runcontrollerscript
166 local CONTROLLERIP=\$1
168 echo "run controller \$CONTROLLERIP on \$i"
169 ssh -v \$CONTROLLERIP 'bash /tmp/\$SCRIPT'
176 #less configuration-functions
177 echo "#########################################################"
178 echo "## END include-raw-integration-configuration_functions ##"
179 echo "#########################################################"
181 echo "##################################"
182 echo "## Less configuration functions #"
183 echo "##################################"
185 #less ${WORKSPACE}/configuration-functions
187 echo "######################################"
188 echo "## END Less configuration functions #"
189 echo "######################################"
191 ## Describe the script run on guest vm (node) to configure clustering
194 cat > ${WORKSPACE}/configuration-script.sh <<EOF
195 source /tmp/configuration-functions
196 source /tmp/bundle_vars.txt
197 source /tmp/slave_addresses.txt
199 # Calling the Functions used to edit akka.comf and module-shards
200 # $1 is loop increment and $2 is the ipaddress of current
204 configuremoduleshardsconf \$1 \$2
210 # Describe CONFIGURATION FUNCTIONS available for the script above
211 # CONFIGURATIONFUNCTIONS='configuration-functions'
214 for i in "${!CONTROLLERIPS[@]}"
216 echo "IP address of node is: ${CONTROLLERIPS[$i]} and index is $i"
217 scp ${WORKSPACE}/slave_addresses.txt ${CONTROLLERIPS[$i]}:/tmp
218 scp ${WORKSPACE}/bundle_vars.txt ${CONTROLLERIPS[$i]}:/tmp
220 scp ${WORKSPACE}/configuration-functions ${CONTROLLERIPS[$i]}:/tmp
221 scp ${WORKSPACE}/configuration-script.sh ${CONTROLLERIPS[$i]}:/tmp
223 echo "configure controller ${CONTROLLERIPS[$i]} on $i"
226 ssh -v ${CONTROLLERIPS[$i]} "bash /tmp/configuration-script.sh $i ${CONTROLLERIPS[$i]}"
231 echo "######################################################"
232 echo "## END include-raw-integration-configure-clustering ##"
233 echo "######################################################"