1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the include-raw-integration-install-robotframework.sh
5 source ${ROBOT_VENV}/bin/activate
7 echo "#################################################"
8 echo "## Deploy Openstack 3-node ##"
9 echo "#################################################"
13 function create_control_node_local_conf {
14 local_conf_file_name=${WORKSPACE}/local.conf_control
15 cat > ${local_conf_file_name} << EOF
18 SCREEN_LOGDIR=/opt/stack/data/log
24 for service_name in ${DISABLE_OS_SERVICES}
26 cat >> ${local_conf_file_name} << EOF
27 disable_service ${service_name}
30 for service_name in ${ENABLE_OS_SERVICES}
32 cat >> ${local_conf_file_name} << EOF
33 enable_service ${service_name}
38 cat >> ${local_conf_file_name} << EOF
39 HOST_IP=$OPENSTACK_CONTROL_NODE_IP
40 SERVICE_HOST=\$HOST_IP
42 NEUTRON_CREATE_INITIAL_NETWORKS=False
44 Q_ML2_TENANT_NETWORK_TYPE=${TENANT_NETWORK_TYPE}
47 ENABLE_TENANT_TUNNELS=True
49 MYSQL_HOST=\$SERVICE_HOST
50 RABBIT_HOST=\$SERVICE_HOST
51 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
52 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
53 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
56 RABBIT_PASSWORD=rabbit
58 SERVICE_PASSWORD=admin
61 enable_plugin networking-odl ${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}
68 if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
69 echo "ODL_V2DRIVER=True" >> ${local_conf_file_name}
72 if [ "${NUM_ODL_SYSTEM}" -gt 1 ]; then
73 odl_list=${ODL_SYSTEM_1_IP}
74 for i in `seq 2 ${NUM_ODL_SYSTEM}`
76 odlip=ODL_SYSTEM_${i}_IP
77 odl_list=${odl_list},${!odlip}
79 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
80 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
81 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
82 odl_mgr_ip=${!odlmgrip}
84 odl_mgr_ip=${ODL_SYSTEM_1_IP}
86 cat >> ${local_conf_file_name} << EOF
87 ODL_OVS_MANAGERS=${odl_list}
88 ODL_MGR_IP=${odl_mgr_ip}
91 cat >> ${local_conf_file_name} << EOF
92 ODL_MGR_IP=${ODL_SYSTEM_1_IP}
96 # if we are using the old netvirt impl, as determined by the feature name
97 # odl-ovsdb-openstack (note: new impl is odl-netvirt-openstack) then we
98 # want ODL_L3 to be True. New impl wants it False
99 if [[ ${CONTROLLERFEATURES} == *"odl-ovsdb-openstack"* ]]; then
105 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
106 cat >> ${local_conf_file_name} << EOF
108 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
109 ODL_PROVIDER_MAPPINGS=${PUBLIC_BRIDGE}:br100
114 PUBLIC_INTERFACE=br100
118 cat >> ${local_conf_file_name} << EOF
119 [[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
121 minimize_polling=True
123 [[post-config|/etc/neutron/dhcp_agent.ini]]
125 force_metadata = True
126 enable_isolated_metadata = True
128 [[post-config|/etc/nova/nova.conf]]
130 force_config_drive = False
134 echo "local.conf Created...."
135 cat ${local_conf_file_name}
138 function create_compute_node_local_conf {
140 local_conf_file_name=${WORKSPACE}/local.conf_compute_${HOSTIP}
141 cat > ${local_conf_file_name} << EOF
145 SCREEN_LOGDIR=/opt/stack/data/log
148 NOVA_VNC_ENABLED=True
150 ENABLED_SERVICES=n-cpu
153 SERVICE_HOST=${OPENSTACK_CONTROL_NODE_IP}
156 ENABLE_TENANT_TUNNELS=True
157 Q_ML2_TENANT_NETWORK_TYPE=vxlan
159 Q_HOST=\$SERVICE_HOST
160 MYSQL_HOST=\$SERVICE_HOST
161 RABBIT_HOST=\$SERVICE_HOST
162 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
163 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
164 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
167 RABBIT_PASSWORD=rabbit
168 SERVICE_TOKEN=service
169 SERVICE_PASSWORD=admin
172 enable_plugin networking-odl ${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}
178 if [ "${NUM_ODL_SYSTEM}" -gt 1 ]; then
179 odl_list=${ODL_SYSTEM_1_IP}
180 for i in `seq 2 ${NUM_ODL_SYSTEM}`
182 odlip=ODL_SYSTEM_${i}_IP
183 odl_list=${odl_list},${!odlip}
185 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
186 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
187 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
188 odl_mgr_ip=${!odlmgrip}
190 odl_mgr_ip=${ODL_SYSTEM_1_IP}
192 cat >> ${local_conf_file_name} << EOF
193 ODL_OVS_MANAGERS=${odl_list}
194 ODL_MGR_IP=${odl_mgr_ip}
197 cat >> ${local_conf_file_name} << EOF
198 ODL_MGR_IP=${ODL_SYSTEM_1_IP}
202 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
203 cat >> ${local_conf_file_name} << EOF
204 # Uncomment lines below if odl-compute is to be used for l3 forwarding
207 PUBLIC_INTERFACE=br100
210 echo "local.conf Created...."
211 cat ${local_conf_file_name}
214 function configure_haproxy_for_neutron_requests () {
215 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
216 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
217 ha_proxy_ip=${!odlmgrip}
219 cat > ${WORKSPACE}/install_ha_proxy.sh<< EOF
220 sudo systemctl stop firewalld
221 sudo yum -y install policycoreutils-python haproxy
224 cat > ${WORKSPACE}/haproxy.cfg << EOF
230 pidfile /tmp/haproxy.pid
238 timeout http-request 10s
246 bind ${ha_proxy_ip}:8080
250 for i in `seq 1 ${NUM_ODL_SYSTEM}`
252 odlip=ODL_SYSTEM_${i}_IP
253 cat >> ${WORKSPACE}/haproxy.cfg << EOF
254 server controller-$i ${!odlip}:8080 check fall 5 inter 2000 rise 2
258 cat > ${WORKSPACE}/deploy_ha_proxy.sh<< EOF
259 sudo chown haproxy:haproxy /tmp/haproxy.cfg
260 sudo sed -i 's/\\/etc\\/haproxy\\/haproxy.cfg/\\/tmp\\/haproxy.cfg/g' /usr/lib/systemd/system/haproxy.service
261 sudo /usr/sbin/semanage permissive -a haproxy_t
262 sudo systemctl restart haproxy
265 sudo systemctl status haproxy
268 scp ${WORKSPACE}/install_ha_proxy.sh ${ha_proxy_ip}:/tmp
269 ${SSH} ${ha_proxy_ip} "sudo bash /tmp/install_ha_proxy.sh"
270 scp ${WORKSPACE}/haproxy.cfg ${ha_proxy_ip}:/tmp
271 scp ${WORKSPACE}/deploy_ha_proxy.sh ${ha_proxy_ip}:/tmp
272 ${SSH} ${ha_proxy_ip} "sudo bash /tmp/deploy_ha_proxy.sh"
275 function collect_logs_and_exit (){
276 set +e # We do not want to create red dot just because something went wrong while fetching logs.
277 for i in `seq 1 ${NUM_ODL_SYSTEM}`
279 CONTROLLERIP=ODL_SYSTEM_${i}_IP
280 echo "killing karaf process..."
281 ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
285 # FIXME: Do not create .tar and gzip before copying.
286 for i in `seq 1 ${NUM_ODL_SYSTEM}`
288 CONTROLLERIP=ODL_SYSTEM_${i}_IP
289 ${SSH} "${!CONTROLLERIP}" "cp -r /tmp/${BUNDLEFOLDER}/data/log /tmp/odl_log"
290 ${SSH} "${!CONTROLLERIP}" "tar -cf /tmp/odl${i}_karaf.log.tar /tmp/odl_log/*"
291 scp "${!CONTROLLERIP}:/tmp/odl${i}_karaf.log.tar" "${WORKSPACE}/odl${i}_karaf.log.tar"
292 tar -xvf ${WORKSPACE}/odl${i}_karaf.log.tar -C . --strip-components 2 --transform s/karaf/odl${i}_karaf/g
293 rm ${WORKSPACE}/odl${i}_karaf.log.tar
296 scp ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/devstack/nohup.out "openstack_control_stack.log"
297 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "tar -cf /tmp/control_node_openstack_logs.tgz /opt/stack/logs/*"
298 scp "${OPENSTACK_CONTROL_NODE_IP}:/tmp/control_node_openstack_logs.tgz" control_node_openstack_logs.tgz
299 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
301 OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
302 scp "${!OSIP}:/opt/stack/devstack/nohup.out" "openstack_compute_stack_${i}.log"
303 ${SSH} "${!OSIP}" "tar -cf /tmp/compute_node_${i}_openstack_logs.tgz /opt/stack/logs/*"
304 scp "${!OSIP}:/tmp/compute_node_${i}_openstack_logs.tgz" "compute_node_${i}_openstack_logs.tgz"
308 cat > ${WORKSPACE}/disable_firewall.sh << EOF
309 sudo systemctl stop firewalld
310 sudo systemctl stop iptables
314 cat > ${WORKSPACE}/get_devstack.sh << EOF
315 sudo systemctl stop firewalld
316 sudo yum install bridge-utils -y
317 sudo systemctl stop NetworkManager
318 #Disable NetworkManager and kill dhclient and dnsmasq
319 sudo systemctl stop NetworkManager
320 sudo killall dhclient
322 #Workaround for mysql failure
323 echo "127.0.0.1 localhost \${HOSTNAME}" > /tmp/hosts
324 echo "::1 localhost \${HOSTNAME}" >> /tmp/hosts
325 sudo mv /tmp/hosts /etc/hosts
326 sudo /usr/sbin/brctl addbr br100
327 #sudo ifconfig eth0 mtu 2000
328 sudo mkdir /opt/stack
329 sudo chmod 777 /opt/stack
331 git clone https://git.openstack.org/openstack-dev/devstack
333 git checkout $OPENSTACK_BRANCH
336 echo "Create HAProxy if needed"
337 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
338 echo "Need to configure HAProxy"
339 configure_haproxy_for_neutron_requests
343 echo "Stack the Control Node"
344 scp ${WORKSPACE}/get_devstack.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
345 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "bash /tmp/get_devstack.sh"
346 create_control_node_local_conf
347 scp ${WORKSPACE}/local.conf_control ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/devstack/local.conf
348 ssh ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
349 ssh ${OPENSTACK_CONTROL_NODE_IP} "ps -ef | grep stack.sh"
350 ssh ${OPENSTACK_CONTROL_NODE_IP} "ls -lrt /opt/stack/devstack/nohup.out"
351 os_node_list+=(${OPENSTACK_CONTROL_NODE_IP})
354 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
356 COMPUTEIP=OPENSTACK_COMPUTE_NODE_${i}_IP
357 scp ${WORKSPACE}/get_devstack.sh ${!COMPUTEIP}:/tmp
358 ${SSH} ${!COMPUTEIP} "bash /tmp/get_devstack.sh"
359 create_compute_node_local_conf ${!COMPUTEIP}
360 scp ${WORKSPACE}/local.conf_compute_${!COMPUTEIP} ${!COMPUTEIP}:/opt/stack/devstack/local.conf
361 ssh ${!COMPUTEIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
362 ssh ${!COMPUTEIP} "ps -ef | grep stack.sh"
363 os_node_list+=(${!COMPUTEIP})
366 cat > ${WORKSPACE}/check_stacking.sh << EOF
367 > /tmp/stack_progress
368 ps -ef | grep "stack.sh" | grep -v grep
370 if [ \${ret} -eq 1 ]; then
371 grep "This is your host IP address:" /opt/stack/devstack/nohup.out
372 if [ \$? -eq 0 ]; then
373 echo "Stacking Complete" > /tmp/stack_progress
375 echo "Stacking Failed" > /tmp/stack_progress
377 elif [ \${ret} -eq 0 ]; then
378 echo "Still Stacking" > /tmp/stack_progress
382 #the checking is repeated for an hour
385 while [ ${in_progress} -eq 1 ]; do
386 iteration=$(($iteration + 1))
387 for index in ${!os_node_list[@]}
389 echo "Check the status of stacking in ${os_node_list[index]}"
390 scp ${WORKSPACE}/check_stacking.sh ${os_node_list[index]}:/tmp
391 ${SSH} ${os_node_list[index]} "bash /tmp/check_stacking.sh"
392 scp ${os_node_list[index]}:/tmp/stack_progress .
395 stacking_status=`cat stack_progress`
396 if [ "$stacking_status" == "Still Stacking" ]; then
398 elif [ "$stacking_status" == "Stacking Failed" ]; then
399 collect_logs_and_exit
401 elif [ "$stacking_status" == "Stacking Complete" ]; then
402 unset os_node_list[index]
403 if [ ${#os_node_list[@]} -eq 0 ]; then
408 echo "sleep for a minute before the next check"
410 if [ ${iteration} -eq 60 ]; then
411 collect_logs_and_exit
416 #Need to disable firewalld and iptables in control node
417 echo "Stop Firewall in Control Node for compute nodes to be able to reach the ports and add to hypervisor-list"
418 scp ${WORKSPACE}/disable_firewall.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
419 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo bash /tmp/disable_firewall.sh"
420 echo "sleep for a minute and print hypervisor-list"
422 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack/devstack; source openrc admin admin; nova hypervisor-list"
424 #Need to disable firewalld and iptables in compute nodes as well
425 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
427 OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
428 scp ${WORKSPACE}/disable_firewall.sh "${!OSIP}:/tmp"
429 ${SSH} "${!OSIP}" "sudo bash /tmp/disable_firewall.sh"
432 # upgrading pip, urllib3 and httplib2 so that tempest tests can be run on ${OPENSTACK_CONTROL_NODE_IP}
433 # this needs to happen after devstack runs because it seems devstack is pulling in specific versions
434 # of these libs that are not working for tempest.
435 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install --upgrade pip"
436 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install urllib3 --upgrade"
437 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install httplib2 --upgrade"
439 echo "Locating test plan to use..."
440 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
441 if [ ! -f "${testplan_filepath}" ]; then
442 testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
445 echo "Changing the testplan path..."
446 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
449 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
451 echo "Starting Robot test suites ${SUITES} ..."
452 pybot -N ${TESTPLAN} --removekeywords wuks -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
453 -v BUNDLE_URL:${ACTUALBUNDLEURL} -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} -v JDKVERSION:${JDKVERSION} -v ODL_STREAM:${DISTROSTREAM} \
454 -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_1_IP} -v ODL_SYSTEM_2_IP:${ODL_SYSTEM_2_IP} \
455 -v ODL_SYSTEM_3_IP:${ODL_SYSTEM_3_IP} -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} -v CONTROLLER_USER:${USER} -v OS_USER:${USER} \
456 -v NUM_OS_SYSTEM:${NUM_OPENSTACK_SYSTEM} -v OS_CONTROL_NODE_IP:${OPENSTACK_CONTROL_NODE_IP} \
457 -v OS_COMPUTE_1_IP:${OPENSTACK_COMPUTE_NODE_1_IP} -v OS_COMPUTE_2_IP:${OPENSTACK_COMPUTE_NODE_2_IP} \
458 -v DEVSTACK_DEPLOY_PATH:/opt/stack/devstack -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
460 echo "Tests Executed"
461 DEVSTACK_TEMPEST_DIR="/opt/stack/tempest"
462 if $(ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo sh -c '[ -f ${DEVSTACK_TEMPEST_DIR}/.testrepository/0 ]'"); then # if Tempest results exist
463 ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo sh -c '${DEVSTACK_TEMPEST_DIR}/.tox/tempest/bin/subunit-1to2 < ${DEVSTACK_TEMPEST_DIR}/.testrepository/0 > ${DEVSTACK_TEMPEST_DIR}/subunit_log.txt'"
464 ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo sh -c '${DEVSTACK_TEMPEST_DIR}/.tox/tempest/bin/python ${DEVSTACK_TEMPEST_DIR}/.tox/tempest/lib/python2.7/site-packages/os_testr/subunit2html.py ${DEVSTACK_TEMPEST_DIR}/subunit_log.txt ${DEVSTACK_TEMPEST_DIR}/tempest_results.html'"
465 scp ${OPENSTACK_CONTROL_NODE_IP}:${DEVSTACK_TEMPEST_DIR}/tempest_results.html ${WORKSPACE}/
467 collect_logs_and_exit
469 true # perhaps Jenkins is testing last exit code
470 # vim: ts=4 sw=4 sts=4 et ft=sh :