2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
5 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
6 source ${ROBOT_VENV}/bin/activate
7 PYTHON="${ROBOT_VENV}/bin/python"
10 OPENSTACK_MASTER_CLIENTS_VERSION="pike"
12 # TODO: remove this work to run changes.py if/when it's moved higher up to be visible at the Robot level
13 echo "showing recent changes that made it in to the distribution used by this job"
14 $PYTHON -m pip install --upgrade urllib3
15 python ${WORKSPACE}/test/tools/distchanges/changes.py -d /tmp/distribution_folder \
16 -u ${ACTUAL_BUNDLE_URL} -b ${DISTROBRANCH} \
17 -r ssh://jenkins-${SILO}@git.opendaylight.org:29418 || true
19 #################################################
20 ## Deploy Openstack 3-node ##
21 #################################################
24 # Catch command errors and collect logs.
25 # This ensures logs are collected when script commands fail rather than simply exiting.
26 function trap_handler() {
30 echo "${prog}: line ${lastline}: exit status of last command: ${lasterr}"
31 echo "command: ${BASH_COMMAND}"
36 trap 'trap_handler ${LINENO} ${$?}' ERR
38 function print_job_parameters() {
42 DISTROBRANCH: ${DISTROBRANCH}
43 DISTROSTREAM: ${DISTROSTREAM}
44 BUNDLE_URL: ${BUNDLE_URL}
45 CONTROLLERFEATURES: ${CONTROLLERFEATURES}
46 CONTROLLERDEBUGMAP: ${CONTROLLERDEBUGMAP}
49 PATCHREFSPEC: ${PATCHREFSPEC}
50 OPENSTACK_BRANCH: ${OPENSTACK_BRANCH}
51 DEVSTACK_HASH: ${DEVSTACK_HASH}
52 ODL_ML2_DRIVER_REPO: ${ODL_ML2_DRIVER_REPO}
53 ODL_ML2_BRANCH: ${ODL_ML2_BRANCH}
54 ODL_ML2_DRIVER_VERSION: ${ODL_ML2_DRIVER_VERSION}
55 ODL_ML2_PORT_BINDING: ${ODL_ML2_PORT_BINDING}
56 DEVSTACK_KUBERNETES_PLUGIN_REPO: ${DEVSTACK_KUBERNETES_PLUGIN_REPO}
57 DEVSTACK_LBAAS_PLUGIN_REPO: ${DEVSTACK_LBAAS_PLUGIN_REPO}
58 DEVSTACK_NETWORKING_SFC_PLUGIN_REPO: ${DEVSTACK_NETWORKING_SFC_PLUGIN_REPO}
59 ODL_ENABLE_L3_FWD: ${ODL_ENABLE_L3_FWD}
60 IPSEC_VXLAN_TUNNELS_ENABLED: ${IPSEC_VXLAN_TUNNELS_ENABLED}
61 PUBLIC_BRIDGE: ${PUBLIC_BRIDGE}
62 ENABLE_HAPROXY_FOR_NEUTRON: ${ENABLE_HAPROXY_FOR_NEUTRON}
63 ENABLE_OS_SERVICES: ${ENABLE_OS_SERVICES}
64 ENABLE_OS_COMPUTE_SERVICES: ${ENABLE_OS_COMPUTE_SERVICES}
65 ENABLE_OS_PLUGINS: ${ENABLE_OS_PLUGINS}
66 DISABLE_OS_SERVICES: ${DISABLE_OS_SERVICES}
67 TENANT_NETWORK_TYPE: ${TENANT_NETWORK_TYPE}
68 SECURITY_GROUP_MODE: ${SECURITY_GROUP_MODE}
69 PUBLIC_PHYSICAL_NETWORK: ${PUBLIC_PHYSICAL_NETWORK}
70 ENABLE_NETWORKING_L2GW: ${ENABLE_NETWORKING_L2GW}
71 CREATE_INITIAL_NETWORKS: ${CREATE_INITIAL_NETWORKS}
72 LBAAS_SERVICE_PROVIDER: ${LBAAS_SERVICE_PROVIDER}
73 NUM_OPENSTACK_SITES: ${NUM_OPENSTACK_SITES}
74 ODL_SFC_DRIVER: ${ODL_SFC_DRIVER}
75 ODL_SNAT_MODE: ${ODL_SNAT_MODE}
82 function create_etc_hosts() {
85 : > ${WORKSPACE}/hosts_file
86 for iter in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`
88 COMPUTE_IP=OPENSTACK_COMPUTE_NODE_${iter}_IP
89 if [ "${!COMPUTE_IP}" == "${NODE_IP}" ]; then
90 CONTROL_HNAME=$(${SSH} ${CTRL_IP} "hostname")
91 echo "${CTRL_IP} ${CONTROL_HNAME}" >> ${WORKSPACE}/hosts_file
93 COMPUTE_HNAME=$(${SSH} ${!COMPUTE_IP} "hostname")
94 echo "${!COMPUTE_IP} ${COMPUTE_HNAME}" >> ${WORKSPACE}/hosts_file
98 echo "Created the hosts file for ${NODE_IP}:"
99 cat ${WORKSPACE}/hosts_file
100 } # create_etc_hosts()
102 #function to install Openstack Clients for Testing
103 #This will pull the latest versions compatiable with the
105 function install_openstack_clients_in_robot_vm() {
106 packages=("python-novaclient" "python-neutronclient" "python-openstackclient")
107 for plugin_name in ${ENABLE_OS_PLUGINS}; do
108 if [ "$plugin_name" == "networking-sfc" ]; then
109 packages+=("networking-sfc")
112 openstack_version=$(echo ${OPENSTACK_BRANCH} | cut -d/ -f2)
113 #If the job tests "master", we will use the clients from previous released stable version to avoid failures
114 if [ "${openstack_version}" == "master" ]; then
115 openstack_version=${OPENSTACK_MASTER_CLIENTS_VERSION}
117 for package in ${packages[*]}; do
118 echo "Get the current support version of the package ${package}"
119 wget https://raw.githubusercontent.com/openstack/requirements/stable/${openstack_version}/upper-constraints.txt -O /tmp/constraints.txt 2>/dev/null
120 echo "$PYTHON -m pip install --upgrade --no-deps ${package} --no-cache-dir -c /tmp/constraints.txt"
121 $PYTHON -m pip install --upgrade --no-deps ${package} --no-cache-dir -c /tmp/constraints.txt
122 echo "$PYTHON -m pip install ${package} --no-cache-dir -c /tmp/constraints.txt"
123 $PYTHON -m pip install ${package} --no-cache-dir -c /tmp/constraints.txt
126 if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
127 #networking-l2gw is not officially available in any release yet. Gettting the latest stable version.
128 $PYTHON -m pip install networking-l2gw
134 # convert commas in csv strings to spaces (ssv)
137 if [ -n "${csv}" ]; then
138 ssv=$(echo ${csv} | sed 's/,/ /g' | sed 's/\ \ */\ /g')
144 # Add enable_services and disable_services to the local.conf
145 function add_os_services() {
146 local core_services=$1
147 local enable_services=$2
148 local disable_services=$3
149 local local_conf_file_name=$4
151 cat >> ${local_conf_file_name} << EOF
152 enable_service $(csv2ssv "${core_services}")
154 if [ -n "${enable_services}" ]; then
155 cat >> ${local_conf_file_name} << EOF
156 enable_service $(csv2ssv "${enable_services}")
159 if [ -n "${disable_services}" ]; then
160 cat >> ${local_conf_file_name} << EOF
161 disable_service $(csv2ssv "${disable_services}")
166 function create_control_node_local_conf() {
169 ODL_OVS_MANAGERS="$3"
171 local_conf_file_name=${WORKSPACE}/local.conf_control_${HOSTIP}
172 cat > ${local_conf_file_name} << EOF
176 SCREEN_LOGDIR=/opt/stack/data/log
183 add_os_services "${CORE_OS_CONTROL_SERVICES}" "${ENABLE_OS_SERVICES}" "${DISABLE_OS_SERVICES}" "${local_conf_file_name}"
185 cat >> ${local_conf_file_name} << EOF
188 SERVICE_HOST=\$HOST_IP
189 Q_ML2_TENANT_NETWORK_TYPE=${TENANT_NETWORK_TYPE}
190 NEUTRON_CREATE_INITIAL_NETWORKS=${CREATE_INITIAL_NETWORKS}
195 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
196 ODL_OVS_MANAGERS=${ODL_OVS_MANAGERS}
198 MYSQL_HOST=\$SERVICE_HOST
199 RABBIT_HOST=\$SERVICE_HOST
200 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
201 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
202 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
204 ADMIN_PASSWORD=${ADMIN_PASSWORD}
205 DATABASE_PASSWORD=${ADMIN_PASSWORD}
206 RABBIT_PASSWORD=${ADMIN_PASSWORD}
207 SERVICE_TOKEN=${ADMIN_PASSWORD}
208 SERVICE_PASSWORD=${ADMIN_PASSWORD}
210 NEUTRON_LBAAS_SERVICE_PROVIDERV2=${LBAAS_SERVICE_PROVIDER} # Only relevant if neutron-lbaas plugin is enabled
211 NEUTRON_SFC_DRIVERS=${ODL_SFC_DRIVER} # Only relevant if networking-sfc plugin is enabled
212 NEUTRON_FLOWCLASSIFIER_DRIVERS=${ODL_SFC_DRIVER} # Only relevant if networking-sfc plugin is enabled
216 if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
217 echo "ODL_V2DRIVER=True" >> ${local_conf_file_name}
221 for plugin_name in ${ENABLE_OS_PLUGINS}; do
222 if [ "$plugin_name" == "networking-odl" ]; then
223 ENABLE_PLUGIN_ARGS="${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}"
224 elif [ "$plugin_name" == "kuryr-kubernetes" ]; then
225 ENABLE_PLUGIN_ARGS="${DEVSTACK_KUBERNETES_PLUGIN_REPO} master" # note: kuryr-kubernetes only exists in master at the moment
226 elif [ "$plugin_name" == "neutron-lbaas" ]; then
227 ENABLE_PLUGIN_ARGS="${DEVSTACK_LBAAS_PLUGIN_REPO} ${OPENSTACK_BRANCH}"
228 IS_LBAAS_PLUGIN_ENABLED="yes"
229 elif [ "$plugin_name" == "networking-sfc" ]; then
230 ENABLE_PLUGIN_ARGS="${DEVSTACK_NETWORKING_SFC_PLUGIN_REPO} ${OPENSTACK_BRANCH}"
232 echo "Error: Invalid plugin $plugin_name, unsupported"
235 cat >> ${local_conf_file_name} << EOF
237 enable_plugin ${plugin_name} ${ENABLE_PLUGIN_ARGS}
242 if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
243 cat >> ${local_conf_file_name} << EOF
245 enable_plugin networking-l2gw ${NETWORKING_L2GW_DRIVER} ${ODL_ML2_BRANCH}
246 NETWORKING_L2GW_SERVICE_DRIVER=L2GW:OpenDaylight:networking_odl.l2gateway.driver.OpenDaylightL2gwDriver:default
250 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
251 cat >> ${local_conf_file_name} << EOF
253 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
254 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
255 ML2_VLAN_RANGES=${PUBLIC_PHYSICAL_NETWORK}
256 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
259 if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
260 SERVICE_PLUGINS="odl-router_v2"
262 SERVICE_PLUGINS="odl-router"
264 if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
265 SERVICE_PLUGINS+=", networking_l2gw.services.l2gateway.plugin.L2GatewayPlugin"
267 if [ "${IS_LBAAS_PLUGIN_ENABLED}" == "yes" ]; then
268 SERVICE_PLUGINS+=", lbaasv2"
270 fi #check for ODL_ENABLE_L3_FWD
272 cat >> ${local_conf_file_name} << EOF
274 [[post-config|\$NEUTRON_CONF]]
276 service_plugins = ${SERVICE_PLUGINS}
278 [[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
280 minimize_polling=True
283 # Needed for VLAN provider tests - because our provider networks are always encapsulated in VXLAN (br-physnet1)
284 # MTU(1400) + VXLAN(50) + VLAN(4) = 1454 < MTU eth0/br-physnet1(1458)
285 physical_network_mtus = ${PUBLIC_PHYSICAL_NETWORK}:1400
288 # workaround for port-status not working due to https://bugs.opendaylight.org/show_bug.cgi?id=9092
292 [[post-config|/etc/neutron/dhcp_agent.ini]]
294 force_metadata = True
295 enable_isolated_metadata = True
297 [[post-config|/etc/nova/nova.conf]]
299 force_config_drive = False
300 force_raw_images = False
303 discover_hosts_in_cells_interval = 30
306 echo "Control local.conf created:"
307 cat ${local_conf_file_name}
308 } # create_control_node_local_conf()
310 function create_compute_node_local_conf() {
314 ODL_OVS_MANAGERS="$4"
316 local_conf_file_name=${WORKSPACE}/local.conf_compute_${HOSTIP}
317 cat > ${local_conf_file_name} << EOF
322 SCREEN_LOGDIR=/opt/stack/data/log
328 add_os_services "${CORE_OS_COMPUTE_SERVICES}" "${ENABLE_OS_COMPUTE_SERVICES}" "${DISABLE_OS_SERVICES}" "${local_conf_file_name}"
330 cat >> ${local_conf_file_name} << EOF
333 SERVICE_HOST=${SERVICEHOST}
334 Q_ML2_TENANT_NETWORK_TYPE=${TENANT_NETWORK_TYPE}
339 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
340 ODL_OVS_MANAGERS=${ODL_OVS_MANAGERS}
342 Q_HOST=\$SERVICE_HOST
343 MYSQL_HOST=\$SERVICE_HOST
344 RABBIT_HOST=\$SERVICE_HOST
345 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
346 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
347 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
349 ADMIN_PASSWORD=${ADMIN_PASSWORD}
350 DATABASE_PASSWORD=${ADMIN_PASSWORD}
351 RABBIT_PASSWORD=${ADMIN_PASSWORD}
352 SERVICE_TOKEN=${ADMIN_PASSWORD}
353 SERVICE_PASSWORD=${ADMIN_PASSWORD}
356 if [[ "${ENABLE_OS_PLUGINS}" =~ networking-odl ]]; then
357 cat >> ${local_conf_file_name} << EOF
359 enable_plugin networking-odl ${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}
363 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
364 cat >> ${local_conf_file_name} << EOF
366 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
367 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
368 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
374 cat >> ${local_conf_file_name} << EOF
376 [[post-config|/etc/nova/nova.conf]]
378 auth_strategy = keystone
381 force_raw_images = False
384 echo "Compute local.conf created:"
385 cat ${local_conf_file_name}
386 } # create_compute_node_local_conf()
388 function configure_haproxy_for_neutron_requests() {
390 # shellcheck disable=SC2206
393 cat > ${WORKSPACE}/install_ha_proxy.sh<< EOF
394 sudo systemctl stop firewalld
395 sudo yum -y install policycoreutils-python haproxy
398 cat > ${WORKSPACE}/haproxy.cfg << EOF
404 pidfile /tmp/haproxy.pid
412 timeout http-request 10s
425 for odlip in ${ODL_IPS[*]}; do
426 cat >> ${WORKSPACE}/haproxy.cfg << EOF
427 server controller-${odlindex} ${odlip}:8080 check fall 5 inter 2000 rise 2
429 odlindex=$((odlindex+1))
432 cat >> ${WORKSPACE}/haproxy.cfg << EOF
433 listen opendaylight_rest
439 for odlip in ${ODL_IPS[*]}; do
440 cat >> ${WORKSPACE}/haproxy.cfg << EOF
441 server controller-rest-${odlindex} ${odlip}:8181 check fall 5 inter 2000 rise 2
443 odlindex=$((odlindex+1))
446 echo "Dump haproxy.cfg"
447 cat ${WORKSPACE}/haproxy.cfg
449 cat > ${WORKSPACE}/deploy_ha_proxy.sh<< EOF
450 sudo chown haproxy:haproxy /tmp/haproxy.cfg
451 sudo sed -i 's/\\/etc\\/haproxy\\/haproxy.cfg/\\/tmp\\/haproxy.cfg/g' /usr/lib/systemd/system/haproxy.service
452 sudo /usr/sbin/semanage permissive -a haproxy_t
453 sudo systemctl restart haproxy
456 sudo systemctl status haproxy
460 scp ${WORKSPACE}/install_ha_proxy.sh ${MGRIP}:/tmp
461 ${SSH} ${MGRIP} "sudo bash /tmp/install_ha_proxy.sh"
462 scp ${WORKSPACE}/haproxy.cfg ${MGRIP}:/tmp
463 scp ${WORKSPACE}/deploy_ha_proxy.sh ${MGRIP}:/tmp
464 ${SSH} ${MGRIP} "sudo bash /tmp/deploy_ha_proxy.sh"
465 } # configure_haproxy_for_neutron_requests()
467 # Collect the list of files on the hosts
468 function list_files () {
471 ${SSH} ${ip} "sudo find /etc > /tmp/find.etc.txt"
472 ${SSH} ${ip} "sudo find /opt/stack > /tmp/find.opt.stack.txt"
473 ${SSH} ${ip} "sudo find /var > /tmp/find2.txt"
474 ${SSH} ${ip} "sudo find /var > /tmp/find.var.txt"
475 rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/etc/ > ${folder}/rsync.etc.txt
476 rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/opt/stack/ > ${folder}/rsync.opt.stack.txt
477 rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/var/ > ${folder}/rsync.var.txt
478 scp ${ip}:/tmp/find.etc.txt ${folder}
479 scp ${ip}:/tmp/find.opt.stack.txt ${folder}
480 scp ${ip}:/tmp/find2.txt ${folder}
481 scp ${ip}:/tmp/find.var.txt ${folder}
484 function collect_logs () {
485 set +e # We do not want to create red dot just because something went wrong while fetching logs.
487 cat > extra_debug.sh << EOF
488 echo -e "/usr/sbin/lsmod | /usr/bin/grep openvswitch\n"
489 /usr/sbin/lsmod | /usr/bin/grep openvswitch
490 echo -e "\ngrep ct_ /var/log/openvswitch/ovs-vswitchd.log\n"
491 grep "Datapath supports" /var/log/openvswitch/ovs-vswitchd.log
492 echo -e "\nsudo netstat -punta\n"
494 echo -e "\nsudo getenforce\n"
496 echo -e "\nsudo systemctl status httpd\n"
497 sudo systemctl status httpd
500 source /opt/stack/devstack/openrc admin admin
501 echo -e "\nenv after openrc\n"
503 echo -e "\nsudo du -hs /opt/stack"
504 sudo du -hs /opt/stack
505 echo -e "\nsudo mount"
507 echo -e "\ndmesg -T > /tmp/dmesg.log"
508 dmesg -T > /tmp/dmesg.log
509 echo -e "\njournalctl > /tmp/journalctl.log\n"
510 sudo journalctl > /tmp/journalctl.log
511 echo -e "\novsdb-tool -mm show-log > /tmp/ovsdb-tool.log"
512 ovsdb-tool -mm show-log > /tmp/ovsdb-tool.log
515 # Since this log collection work is happening before the archive build macro which also
516 # creates the ${WORKSPACE}/archives dir, we have to do it here first. The mkdir in the
517 # archives build step will essentially be a noop.
518 mkdir -p ${WORKSPACE}/archives
521 # FIXME: Do not create .tar and gzip before copying.
522 for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
523 CONTROLLERIP=ODL_SYSTEM_${i}_IP
524 echo "collect_logs: for opendaylight controller ip: ${!CONTROLLERIP}"
525 NODE_FOLDER="odl_${i}"
526 mkdir -p ${NODE_FOLDER}
527 echo "Lets's take the karaf thread dump again..."
528 ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
529 pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
530 echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
531 ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
532 echo "killing karaf process..."
533 ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
534 ${SSH} ${!CONTROLLERIP} "sudo journalctl > /tmp/journalctl.log"
535 scp ${!CONTROLLERIP}:/tmp/journalctl.log ${NODE_FOLDER}
536 ${SSH} ${!CONTROLLERIP} "dmesg -T > /tmp/dmesg.log"
537 scp ${!CONTROLLERIP}:/tmp/dmesg.log ${NODE_FOLDER}
538 ${SSH} ${!CONTROLLERIP} "cp -r /tmp/${BUNDLEFOLDER}/data/log /tmp/odl_log"
539 ${SSH} ${!CONTROLLERIP} "tar -cf /tmp/odl${i}_karaf.log.tar /tmp/odl_log/*"
540 scp ${!CONTROLLERIP}:/tmp/odl${i}_karaf.log.tar ${NODE_FOLDER}
541 ${SSH} ${!CONTROLLERIP} "tar -cf /tmp/odl${i}_zrpcd.log.tar /tmp/zrpcd.init.log"
542 scp ${!CONTROLLERIP}:/tmp/odl${i}_zrpcd.log.tar ${NODE_FOLDER}
543 tar -xvf ${NODE_FOLDER}/odl${i}_karaf.log.tar -C ${NODE_FOLDER} --strip-components 2 --transform s/karaf/odl${i}_karaf/g
544 grep "ROBOT MESSAGE\| ERROR " ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_err.log
545 grep "ROBOT MESSAGE\| ERROR \| WARN \|Exception" \
546 ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_err_warn_exception.log
547 # Print ROBOT lines and print Exception lines. For exception lines also print the previous line for context
548 sed -n -e '/ROBOT MESSAGE/P' -e '$!N;/Exception/P;D' ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_exception.log
549 rm ${NODE_FOLDER}/odl${i}_karaf.log.tar
550 mv *_threads* ${NODE_FOLDER}
551 mv ps_* ${NODE_FOLDER}
552 mv ${NODE_FOLDER} ${WORKSPACE}/archives/
555 print_job_parameters > ${WORKSPACE}/archives/params.txt
558 for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`; do
559 OSIP=OPENSTACK_CONTROL_NODE_${i}_IP
560 echo "collect_logs: for openstack control node ip: ${!OSIP}"
561 NODE_FOLDER="control_${i}"
562 mkdir -p ${NODE_FOLDER}
563 scp extra_debug.sh ${!OSIP}:/tmp
564 ${SSH} ${!OSIP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
565 scp ${!OSIP}:/etc/dnsmasq.conf ${NODE_FOLDER}
566 scp ${!OSIP}:/etc/keystone/keystone.conf ${NODE_FOLDER}
567 scp ${!OSIP}:/etc/keystone/keystone-uwsgi-admin.ini ${NODE_FOLDER}
568 scp ${!OSIP}:/etc/keystone/keystone-uwsgi-public.ini ${NODE_FOLDER}
569 scp ${!OSIP}:/etc/kuryr/kuryr.conf ${NODE_FOLDER}
570 scp ${!OSIP}:/etc/neutron/dhcp_agent.ini ${NODE_FOLDER}
571 scp ${!OSIP}:/etc/neutron/metadata_agent.ini ${NODE_FOLDER}
572 scp ${!OSIP}:/etc/neutron/neutron.conf ${NODE_FOLDER}
573 scp ${!OSIP}:/etc/neutron/neutron_lbaas.conf ${NODE_FOLDER}
574 scp ${!OSIP}:/etc/neutron/plugins/ml2/ml2_conf.ini ${NODE_FOLDER}
575 scp ${!OSIP}:/etc/neutron/services/loadbalancer/haproxy/lbaas_agent.ini ${NODE_FOLDER}
576 scp ${!OSIP}:/etc/nova/nova.conf ${NODE_FOLDER}
577 scp ${!OSIP}:/etc/nova/nova-api-uwsgi.ini ${NODE_FOLDER}
578 scp ${!OSIP}:/etc/nova/nova_cell1.conf ${NODE_FOLDER}
579 scp ${!OSIP}:/etc/nova/nova-cpu.conf ${NODE_FOLDER}
580 scp ${!OSIP}:/etc/nova/placement-uwsgi.ini ${NODE_FOLDER}
581 scp ${!OSIP}:/etc/openstack/clouds.yaml ${NODE_FOLDER}
582 scp ${!OSIP}:/opt/stack/devstack/.stackenv ${NODE_FOLDER}
583 scp ${!OSIP}:/opt/stack/devstack/nohup.out ${NODE_FOLDER}/stack.log
584 scp ${!OSIP}:/opt/stack/devstack/openrc ${NODE_FOLDER}
585 scp ${!OSIP}:/opt/stack/requirements/upper-constraints.txt ${NODE_FOLDER}
586 scp ${!OSIP}:/opt/stack/tempest/etc/tempest.conf ${NODE_FOLDER}
587 scp ${!OSIP}:/tmp/*.xz ${NODE_FOLDER}
588 scp ${!OSIP}:/tmp/dmesg.log ${NODE_FOLDER}
589 scp ${!OSIP}:/tmp/extra_debug.log ${NODE_FOLDER}
590 scp ${!OSIP}:/tmp/get_devstack.sh.txt ${NODE_FOLDER}
591 scp ${!OSIP}:/tmp/journalctl.log ${NODE_FOLDER}
592 scp ${!OSIP}:/tmp/ovsdb-tool.log ${NODE_FOLDER}
593 scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${NODE_FOLDER}
594 scp ${!OSIP}:/var/log/openvswitch/ovsdb-server.log ${NODE_FOLDER}
595 list_files "${!OSIP}" "${NODE_FOLDER}"
596 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/etc/hosts ${NODE_FOLDER}
597 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/usr/lib/systemd/system/haproxy.service ${NODE_FOLDER}
598 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/audit/audit.log ${NODE_FOLDER}
599 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/httpd/keystone_access.log ${NODE_FOLDER}
600 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/httpd/keystone.log ${NODE_FOLDER}
601 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/messages ${NODE_FOLDER}
602 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/rabbitmq ${NODE_FOLDER}
603 rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${NODE_FOLDER} # rsync to prevent copying of symbolic links
604 mv local.conf_control_${!OSIP} ${NODE_FOLDER}/local.conf
605 # qdhcp files are created by robot tests
606 mv /tmp/qdhcp ${NODE_FOLDER}
607 mv ${NODE_FOLDER} ${WORKSPACE}/archives/
611 for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`; do
612 OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
613 echo "collect_logs: for openstack compute node ip: ${!OSIP}"
614 NODE_FOLDER="compute_${i}"
615 mkdir -p ${NODE_FOLDER}
616 scp extra_debug.sh ${!OSIP}:/tmp
617 ${SSH} ${!OSIP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
618 scp ${!OSIP}:/etc/nova/nova.conf ${NODE_FOLDER}
619 scp ${!OSIP}:/etc/nova/nova-cpu.conf ${NODE_FOLDER}
620 scp ${!OSIP}:/etc/openstack/clouds.yaml ${NODE_FOLDER}
621 scp ${!OSIP}:/opt/stack/devstack/.stackenv ${NODE_FOLDER}
622 scp ${!OSIP}:/opt/stack/devstack/nohup.out ${NODE_FOLDER}/stack.log
623 scp ${!OSIP}:/opt/stack/devstack/openrc ${NODE_FOLDER}
624 scp ${!OSIP}:/opt/stack/requirements/upper-constraints.txt ${NODE_FOLDER}
625 scp ${!OSIP}:/tmp/*.xz ${NODE_FOLDER}/
626 scp ${!OSIP}:/tmp/dmesg.log ${NODE_FOLDER}
627 scp ${!OSIP}:/tmp/extra_debug.log ${NODE_FOLDER}
628 scp ${!OSIP}:/tmp/get_devstack.sh.txt ${NODE_FOLDER}
629 scp ${!OSIP}:/tmp/journalctl.log ${NODE_FOLDER}
630 scp ${!OSIP}:/tmp/ovsdb-tool.log ${NODE_FOLDER}
631 scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${NODE_FOLDER}
632 scp ${!OSIP}:/var/log/openvswitch/ovsdb-server.log ${NODE_FOLDER}
633 list_files "${!OSIP}" "${NODE_FOLDER}"
634 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/etc/hosts ${NODE_FOLDER}
635 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/audit/audit.log ${NODE_FOLDER}
636 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/libvirt ${NODE_FOLDER}
637 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/messages ${NODE_FOLDER}
638 rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/nova-agent.log ${NODE_FOLDER}
639 rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${NODE_FOLDER} # rsync to prevent copying of symbolic links
640 mv local.conf_compute_${!OSIP} ${NODE_FOLDER}/local.conf
641 mv ${NODE_FOLDER} ${WORKSPACE}/archives/
645 DEVSTACK_TEMPEST_DIR="/opt/stack/tempest"
647 TEMPEST_LOGS_DIR=${WORKSPACE}/archives/tempest
648 # Look for tempest test results in the $TESTREPO dir and copy if found
649 if ${SSH} ${OPENSTACK_CONTROL_NODE_1_IP} "sudo sh -c '[ -f ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/0 ]'"; then
650 ${SSH} ${OPENSTACK_CONTROL_NODE_1_IP} "for I in \$(sudo ls ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/ | grep -E '^[0-9]+$'); do sudo sh -c \"${DEVSTACK_TEMPEST_DIR}/.tox/tempest/bin/subunit-1to2 < ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/\${I} >> ${DEVSTACK_TEMPEST_DIR}/subunit_log.txt\"; done"
651 ${SSH} ${OPENSTACK_CONTROL_NODE_1_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'"
652 mkdir -p ${TEMPEST_LOGS_DIR}
653 scp ${OPENSTACK_CONTROL_NODE_1_IP}:${DEVSTACK_TEMPEST_DIR}/tempest_results.html ${TEMPEST_LOGS_DIR}
654 scp ${OPENSTACK_CONTROL_NODE_1_IP}:${DEVSTACK_TEMPEST_DIR}/tempest.log ${TEMPEST_LOGS_DIR}
655 mv ${WORKSPACE}/tempest_output* ${TEMPEST_LOGS_DIR}
657 echo "tempest results not found in ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/0"
661 # Following three functions are debugging helpers when debugging devstack changes.
662 # Keeping them for now so we can simply call them when needed.
666 function get_hostnames () {
668 local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
669 local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
670 local comp2ip=${OPENSTACK_COMPUTE_NODE_2_IP}
671 ctrlhn=$(${SSH} ${ctrlip} "hostname")
672 comp1hn=$(${SSH} ${comp1ip} "hostname")
673 comp2hn=$(${SSH} ${comp2ip} "hostname")
674 echo "hostnames: ${ctrlhn}, ${comp1hn}, ${comp2hn}"
678 function check_firewall() {
681 local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
682 local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
683 local comp2ip=${OPENSTACK_COMPUTE_NODE_2_IP}
685 echo "check_firewall on control"
687 sudo systemctl status firewalld
688 sudo systemctl -l status iptables
689 sudo iptables --line-numbers -nvL
691 echo "check_firewall on compute 1"
693 sudo systemctl status firewalld
694 sudo systemctl -l status iptables
695 sudo iptables --line-numbers -nvL
697 echo "check_firewall on compute 2"
699 sudo systemctl status firewalld
700 sudo systemctl -l status iptables
701 sudo iptables --line-numbers -nvL
705 function get_service () {
709 local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
710 local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
712 #if [ ${idx} -eq 1 ]; then
713 if [ ${iter} -eq 1 ] || [ ${iter} -gt 16 ]; then
714 curl http://${ctrlip}:5000
715 curl http://${ctrlip}:35357
716 curl http://${ctrlip}/identity
718 source /opt/stack/devstack/openrc admin admin;
720 openstack configuration show --unmask;
721 openstack service list
722 openstack --os-cloud devstack-admin --os-region RegionOne compute service list
723 openstack hypervisor list;
731 # Check if rabbitmq is ready by looking for a pid in it's status.
732 # The function returns the status of the grep command which callers can check.
733 function is_rabbitmq_ready() {
736 ${SSH} ${ip} "sudo rabbitmqctl status" > rabbit.txt
740 # retry the given command ($3) until success for a number of iterations ($1)
741 # sleeping ($2) between tries.
744 local -r -i max_tries=${1}
745 local -r -i sleep_time=${2}
750 echo "retry ${cmd}: attempt: ${retries}"
753 if ((${rc} == 0)); then
756 if ((${retries} == ${max_tries})); then
768 # if we are using the new netvirt impl, as determined by the feature name
769 # odl-netvirt-openstack (note: old impl is odl-ovsdb-openstack) then we
770 # want PROVIDER_MAPPINGS to be used -- this should be fixed if we want to support
771 # external networks in legacy netvirt
772 if [[ ${CONTROLLERFEATURES} == *"odl-netvirt-openstack"* ]]; then
773 ODL_PROVIDER_MAPPINGS="\${PUBLIC_PHYSICAL_NETWORK}:${PUBLIC_BRIDGE}"
775 ODL_PROVIDER_MAPPINGS=
778 # if we are using the old netvirt impl, as determined by the feature name
779 # odl-ovsdb-openstack (note: new impl is odl-netvirt-openstack) then we
780 # want ODL_L3 to be True. New impl wants it False
781 if [[ ${CONTROLLERFEATURES} == *"odl-ovsdb-openstack"* ]]; then
789 # Always compare the lists below against the devstack upstream ENABLED_SERVICES in
790 # https://github.com/openstack-dev/devstack/blob/master/stackrc#L52
791 # ODL CSIT does not use vnc, cinder, q-agt, q-l3 or horizon so they are not included below.
792 # collect performance stats
793 CORE_OS_CONTROL_SERVICES="dstat"
795 CORE_OS_CONTROL_SERVICES+=",g-api,g-reg"
797 CORE_OS_CONTROL_SERVICES+=",key"
798 # Nova - services to support libvirt
799 CORE_OS_CONTROL_SERVICES+=",n-api,n-api-meta,n-cauth,n-cond,n-crt,n-obj,n-sch"
800 # ODL - services to connect to ODL
801 CORE_OS_CONTROL_SERVICES+=",odl-compute,odl-neutron"
803 CORE_OS_CONTROL_SERVICES+=",q-dhcp,q-meta,q-svc"
804 # Additional services
805 CORE_OS_CONTROL_SERVICES+=",mysql,rabbit"
807 # computes only need nova and odl
808 CORE_OS_COMPUTE_SERVICES="n-cpu,odl-compute"
810 cat > ${WORKSPACE}/disable_firewall.sh << EOF
811 sudo systemctl stop firewalld
812 # Open these ports to match the tutorial vms
813 # http/https (80/443), samba (445), netbios (137,138,139)
814 sudo iptables -I INPUT -p tcp -m multiport --dports 80,443,139,445 -j ACCEPT
815 sudo iptables -I INPUT -p udp -m multiport --dports 137,138 -j ACCEPT
816 # OpenStack services as well as vxlan tunnel ports 4789 and 9876
817 # identity public/admin (5000/35357), ampq (5672), vnc (6080), nova (8774), glance (9292), neutron (9696)
818 sudo sudo iptables -I INPUT -p tcp -m multiport --dports 5000,5672,6080,8774,9292,9696,35357 -j ACCEPT
819 sudo sudo iptables -I INPUT -p udp -m multiport --dports 4789,9876 -j ACCEPT
820 sudo iptables-save > /etc/sysconfig/iptables
821 sudo systemctl restart iptables
822 sudo iptables --line-numbers -nvL
826 cat > ${WORKSPACE}/get_devstack.sh << EOF
827 sudo systemctl stop firewalld
828 sudo yum install bridge-utils python-pip -y
829 #sudo systemctl stop NetworkManager
830 #Disable NetworkManager and kill dhclient and dnsmasq
831 sudo systemctl stop NetworkManager
832 sudo killall dhclient
834 #Workaround for mysql failure
835 echo "127.0.0.1 localhost \${HOSTNAME}" >> /tmp/hosts
836 echo "::1 localhost \${HOSTNAME}" >> /tmp/hosts
837 sudo mv /tmp/hosts /etc/hosts
838 sudo mkdir /opt/stack
839 echo "Create RAM disk for /opt/stack"
840 sudo mount -t tmpfs -o size=2G tmpfs /opt/stack
841 sudo chmod 777 /opt/stack
843 echo "git clone https://git.openstack.org/openstack-dev/devstack --branch ${OPENSTACK_BRANCH}"
844 git clone https://git.openstack.org/openstack-dev/devstack --branch ${OPENSTACK_BRANCH}
846 if [ -n "${DEVSTACK_HASH}" ]; then
847 echo "git checkout ${DEVSTACK_HASH}"
848 git checkout ${DEVSTACK_HASH}
850 git --no-pager log --pretty=format:'%h %<(13)%ar%<(13)%cr %<(20,trunc)%an%d %s\n%b' -n20
851 echo "workaround: adjust wait from 60s to 1800s (30m)"
852 sed -i 's/wait_for_compute 60/wait_for_compute 1800/g' /opt/stack/devstack/lib/nova
853 # TODO: modify sleep 1 to sleep 60, search wait_for_compute, then first sleep 1
854 # that would just reduce the number of logs in the compute stack.log
856 #Install qemu-img command in Control Node for Pike
857 echo "Install qemu-img application"
858 sudo yum install -y qemu-img
861 cat > "${WORKSPACE}/setup_host_cell_mapping.sh" << EOF
862 sudo nova-manage cell_v2 map_cell0
863 sudo nova-manage cell_v2 simple_cell_setup
864 sudo nova-manage db sync
865 sudo nova-manage cell_v2 discover_hosts
868 NUM_OPENSTACK_SITES=${NUM_OPENSTACK_SITES:-1}
872 os_interval=$(( ${NUM_OPENSTACK_SYSTEM} / ${NUM_OPENSTACK_SITES} ))
873 ha_proxy_index=${os_interval}
875 for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
876 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
877 echo "Configure HAProxy"
878 ODL_HAPROXYIP_PARAM=OPENSTACK_HAPROXY_${i}_IP
879 ha_proxy_index=$(( $ha_proxy_index + $os_interval ))
880 odl_index=$(((i - 1) * 3 + 1))
881 ODL_IP_PARAM1=ODL_SYSTEM_$((odl_index++))_IP
882 ODL_IP_PARAM2=ODL_SYSTEM_$((odl_index++))_IP
883 ODL_IP_PARAM3=ODL_SYSTEM_$((odl_index++))_IP
884 ODLMGRIP[$i]=${!ODL_HAPROXYIP_PARAM} # ODL Northbound uses HAProxy VIP
885 ODL_OVS_MGRS[$i]="${!ODL_IP_PARAM1},${!ODL_IP_PARAM2},${!ODL_IP_PARAM3}" # OVSDB connects to all ODL IPs
886 configure_haproxy_for_neutron_requests ${!ODL_HAPROXYIP_PARAM} "${ODL_OVS_MGRS[$i]}"
888 ODL_IP_PARAM=ODL_SYSTEM_${i}_IP
889 ODL_OVS_MGRS[$i]="${!ODL_IP_PARAM}" # ODL Northbound uses ODL IP
890 ODLMGRIP[$i]=${!ODL_IP_PARAM} # OVSDB connects to ODL IP
894 # Begin stacking the nodes, starting with the controller(s) and then the compute(s)
896 for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`; do
897 CONTROLIP=OPENSTACK_CONTROL_NODE_${i}_IP
898 echo "Configure the stack of the control node ${i} of ${NUM_OPENSTACK_CONTROL_NODES}: ${CONTROLIP}"
899 scp ${WORKSPACE}/disable_firewall.sh ${!CONTROLIP}:/tmp
900 ${SSH} ${!CONTROLIP} "sudo bash /tmp/disable_firewall.sh"
901 create_etc_hosts ${!CONTROLIP}
902 scp ${WORKSPACE}/hosts_file ${!CONTROLIP}:/tmp/hosts
903 scp ${WORKSPACE}/get_devstack.sh ${!CONTROLIP}:/tmp
904 ${SSH} ${!CONTROLIP} "bash /tmp/get_devstack.sh > /tmp/get_devstack.sh.txt 2>&1"
905 create_control_node_local_conf ${!CONTROLIP} ${ODLMGRIP[$i]} "${ODL_OVS_MGRS[$i]}"
906 scp ${WORKSPACE}/local.conf_control_${!CONTROLIP} ${!CONTROLIP}:/opt/stack/devstack/local.conf
907 echo "Stack the control node ${i} of ${NUM_OPENSTACK_CONTROL_NODES}: ${CONTROLIP}"
908 ssh ${!CONTROLIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
909 ssh ${!CONTROLIP} "ps -ef | grep stack.sh"
910 ssh ${!CONTROLIP} "ls -lrt /opt/stack/devstack/nohup.out"
911 os_node_list+=("${!CONTROLIP}")
912 # Workaround for stable/newton jobs
913 # TODO: can this be removed now?
914 if [ "${ODL_ML2_BRANCH}" == "stable/newton" ]; then
915 ssh ${!CONTROLIP} "cd /opt/stack; git clone https://git.openstack.org/openstack/requirements; cd requirements; git checkout stable/newton; sed -i /appdirs/d upper-constraints.txt"
919 # This is a backup to the CELLSV2_SETUP=singleconductor workaround. Keeping it here as an easy lookup
921 # Let the control node get started to avoid a race condition where the computes start and try to access
922 # the nova_cell1 on the control node before it is created. If that happens, the nova-compute service on the
923 # compute exits and does not attempt to restart.
924 # 180s is chosen because in test runs the control node usually finished in 17-20 minutes and the computes finished
925 # in 17 minutes, so take the max difference of 3 minutes and the jobs should still finish around the same time.
926 # one of the following errors is seen in the compute n-cpu.log:
927 # Unhandled error: NotAllowed: Connection.open: (530) NOT_ALLOWED - access to vhost 'nova_cell1' refused for user 'stackrabbit'
928 # AccessRefused: (0, 0): (403) ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.
929 # Compare that timestamp to this log in the control stack.log: sudo rabbitmqctl set_permissions -p nova_cell1 stackrabbit
930 # If the n-cpu.log is earlier than the control stack.log timestamp then the failure condition is likely hit.
931 WAIT_FOR_RABBITMQ_MINUTES=60
932 echo "Wait a maximum of ${WAIT_FOR_RABBITMQ_MINUTES}m until rabbitmq is ready to allow the controller to create nova_cell1 before the computes need it"
933 retry ${WAIT_FOR_RABBITMQ_MINUTES} 60 "is_rabbitmq_ready ${OPENSTACK_CONTROL_NODE_1_IP}"
935 if ((${rc} == 0)); then
936 echo "rabbitmq is ready, starting ${NUM_OPENSTACK_COMPUTE_NODES} compute(s)"
938 echo "rabbitmq was not ready in ${WAIT_FOR_RABBITMQ_MINUTES}m"
943 for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`; do
944 NUM_COMPUTES_PER_SITE=$((NUM_OPENSTACK_COMPUTE_NODES / NUM_OPENSTACK_SITES))
945 SITE_INDEX=$((((i - 1) / NUM_COMPUTES_PER_SITE) + 1)) # We need the site index to infer the control node IP for this compute
946 COMPUTEIP=OPENSTACK_COMPUTE_NODE_${i}_IP
947 CONTROLIP=OPENSTACK_CONTROL_NODE_${SITE_INDEX}_IP
948 echo "Configure the stack of the compute node ${i} of ${NUM_OPENSTACK_COMPUTE_NODES}: ${COMPUTEIP}"
949 scp ${WORKSPACE}/disable_firewall.sh "${!COMPUTEIP}:/tmp"
950 ${SSH} "${!COMPUTEIP}" "sudo bash /tmp/disable_firewall.sh"
951 create_etc_hosts ${!COMPUTEIP} ${!CONTROLIP}
952 scp ${WORKSPACE}/hosts_file ${!COMPUTEIP}:/tmp/hosts
953 scp ${WORKSPACE}/get_devstack.sh ${!COMPUTEIP}:/tmp
954 ${SSH} ${!COMPUTEIP} "bash /tmp/get_devstack.sh > /tmp/get_devstack.sh.txt 2>&1"
955 if [ "${ODL_ML2_BRANCH}" == "stable/ocata" ]; then
956 echo "Updating requirements for ${ODL_ML2_BRANCH}"
957 echo "Workaround for https://review.openstack.org/#/c/491032/"
958 echo "Modify upper-constraints to use libvirt-python 3.2.0"
959 ${SSH} ${!COMPUTEIP} "
961 git clone https://git.openstack.org/openstack/requirements;
963 git checkout stable/ocata;
964 sed -i s/libvirt-python===2.5.0/libvirt-python===3.2.0/ upper-constraints.txt
967 create_compute_node_local_conf ${!COMPUTEIP} ${!CONTROLIP} ${ODLMGRIP[$SITE_INDEX]} "${ODL_OVS_MGRS[$SITE_INDEX]}"
968 scp ${WORKSPACE}/local.conf_compute_${!COMPUTEIP} ${!COMPUTEIP}:/opt/stack/devstack/local.conf
969 echo "Stack the compute node ${i} of ${NUM_OPENSTACK_COMPUTE_NODES}: ${COMPUTEIP}"
970 ssh ${!COMPUTEIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
971 ssh ${!COMPUTEIP} "ps -ef | grep stack.sh"
972 os_node_list+=("${!COMPUTEIP}")
975 echo "nodelist: ${os_node_list[*]}"
977 # This script runs on the openstack nodes. It greps for a string that devstack writes when stacking is complete.
978 # The script then writes a status depending on the grep output that is later scraped by the robot vm to control
979 # the status polling.
980 cat > ${WORKSPACE}/check_stacking.sh << EOF
981 > /tmp/stack_progress
982 ps -ef | grep "stack.sh" | grep -v grep
984 if [ \${ret} -eq 1 ]; then
985 grep "This is your host IP address:" /opt/stack/devstack/nohup.out
986 if [ \$? -eq 0 ]; then
987 echo "Stacking Complete" > /tmp/stack_progress
989 echo "Stacking Failed" > /tmp/stack_progress
991 elif [ \${ret} -eq 0 ]; then
992 echo "Still Stacking" > /tmp/stack_progress
999 # Check if the stacking is finished. Poll all nodes every 60s for one hour.
1002 while [ ${in_progress} -eq 1 ]; do
1003 iteration=$(($iteration + 1))
1004 for index in "${!os_node_list[@]}"; do
1005 echo "node $index ${os_node_list[index]}: checking stacking status attempt ${iteration} of 60"
1006 scp ${WORKSPACE}/check_stacking.sh ${os_node_list[index]}:/tmp
1007 ${SSH} ${os_node_list[index]} "bash /tmp/check_stacking.sh"
1008 scp ${os_node_list[index]}:/tmp/stack_progress .
1010 stacking_status=`cat stack_progress`
1011 # devstack debugging
1012 # get_service "${iteration}" "${index}"
1013 if [ "$stacking_status" == "Still Stacking" ]; then
1015 elif [ "$stacking_status" == "Stacking Failed" ]; then
1016 echo "node $index ${os_node_list[index]}: stacking has failed"
1019 elif [ "$stacking_status" == "Stacking Complete" ]; then
1020 echo "node $index ${os_node_list[index]}: stacking complete"
1021 unset 'os_node_list[index]'
1022 if [ ${#os_node_list[@]} -eq 0 ]; then
1027 echo "sleep for a minute before the next check"
1029 if [ ${iteration} -eq 60 ]; then
1030 echo "stacking has failed - took longer than 60m"
1036 # Further configuration now that stacking is complete.
1037 NUM_COMPUTES_PER_SITE=$((NUM_OPENSTACK_COMPUTE_NODES / NUM_OPENSTACK_SITES))
1038 for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
1039 echo "Configure the Control Node"
1040 CONTROLIP=OPENSTACK_CONTROL_NODE_${i}_IP
1041 # Gather Compute IPs for the site
1042 for j in `seq 1 ${NUM_COMPUTES_PER_SITE}`; do
1043 COMPUTE_INDEX=$(((i-1) * NUM_COMPUTES_PER_SITE + j))
1044 IP_VAR=OPENSTACK_COMPUTE_NODE_${COMPUTE_INDEX}_IP
1045 COMPUTE_IPS[$((j-1))]=${!IP_VAR}
1048 echo "sleep for 60s and print hypervisor-list"
1050 # In Ocata if we do not enable the n-cpu in control node then
1051 # we need to discover hosts manually and ensure that they are mapped to cells.
1052 # reference: https://ask.openstack.org/en/question/102256/how-to-configure-placement-service-for-compute-node-on-ocata/
1053 if [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then
1054 scp ${WORKSPACE}/setup_host_cell_mapping.sh ${!CONTROLIP}:/tmp
1055 ${SSH} ${!CONTROLIP} "sudo bash /tmp/setup_host_cell_mapping.sh"
1057 ${SSH} ${!CONTROLIP} "cd /opt/stack/devstack; source openrc admin admin; nova hypervisor-list"
1058 # in the case that we are doing openstack (control + compute) all in one node, then the number of hypervisors
1059 # will be the same as the number of openstack systems. However, if we are doing multinode openstack then the
1060 # assumption is we have a single control node and the rest are compute nodes, so the number of expected hypervisors
1061 # is one less than the total number of openstack systems
1062 if [ $((NUM_OPENSTACK_SYSTEM / NUM_OPENSTACK_SITES)) -eq 1 ]; then
1063 expected_num_hypervisors=1
1065 expected_num_hypervisors=${NUM_COMPUTES_PER_SITE}
1067 num_hypervisors=$(${SSH} ${!CONTROLIP} "cd /opt/stack/devstack; source openrc admin admin; openstack hypervisor list -f value | wc -l" | tail -1 | tr -d "\r")
1068 if ! [ "${num_hypervisors}" ] || ! [ ${num_hypervisors} -eq ${expected_num_hypervisors} ]; then
1069 echo "Error: Only $num_hypervisors hypervisors detected, expected $expected_num_hypervisors"
1074 # upgrading pip, urllib3 and httplib2 so that tempest tests can be run on openstack control node
1075 # this needs to happen after devstack runs because it seems devstack is pulling in specific versions
1076 # of these libs that are not working for tempest.
1077 ${SSH} ${!CONTROLIP} "sudo pip install --upgrade pip"
1078 ${SSH} ${!CONTROLIP} "sudo pip install urllib3 --upgrade"
1079 ${SSH} ${!CONTROLIP} "sudo pip install httplib2 --upgrade"
1081 # Gather Compute IPs for the site
1082 for j in `seq 1 ${NUM_COMPUTES_PER_SITE}`; do
1083 COMPUTE_INDEX=$(((i-1) * NUM_COMPUTES_PER_SITE + j))
1084 IP_VAR=OPENSTACK_COMPUTE_NODE_${COMPUTE_INDEX}_IP
1085 COMPUTE_IPS[$((j-1))]=${!IP_VAR}
1089 echo "prepare external networks by adding vxlan tunnels between all nodes on a separate bridge..."
1090 # FIXME Should there be a unique gateway IP and devstack index for each site?
1092 for ip in ${!CONTROLIP} ${COMPUTE_IPS[*]}; do
1093 # FIXME - Workaround, ODL (new netvirt) currently adds PUBLIC_BRIDGE as a port in br-int since it doesn't see such a bridge existing when we stack
1094 ${SSH} $ip "sudo ovs-vsctl --if-exists del-port br-int $PUBLIC_BRIDGE"
1095 ${SSH} $ip "sudo ovs-vsctl --may-exist add-br $PUBLIC_BRIDGE -- set bridge $PUBLIC_BRIDGE other-config:disable-in-band=true other_config:hwaddr=f6:00:00:ff:01:0$((devstack_index++))"
1099 if [ "${IPSEC_VXLAN_TUNNELS_ENABLED}" == "yes" ]; then
1100 # shellcheck disable=SC2206
1101 ALL_NODES=(${!CONTROLIP} ${COMPUTE_IPS[*]})
1102 for ((inx_ip1=0; inx_ip1<$((${#ALL_NODES[@]} - 1)); inx_ip1++)); do
1103 for ((inx_ip2=$((inx_ip1 + 1)); inx_ip2<${#ALL_NODES[@]}; inx_ip2++)); do
1104 KEY1=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
1105 KEY2=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
1106 ID=0x$(dd if=/dev/urandom count=4 bs=1 2> /dev/null| xxd -p -c 8)
1107 ip1=${ALL_NODES[$inx_ip1]}
1108 ip2=${ALL_NODES[$inx_ip2]}
1109 ${SSH} $ip1 "sudo ip xfrm state add src $ip1 dst $ip2 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1110 ${SSH} $ip1 "sudo ip xfrm state add src $ip2 dst $ip1 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1111 ${SSH} $ip1 "sudo ip xfrm policy add src $ip1 dst $ip2 proto udp dir out tmpl src $ip1 dst $ip2 proto esp reqid $ID mode transport"
1112 ${SSH} $ip1 "sudo ip xfrm policy add src $ip2 dst $ip1 proto udp dir in tmpl src $ip2 dst $ip1 proto esp reqid $ID mode transport"
1114 ${SSH} $ip2 "sudo ip xfrm state add src $ip2 dst $ip1 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1115 ${SSH} $ip2 "sudo ip xfrm state add src $ip1 dst $ip2 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1116 ${SSH} $ip2 "sudo ip xfrm policy add src $ip2 dst $ip1 proto udp dir out tmpl src $ip2 dst $ip1 proto esp reqid $ID mode transport"
1117 ${SSH} $ip2 "sudo ip xfrm policy add src $ip1 dst $ip2 proto udp dir in tmpl src $ip1 dst $ip2 proto esp reqid $ID mode transport"
1121 for ip in ${!CONTROLIP} ${COMPUTE_IPS[*]}; do
1122 echo "ip xfrm configuration for node $ip:"
1123 ${SSH} $ip "sudo ip xfrm policy list"
1124 ${SSH} $ip "sudo ip xfrm state list"
1128 # Control Node - PUBLIC_BRIDGE will act as the external router
1129 # Parameter values below are used in integration/test - changing them requires updates in intergration/test as well
1130 EXTNET_GATEWAY_IP="10.10.10.250"
1131 EXTNET_INTERNET_IP="10.9.9.9"
1132 EXTNET_PNF_IP="10.10.10.253"
1133 ${SSH} ${!CONTROLIP} "sudo ifconfig ${PUBLIC_BRIDGE} up ${EXTNET_GATEWAY_IP}/24"
1135 # Control Node - external net PNF simulation
1136 ${SSH} ${!CONTROLIP} "
1137 sudo ip netns add pnf_ns;
1138 sudo ip link add pnf_veth0 type veth peer name pnf_veth1;
1139 sudo ip link set pnf_veth1 netns pnf_ns;
1140 sudo ip link set pnf_veth0 up;
1141 sudo ip netns exec pnf_ns ifconfig pnf_veth1 up ${EXTNET_PNF_IP}/24;
1142 sudo ovs-vsctl add-port ${PUBLIC_BRIDGE} pnf_veth0;
1144 # Control Node - set VXLAN TEP IP for Genius Auto TZ
1145 ${SSH} ${!CONTROLIP} "
1146 sudo ovs-vsctl set O . external_ids:tep-ip=${!CONTROLIP};
1149 # Control Node - external net internet address simulation
1150 ${SSH} ${!CONTROLIP} "
1151 sudo ip tuntap add dev internet_tap mode tap;
1152 sudo ifconfig internet_tap up ${EXTNET_INTERNET_IP}/24;
1157 for compute_ip in ${COMPUTE_IPS[*]}; do
1158 # Tunnel from controller to compute
1159 COMPUTEPORT=compute$(( compute_index++ ))_vxlan
1160 ${SSH} ${!CONTROLIP} "
1161 sudo ovs-vsctl add-port $PUBLIC_BRIDGE $COMPUTEPORT -- set interface $COMPUTEPORT type=vxlan options:local_ip=${!CONTROLIP} options:remote_ip=$compute_ip options:dst_port=9876 options:key=flow
1163 # Tunnel from compute to controller
1164 CONTROLPORT="control_vxlan"
1165 ${SSH} $compute_ip "
1166 sudo ovs-vsctl add-port $PUBLIC_BRIDGE $CONTROLPORT -- set interface $CONTROLPORT type=vxlan options:local_ip=$compute_ip options:remote_ip=${!CONTROLIP} options:dst_port=9876 options:key=flow
1168 #Compute Node - set VXLAN TEP IP for Genius Auto TZ
1169 ${SSH} $compute_ip "
1170 sudo ovs-vsctl set O . external_ids:tep-ip=${compute_ip};
1175 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
1176 odlmgrip=OPENSTACK_HAPROXY_1_IP
1177 HA_PROXY_IP=${!odlmgrip}
1178 HA_PROXY_1_IP=${!odlmgrip}
1179 odlmgrip2=OPENSTACK_HAPROXY_2_IP
1180 HA_PROXY_2_IP=${!odlmgrip2}
1181 odlmgrip3=OPENSTACK_HAPROXY_1_IP
1182 HA_PROXY_3_IP=${!odlmgrip3}
1184 HA_PROXY_IP=${ODL_SYSTEM_IP}
1185 HA_PROXY_1_IP=${ODL_SYSTEM_1_IP}
1186 HA_PROXY_2_IP=${ODL_SYSTEM_2_IP}
1187 HA_PROXY_3_IP=${ODL_SYSTEM_3_IP}
1190 echo "Locating test plan to use..."
1191 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
1192 if [ ! -f "${testplan_filepath}" ]; then
1193 testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
1196 echo "Changing the testplan path..."
1197 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
1200 # Use the testplan if specific SUITES are not defined.
1201 if [ -z "${SUITES}" ]; then
1202 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
1205 workpath="${WORKSPACE}/test/csit/suites"
1206 for suite in ${SUITES}; do
1207 fullsuite="${workpath}/${suite}"
1208 if [ -z "${newsuites}" ]; then
1209 newsuites+=${fullsuite}
1211 newsuites+=" "${fullsuite}
1217 #install all client versions required for this job testing
1218 install_openstack_clients_in_robot_vm
1220 # TODO: run openrc on control node and then scrape the vars from it
1221 # Environment Variables Needed to execute Openstack Client for NetVirt Jobs
1222 cat > /tmp/os_netvirt_client_rc << EOF
1223 export OS_USERNAME=admin
1224 export OS_PASSWORD=admin
1225 export OS_PROJECT_NAME=admin
1226 export OS_USER_DOMAIN_NAME=default
1227 export OS_PROJECT_DOMAIN_NAME=default
1228 export OS_AUTH_URL="http://${!CONTROLIP}/identity"
1229 export OS_IDENTITY_API_VERSION=3
1230 export OS_IMAGE_API_VERSION=2
1231 export OS_TENANT_NAME=admin
1235 source /tmp/os_netvirt_client_rc
1237 echo "Get all versions before executing pybot"
1238 echo "openstack --version"
1241 echo "nova --version"
1244 echo "neutron --version"
1248 echo "Starting Robot test suites ${SUITES} ..."
1249 # please add pybot -v arguments on a single line and alphabetized
1251 for suite in ${SUITES}; do
1252 # prepend a incrmental counter to the suite name so that the full robot log combining all the suites as is done
1253 # in the rebot step below will list all the suites in chronological order as rebot seems to alphabatize them
1254 let "suite_num = suite_num + 1"
1255 suite_index="$(printf %02d ${suite_num})"
1256 suite_name="$(basename ${suite} | cut -d. -f1)"
1257 log_name="${suite_index}_${suite_name}"
1258 pybot -N ${log_name} --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
1259 --log log_${log_name}.html --report None --output output_${log_name}.xml \
1260 -v BUNDLEFOLDER:${BUNDLEFOLDER} \
1261 -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
1262 -v CONTROLLERFEATURES:"${CONTROLLERFEATURES}" \
1263 -v CONTROLLER_USER:${USER} \
1264 -v DEVSTACK_DEPLOY_PATH:/opt/stack/devstack \
1265 -v HA_PROXY_IP:${HA_PROXY_IP} \
1266 -v HA_PROXY_1_IP:${HA_PROXY_1_IP} \
1267 -v HA_PROXY_2_IP:${HA_PROXY_2_IP} \
1268 -v HA_PROXY_3_IP:${HA_PROXY_3_IP} \
1269 -v JDKVERSION:${JDKVERSION} \
1270 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
1271 -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
1272 -v NUM_OPENSTACK_SITES:${NUM_OPENSTACK_SITES} \
1273 -v NUM_OS_SYSTEM:${NUM_OPENSTACK_SYSTEM} \
1274 -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
1275 -v ODL_SNAT_MODE:${ODL_SNAT_MODE} \
1276 -v ODL_STREAM:${DISTROSTREAM} \
1277 -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
1278 -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_1_IP} \
1279 -v ODL_SYSTEM_2_IP:${ODL_SYSTEM_2_IP} \
1280 -v ODL_SYSTEM_3_IP:${ODL_SYSTEM_3_IP} \
1281 -v ODL_SYSTEM_4_IP:${ODL_SYSTEM_4_IP} \
1282 -v ODL_SYSTEM_5_IP:${ODL_SYSTEM_5_IP} \
1283 -v ODL_SYSTEM_6_IP:${ODL_SYSTEM_6_IP} \
1284 -v ODL_SYSTEM_7_IP:${ODL_SYSTEM_7_IP} \
1285 -v ODL_SYSTEM_8_IP:${ODL_SYSTEM_8_IP} \
1286 -v ODL_SYSTEM_9_IP:${ODL_SYSTEM_9_IP} \
1287 -v OS_CONTROL_NODE_IP:${OPENSTACK_CONTROL_NODE_1_IP} \
1288 -v OS_CONTROL_NODE_1_IP:${OPENSTACK_CONTROL_NODE_1_IP} \
1289 -v OS_CONTROL_NODE_2_IP:${OPENSTACK_CONTROL_NODE_2_IP} \
1290 -v OS_CONTROL_NODE_3_IP:${OPENSTACK_CONTROL_NODE_3_IP} \
1291 -v OPENSTACK_BRANCH:${OPENSTACK_BRANCH} \
1292 -v OS_COMPUTE_1_IP:${OPENSTACK_COMPUTE_NODE_1_IP} \
1293 -v OS_COMPUTE_2_IP:${OPENSTACK_COMPUTE_NODE_2_IP} \
1294 -v OS_COMPUTE_3_IP:${OPENSTACK_COMPUTE_NODE_3_IP} \
1295 -v OS_COMPUTE_4_IP:${OPENSTACK_COMPUTE_NODE_4_IP} \
1296 -v OS_COMPUTE_5_IP:${OPENSTACK_COMPUTE_NODE_5_IP} \
1297 -v OS_COMPUTE_6_IP:${OPENSTACK_COMPUTE_NODE_6_IP} \
1298 -v OS_USER:${USER} \
1299 -v PUBLIC_PHYSICAL_NETWORK:${PUBLIC_PHYSICAL_NETWORK} \
1300 -v SECURITY_GROUP_MODE:${SECURITY_GROUP_MODE} \
1301 -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_1_IP} \
1302 -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_1_IP} \
1303 -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
1304 -v USER_HOME:${HOME} \
1306 ${TESTOPTIONS} ${suite} || true
1308 #rebot exit codes seem to be different
1309 rebot --output ${WORKSPACE}/output.xml --log log_full.html --report None -N openstack output_*.xml || true
1311 echo "Examining the files in data/log and checking file size"
1312 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
1313 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
1315 echo "Tests Executed"
1318 true # perhaps Jenkins is testing last exit code
1319 # vim: ts=4 sw=4 sts=4 et ft=sh :