Workaround for vif_plugging missing
[releng/builder.git] / jjb / integration / integration-deploy-openstack-run-test.sh
1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
4 # script.
5 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
6 source ${ROBOT_VENV}/bin/activate
7 PYTHON="${ROBOT_VENV}/bin/python"
8
9 # TODO: remove this work to run changes.py if/when it's moved higher up to be visible at the Robot level
10 echo "showing recent changes that made it in to the distribution used by this job"
11 $PYTHON -m pip install --upgrade urllib3
12 python ${WORKSPACE}/test/tools/distchanges/changes.py -d /tmp/distribution_folder \
13                   -u ${ACTUAL_BUNDLE_URL} -b ${DISTROBRANCH} \
14                   -r ssh://jenkins-${SILO}@git.opendaylight.org:29418 || true
15
16 echo "#################################################"
17 echo "##         Deploy Openstack 3-node             ##"
18 echo "#################################################"
19
20
21 SSH="ssh -t -t"
22
23 function create_etc_hosts {
24 NODE_IP=$1
25 CTRL_IP=$2
26 : > ${WORKSPACE}/hosts_file
27 for iter in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`
28 do
29     COMPUTE_IP=OPENSTACK_COMPUTE_NODE_${iter}_IP
30     if [ "${!COMPUTE_IP}" == "${NODE_IP}" ]; then
31        CONTROL_HNAME=$(${SSH}  ${CTRL_IP}  "hostname")
32        echo "${CTRL_IP}   ${CONTROL_HNAME}" >> ${WORKSPACE}/hosts_file
33     else
34        COMPUTE_HNAME=$(${SSH}  ${!COMPUTE_IP}  "hostname")
35        echo "${!COMPUTE_IP}   ${COMPUTE_HNAME}" >> ${WORKSPACE}/hosts_file
36     fi
37 done
38
39 cat ${WORKSPACE}/hosts_file
40 echo "Created the hosts file for ${NODE_IP}"
41 }
42
43 if [ "${ODL_ML2_BRANCH}" != "stable/ocata" ]; then
44    RECLONE=no
45 else
46    RECLONE=yes
47 fi
48 function create_control_node_local_conf {
49 HOSTIP=$1
50 MGRIP=$2
51 ODL_OVS_MANAGERS="$3"
52 #Needs to be removed
53 local_conf_file_name=${WORKSPACE}/local.conf_control_${HOSTIP}
54 cat > ${local_conf_file_name} << EOF
55 [[local|localrc]]
56 LOGFILE=stack.sh.log
57 USE_SCREEN=True
58 SCREEN_LOGDIR=/opt/stack/data/log
59 LOG_COLOR=False
60 RECLONE=${RECLONE}
61 ETCD_PORT=2379
62 EOF
63
64 IFS=,
65 for service_name in ${DISABLE_OS_SERVICES}
66 do
67 cat >> ${local_conf_file_name} << EOF
68 disable_service ${service_name}
69 EOF
70 done
71 for service_name in ${ENABLE_OS_SERVICES}
72 do
73 cat >> ${local_conf_file_name} << EOF
74 enable_service ${service_name}
75 EOF
76 done
77 for plugin_name in ${ENABLE_OS_PLUGINS}
78 do
79 if [ "$plugin_name" == "networking-odl" ]; then
80     ENABLE_PLUGIN_ARGS="${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}"
81 elif [ "$plugin_name" == "kuryr-kubernetes" ]; then
82     ENABLE_PLUGIN_ARGS="${DEVSTACK_KUBERNETES_PLUGIN_REPO} master" # note: kuryr-kubernetes only exists in master at the moment
83     IS_KUBERNETES_PLUGIN_ENABLED="yes"
84 elif [ "$plugin_name" == "neutron-lbaas" ]; then
85     ENABLE_PLUGIN_ARGS="${DEVSTACK_LBAAS_PLUGIN_REPO} ${OPENSTACK_BRANCH}"
86     IS_LBAAS_PLUGIN_ENABLED="yes"
87 elif [ "$plugin_name" == "networking-sfc" ]; then
88     ENABLE_PLUGIN_ARGS="${DEVSTACK_NETWORKING_SFC_PLUGIN_REPO} ${OPENSTACK_BRANCH}"
89 else
90     echo "Error: Invalid plugin $plugin_name, unsupported"
91     continue
92 fi
93 cat >> ${local_conf_file_name} << EOF
94 enable_plugin ${plugin_name} ${ENABLE_PLUGIN_ARGS}
95 EOF
96 done
97 unset IFS
98 if [ "${OPENSTACK_BRANCH}" == "stable/pike" ] || [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then # Ocata+
99     # placement is mandatory for nova since Ocata, note that this requires computes to enable placement-client
100     # this should be moved into enabled_services for each job (but only for Ocata)
101     echo "enable_service placement-api" >> ${local_conf_file_name}
102 fi
103 if [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then # Ocata
104     # running kubernetes master against devstack ocata has some issues with etcd3 and this
105     # workaround is needed for things to work
106     if [ "$IS_KUBERNETES_PLUGIN_ENABLED" == "yes" ]; then
107         echo "disable_service etcd3" >> ${local_conf_file_name}
108     fi
109 fi
110 cat >> ${local_conf_file_name} << EOF
111 HOST_IP=${HOSTIP}
112 SERVICE_HOST=\$HOST_IP
113
114 NEUTRON_CREATE_INITIAL_NETWORKS=${CREATE_INITIAL_NETWORKS}
115 Q_PLUGIN=ml2
116 Q_ML2_TENANT_NETWORK_TYPE=${TENANT_NETWORK_TYPE}
117
118 ENABLE_TENANT_TUNNELS=True
119
120 MYSQL_HOST=\$SERVICE_HOST
121 RABBIT_HOST=\$SERVICE_HOST
122 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
123 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
124 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
125
126 MYSQL_PASSWORD=mysql
127 RABBIT_PASSWORD=rabbit
128 SERVICE_TOKEN=service
129 SERVICE_PASSWORD=admin
130 ADMIN_PASSWORD=admin
131
132 ODL_PORT=8080
133 ODL_MODE=externalodl
134 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
135
136 LIBVIRT_TYPE=qemu
137 ODL_MGR_IP=${MGRIP}
138
139 NEUTRON_LBAAS_SERVICE_PROVIDERV2=${LBAAS_SERVICE_PROVIDER} # Only relevant if neutron-lbaas plugin is enabled
140 NEUTRON_SFC_DRIVERS=${ODL_SFC_DRIVER} # Only relevant if networking-sfc plugin is enabled
141 NEUTRON_FLOWCLASSIFIER_DRIVERS=${ODL_SFC_DRIVER} # Only relevant if networking-sfc plugin is enabled
142 EOF
143
144 if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
145 cat >> ${local_conf_file_name} << EOF
146
147 enable_plugin networking-l2gw ${NETWORKING_L2GW_DRIVER} ${ODL_ML2_BRANCH}
148 NETWORKING_L2GW_SERVICE_DRIVER=L2GW:OpenDaylight:networking_odl.l2gateway.driver.OpenDaylightL2gwDriver:default
149 ENABLED_SERVICES+=,neutron,q-svc,nova,q-meta
150
151 EOF
152 fi
153
154 if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
155     echo "ODL_V2DRIVER=True" >> ${local_conf_file_name}
156 fi
157
158 echo "ODL_OVS_MANAGERS=${ODL_OVS_MANAGERS}" >> ${local_conf_file_name}
159
160 # if we are using the old netvirt impl, as determined by the feature name
161 # odl-ovsdb-openstack (note: new impl is odl-netvirt-openstack) then we
162 # want ODL_L3 to be True.  New impl wants it False
163 if [[ ${CONTROLLERFEATURES} == *"odl-ovsdb-openstack"* ]]; then
164     ODL_L3=True
165 else
166     ODL_L3=False
167 fi
168
169 # if we are using the new netvirt impl, as determined by the feature name
170 # odl-netvirt-openstack (note: old impl is odl-ovsdb-openstack) then we
171 # want PROVIDER_MAPPINGS to be used -- this should be fixed if we want to support
172 # external networks in legacy netvirt
173 if [[ ${CONTROLLERFEATURES} == *"odl-netvirt-openstack"* ]]; then
174   ODL_PROVIDER_MAPPINGS="\${PUBLIC_PHYSICAL_NETWORK}:${PUBLIC_BRIDGE}"
175 else
176   ODL_PROVIDER_MAPPINGS=
177 fi
178
179 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
180 cat >> ${local_conf_file_name} << EOF
181 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
182 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
183 ML2_VLAN_RANGES=${PUBLIC_PHYSICAL_NETWORK}
184 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
185
186 disable_service q-l3
187 EOF
188
189 if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
190    SERVICE_PLUGINS="odl-router_v2"
191 else
192    SERVICE_PLUGINS="odl-router"
193 fi
194
195 if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
196   SERVICE_PLUGINS+=", networking_l2gw.services.l2gateway.plugin.L2GatewayPlugin"
197 fi #check for ENABLE_NETWORKING_L2GW
198 if [ "${IS_LBAAS_PLUGIN_ENABLED}" == "yes" ]; then
199   SERVICE_PLUGINS+=", lbaasv2"
200 fi #check for ENABLE_LBAAS_PLUGIN
201 fi #check for ODL_ENABLE_L3_FWD
202
203 cat >> ${local_conf_file_name} << EOF
204 [[post-config|\$NEUTRON_CONF]]
205 [DEFAULT]
206 service_plugins = ${SERVICE_PLUGINS}
207 EOF
208
209 cat >> ${local_conf_file_name} << EOF
210 [[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
211 [agent]
212 minimize_polling=True
213
214 [ml2]
215 # Needed for VLAN provider tests - because our provider networks are always encapsulated in VXLAN (br-physnet1)
216 # MTU(1440) + VXLAN(50) + VLAN(4) = 1494 < MTU eth0/br-physnet1(1500)
217 physical_network_mtus = ${PUBLIC_PHYSICAL_NETWORK}:1440
218 path_mtu = 1490
219
220 # workaround for port-status not working due to https://bugs.opendaylight.org/show_bug.cgi?id=9092
221 [ml2_odl]
222 odl_features=nothing
223
224 [[post-config|/etc/neutron/dhcp_agent.ini]]
225 [DEFAULT]
226 force_metadata = True
227 enable_isolated_metadata = True
228
229 [[post-config|/etc/nova/nova.conf]]
230 [DEFAULT]
231 force_config_drive = False
232
233 [scheduler]
234 discover_hosts_in_cells_interval = 30
235
236 EOF
237
238 echo "Control local.conf created:"
239 cat ${local_conf_file_name}
240 }
241
242 function create_compute_node_local_conf {
243 HOSTIP=$1
244 SERVICEHOST=$2
245 MGRIP=$3
246 ODL_OVS_MANAGERS="$4"
247 #Needs to be removed
248 if [ "${OPENSTACK_BRANCH}" == "stable/pike" ] || [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then # Ocata+
249     # placement is mandatory for nova since Ocata, note that this requires controller to enable placement-api
250     ENABLED_SERVICES="n-cpu,placement-client"
251 else
252     ENABLED_SERVICES="n-cpu"
253 fi
254
255 local_conf_file_name=${WORKSPACE}/local.conf_compute_${HOSTIP}
256 cat > ${local_conf_file_name} << EOF
257 [[local|localrc]]
258 LOGFILE=stack.sh.log
259 LOG_COLOR=False
260 USE_SCREEN=True
261 SCREEN_LOGDIR=/opt/stack/data/log
262 RECLONE=${RECLONE}
263
264 NOVA_VNC_ENABLED=True
265 MULTI_HOST=1
266 ENABLED_SERVICES=${ENABLED_SERVICES}
267 HOST_IP=${HOSTIP}
268 SERVICE_HOST=${SERVICEHOST}
269
270 Q_PLUGIN=ml2
271 ENABLE_TENANT_TUNNELS=True
272 Q_ML2_TENANT_NETWORK_TYPE=vxlan
273
274 Q_HOST=\$SERVICE_HOST
275 MYSQL_HOST=\$SERVICE_HOST
276 RABBIT_HOST=\$SERVICE_HOST
277 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
278 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
279 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
280
281 MYSQL_PASSWORD=mysql
282 RABBIT_PASSWORD=rabbit
283 SERVICE_TOKEN=service
284 SERVICE_PASSWORD=admin
285 ADMIN_PASSWORD=admin
286
287 ODL_MODE=compute
288 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
289 LIBVIRT_TYPE=qemu
290 ODL_MGR_IP=${MGRIP}
291 EOF
292
293 if [[ "${ENABLE_OS_PLUGINS}" =~ networking-odl ]]; then
294 cat >> ${local_conf_file_name} << EOF
295 enable_plugin networking-odl ${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}
296 EOF
297 fi
298
299 echo "ODL_OVS_MANAGERS=${ODL_OVS_MANAGERS}" >> ${local_conf_file_name}
300
301 # if we are using the new netvirt impl, as determined by the feature name
302 # odl-netvirt-openstack (note: old impl is odl-ovsdb-openstack) then we
303 # want PROVIDER_MAPPINGS to be used -- this should be fixed if we want to support
304 # external networks in legacy netvirt
305 if [[ ${CONTROLLERFEATURES} == *"odl-netvirt-openstack"* ]]; then
306   ODL_PROVIDER_MAPPINGS="\${PUBLIC_PHYSICAL_NETWORK}:${PUBLIC_BRIDGE}"
307 else
308   ODL_PROVIDER_MAPPINGS=
309 fi
310
311 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
312 cat >> ${local_conf_file_name} << EOF
313 # Uncomment lines below if odl-compute is to be used for l3 forwarding
314 Q_L3_ENABLED=True
315 ODL_L3=${ODL_L3}
316 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
317 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
318 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
319 EOF
320 fi
321 cat >> ${local_conf_file_name} << EOF
322
323 [[post-config|/etc/nova/nova.conf]]
324 [api]
325 auth_strategy = keystone
326 [DEFAULT]
327 use_neutron = True
328 EOF
329
330 echo "Compute local.conf created:"
331 cat ${local_conf_file_name}
332 }
333
334 function configure_haproxy_for_neutron_requests () {
335 MGRIP=$1
336 ODL_IPS=(${2//,/ })
337
338 cat > ${WORKSPACE}/install_ha_proxy.sh<< EOF
339 sudo systemctl stop firewalld
340 sudo yum -y install policycoreutils-python haproxy
341 EOF
342
343 cat > ${WORKSPACE}/haproxy.cfg << EOF
344 global
345   daemon
346   group  haproxy
347   log  /dev/log local0
348   maxconn  20480
349   pidfile  /tmp/haproxy.pid
350   user  haproxy
351
352 defaults
353   log  global
354   maxconn  4096
355   mode  tcp
356   retries  3
357   timeout  http-request 10s
358   timeout  queue 1m
359   timeout  connect 10s
360   timeout  client 1m
361   timeout  server 1m
362   timeout  check 10s
363
364 listen opendaylight
365   bind ${MGRIP}:8080
366   balance source
367 EOF
368
369 odlindex=1
370 for odlip in ${ODL_IPS[*]}
371 do
372 cat >> ${WORKSPACE}/haproxy.cfg << EOF
373   server controller-${odlindex} ${odlip}:8080 check fall 5 inter 2000 rise 2
374 EOF
375 odlindex=$((odlindex+1))
376 done
377
378 cat >> ${WORKSPACE}/haproxy.cfg << EOF
379 listen opendaylight_rest
380   bind ${MGRIP}:8181
381   balance source
382 EOF
383
384 odlindex=1
385 for odlip in ${ODL_IPS[*]}
386 do
387 cat >> ${WORKSPACE}/haproxy.cfg << EOF
388   server controller-rest-${odlindex} ${odlip}:8181 check fall 5 inter 2000 rise 2
389 EOF
390 odlindex=$((odlindex+1))
391 done
392
393 echo "Dump haproxy.cfg"
394 cat ${WORKSPACE}/haproxy.cfg
395
396 cat > ${WORKSPACE}/deploy_ha_proxy.sh<< EOF
397 sudo chown haproxy:haproxy /tmp/haproxy.cfg
398 sudo sed -i 's/\\/etc\\/haproxy\\/haproxy.cfg/\\/tmp\\/haproxy.cfg/g' /usr/lib/systemd/system/haproxy.service
399 sudo /usr/sbin/semanage permissive -a haproxy_t
400 sudo systemctl restart haproxy
401 sleep 3
402 sudo netstat -tunpl
403 sudo systemctl status haproxy
404 true
405 EOF
406 scp ${WORKSPACE}/install_ha_proxy.sh ${MGRIP}:/tmp
407 ${SSH} ${MGRIP} "sudo bash /tmp/install_ha_proxy.sh"
408 scp ${WORKSPACE}/haproxy.cfg ${MGRIP}:/tmp
409 scp ${WORKSPACE}/deploy_ha_proxy.sh ${MGRIP}:/tmp
410 ${SSH} ${MGRIP} "sudo bash /tmp/deploy_ha_proxy.sh"
411 }
412
413 function collect_logs_and_exit () {
414 set +e  # We do not want to create red dot just because something went wrong while fetching logs.
415 for i in `seq 1 ${NUM_ODL_SYSTEM}`
416 do
417     CONTROLLERIP=ODL_SYSTEM_${i}_IP
418     echo "Lets's take the karaf thread dump again..."
419     KARAF_PID=$(ssh ${!CONTROLLERIP} "ps aux | grep ${KARAF_ARTIFACT} | grep -v grep | tr -s ' ' | cut -f2 -d' '")
420     ssh ${!CONTROLLERIP} "jstack $KARAF_PID"> ${WORKSPACE}/karaf_${i}_threads_after.log || true
421     echo "killing karaf process..."
422     ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
423 done
424
425 cat > extra_debug.sh << EOF
426 echo -e "/usr/sbin/lsmod | /usr/bin/grep openvswitch\n"
427 /usr/sbin/lsmod | /usr/bin/grep openvswitch
428 echo -e "\ngrep ct_ /var/log/openvswitch/ovs-vswitchd.log\n"
429 grep ct_ /var/log/openvswitch/ovs-vswitchd.log
430 echo -e "\novsdb-tool -mm show-log\n"
431 ovsdb-tool -mm show-log
432 echo -e "\nsudo netstat -punta\n"
433 sudo netstat -punta
434 echo -e "\nsudo getenforce\n"
435 sudo getenforce
436 echo -e "\njournalctl > /tmp/journalctl.log\n"
437 journalctl > /tmp/journalctl.log
438 EOF
439
440 sleep 5
441 # FIXME: Do not create .tar and gzip before copying.
442 for i in `seq 1 ${NUM_ODL_SYSTEM}`
443 do
444     CONTROLLERIP=ODL_SYSTEM_${i}_IP
445     ${SSH} "${!CONTROLLERIP}"  "cp -r /tmp/${BUNDLEFOLDER}/data/log /tmp/odl_log"
446     ${SSH} "${!CONTROLLERIP}"  "tar -cf /tmp/odl${i}_karaf.log.tar /tmp/odl_log/*"
447     scp "${!CONTROLLERIP}:/tmp/odl${i}_karaf.log.tar" "${WORKSPACE}/odl${i}_karaf.log.tar"
448     ${SSH} "${!CONTROLLERIP}"  "tar -cf /tmp/odl${i}_zrpcd.log.tar /tmp/zrpcd.init.log"
449     scp "${!CONTROLLERIP}:/tmp/odl${i}_zrpcd.log.tar" "${WORKSPACE}/odl${i}_zrpcd.log.tar"
450     tar -xvf ${WORKSPACE}/odl${i}_karaf.log.tar -C . --strip-components 2 --transform s/karaf/odl${i}_karaf/g
451     grep "ROBOT MESSAGE\| ERROR " odl${i}_karaf.log > odl${i}_err.log
452     grep "ROBOT MESSAGE\|Exception" odl${i}_karaf.log > odl${i}_exception.log
453     grep "ROBOT MESSAGE\| ERROR \| WARN \|Exception" odl${i}_karaf.log > odl${i}_err_warn_exception.log
454     rm ${WORKSPACE}/odl${i}_karaf.log.tar
455 done
456
457 # Since this log collection work is happening before the archive build macro which also
458 # creates the ${WORKSPACE}/archives dir, we have to do it here first.  The mkdir in the
459 # archives build step will essentially be a noop.
460 mkdir -p ${WORKSPACE}/archives
461
462 # Control Node
463 for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`
464 do
465     OS_CTRL_IP=OPENSTACK_CONTROL_NODE_${i}_IP
466     OS_CTRL_FOLDER="control_${i}"
467     mkdir -p ${OS_CTRL_FOLDER}
468     scp ${!OS_CTRL_IP}:/opt/stack/devstack/nohup.out ${OS_CTRL_FOLDER}/stack.log
469     scp ${!OS_CTRL_IP}:/var/log/openvswitch/ovs-vswitchd.log ${OS_CTRL_FOLDER}/ovs-vswitchd.log
470     scp ${!OS_CTRL_IP}:/etc/neutron/plugins/ml2/ml2_conf.ini ${OS_CTRL_FOLDER}
471     scp ${!OS_CTRL_IP}:/etc/neutron/dhcp_agent.ini ${OS_CTRL_FOLDER}
472     scp ${!OS_CTRL_IP}:/etc/neutron/neutron.conf ${OS_CTRL_FOLDER}/neutron.conf
473     scp ${!OS_CTRL_IP}:/etc/nova/nova.conf ${OS_CTRL_FOLDER}/nova.conf
474     scp ${!OS_CTRL_IP}:/etc/kuryr/kuryr.conf ${OS_CTRL_FOLDER}/kuryr.conf
475     scp ${!OS_CTRL_IP}:/etc/neutron/neutron_lbaas.conf ${OS_CTRL_FOLDER}/neutron-lbaas.conf
476     scp ${!OS_CTRL_IP}:/etc/neutron/services/loadbalancer/haproxy/lbaas_agent.ini ${OS_CTRL_FOLDER}/lbaas-agent.ini
477     rsync --rsync-path="sudo rsync" -avhe ssh ${!OS_CTRL_IP}:/usr/lib/systemd/system/haproxy.service ${OS_CTRL_FOLDER}
478     rsync -avhe ssh ${!OS_CTRL_IP}:/opt/stack/logs/* ${OS_CTRL_FOLDER} # rsync to prevent copying of symbolic links
479     rsync --rsync-path="sudo rsync" -avhe ssh ${!OS_CTRL_IP}:/etc/hosts ${OS_CTRL_FOLDER}/hosts.log
480     # Use rsync with sudo to get access to the log dir.
481     rsync --rsync-path="sudo rsync" -avhe ssh ${!OS_CTRL_IP}:/var/log/audit/audit.log ${OS_CTRL_FOLDER}
482     scp extra_debug.sh ${!OS_CTRL_IP}:/tmp
483     ${SSH} ${!OS_CTRL_IP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
484     scp ${!OS_CTRL_IP}:/tmp/extra_debug.log ${OS_CTRL_FOLDER}/extra_debug.log
485     scp ${!OS_CTRL_IP}:/tmp/journalctl.log ${OS_CTRL_FOLDER}
486     rsync --rsync-path="sudo rsync" -avhe ssh ${!OS_CTRL_IP}:/var/log/messages ${OS_CTRL_FOLDER}
487     scp ${!OS_CTRL_IP}:/tmp/*.xz ${OS_CTRL_FOLDER}/
488     mv local.conf_control_${!OS_CTRL_IP} ${OS_CTRL_FOLDER}/local.conf
489     mv ${OS_CTRL_FOLDER} ${WORKSPACE}/archives/
490 done
491
492 # Compute Nodes
493 for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`
494 do
495     OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
496     OS_COMPUTE_FOLDER="compute_${i}"
497     mkdir -p ${OS_COMPUTE_FOLDER}
498     scp ${!OSIP}:/opt/stack/devstack/nohup.out ${OS_COMPUTE_FOLDER}/stack.log
499     scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${OS_COMPUTE_FOLDER}/ovs-vswitchd.log
500     scp ${!OSIP}:/var/log/openvswitch/ovsdb-server.log ${OS_COMPUTE_FOLDER}/ovsdb-server.log
501     scp ${!OSIP}:/var/log/libvirt/libvirtd.log* ${OS_COMPUTE_FOLDER}
502     scp ${!OSIP}:/var/log/libvirt/qeum/*.log ${OS_COMPUTE_FOLDER}
503     scp ${!OSIP}:/etc/nova/nova.conf ${OS_COMPUTE_FOLDER}/nova.conf
504     rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${OS_COMPUTE_FOLDER} # rsync to prevent copying of symbolic links
505     rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/etc/hosts ${OS_COMPUTE_FOLDER}/hosts.log
506     # Use rsync with sudo to get access to the log dir. Also can't use wildcard because the dirs only have
507     # exec permissions which doesn't allow ls.
508     rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/libvirt ${OS_COMPUTE_FOLDER}
509     rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/audit/audit.log ${OS_COMPUTE_FOLDER}
510     scp extra_debug.sh ${!OSIP}:/tmp
511     ${SSH} ${!OSIP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
512     scp ${!OSIP}:/tmp/extra_debug.log ${OS_COMPUTE_FOLDER}/extra_debug.log
513     scp ${!OSIP}:/tmp/journalctl.log ${OS_COMPUTE_FOLDER}
514     rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/messages ${OS_COMPUTE_FOLDER}
515     scp ${!OSIP}:/tmp/*.xz ${OS_COMPUTE_FOLDER}/
516     mv local.conf_compute_${!OSIP} ${OS_COMPUTE_FOLDER}/local.conf
517     mv ${OS_COMPUTE_FOLDER} ${WORKSPACE}/archives/
518 done
519
520 find local.conf* -print0 | xargs -0 -I % mv % %.log
521
522 # Tempest
523 DEVSTACK_TEMPEST_DIR="/opt/stack/tempest"
524 if ssh ${OPENSTACK_CONTROL_NODE_1_IP} "sudo sh -c '[ -f ${DEVSTACK_TEMPEST_DIR}/.testrepository/0 ]'"; then # if Tempest results exist
525     ssh ${OPENSTACK_CONTROL_NODE_1_IP} "for I in \$(sudo ls ${DEVSTACK_TEMPEST_DIR}/.testrepository/ | grep -E '^[0-9]+$'); do sudo sh -c \"${DEVSTACK_TEMPEST_DIR}/.tox/tempest/bin/subunit-1to2 < ${DEVSTACK_TEMPEST_DIR}/.testrepository/\${I} >> ${DEVSTACK_TEMPEST_DIR}/subunit_log.txt\"; done"
526     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'"
527     TEMPEST_LOGS_DIR=${WORKSPACE}/archives/tempest
528     mkdir -p ${TEMPEST_LOGS_DIR}
529     scp ${OPENSTACK_CONTROL_NODE_1_IP}:${DEVSTACK_TEMPEST_DIR}/tempest_results.html ${TEMPEST_LOGS_DIR}
530     scp ${OPENSTACK_CONTROL_NODE_1_IP}:${DEVSTACK_TEMPEST_DIR}/tempest.log ${TEMPEST_LOGS_DIR}
531     mv ${WORKSPACE}/tempest_output* ${TEMPEST_LOGS_DIR}
532 fi
533 }
534
535 cat > ${WORKSPACE}/disable_firewall.sh << EOF
536 sudo systemctl stop firewalld
537 sudo systemctl stop iptables
538 true
539 EOF
540
541 cat > ${WORKSPACE}/get_devstack.sh << EOF
542 sudo systemctl stop firewalld
543 sudo yum install bridge-utils python-pip -y
544 sudo systemctl stop  NetworkManager
545 #Disable NetworkManager and kill dhclient and dnsmasq
546 sudo systemctl stop NetworkManager
547 sudo killall dhclient
548 sudo killall dnsmasq
549 #Workaround for mysql failure
550 echo "127.0.0.1    localhost \${HOSTNAME}" >> /tmp/hosts
551 echo "::1   localhost  \${HOSTNAME}" >> /tmp/hosts
552 sudo mv /tmp/hosts /etc/hosts
553 sudo mkdir /opt/stack
554 sudo chmod 777 /opt/stack
555 cd /opt/stack
556 git clone https://git.openstack.org/openstack-dev/devstack --branch $OPENSTACK_BRANCH
557 #To fix the recent tempest/tox issues which blocks stacking
558 sudo pip install tox==2.7.0
559 EOF
560
561 cat > "${WORKSPACE}/setup_host_cell_mapping.sh" << EOF
562 sudo nova-manage cell_v2 map_cell0
563 sudo nova-manage cell_v2 simple_cell_setup
564 sudo nova-manage db sync
565 sudo nova-manage cell_v2 discover_hosts
566 EOF
567
568 [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
569 compute_index=1
570 odl_index=1
571 os_node_list=()
572 os_interval=$(( ${NUM_OPENSTACK_SYSTEM} / ${NUM_OPENSTACK_SITES} ))
573 ha_proxy_index=${os_interval}
574
575 cat > "${WORKSPACE}/manual_install_package.sh" << EOF
576 cd /opt/stack
577 git clone "\$1"
578 cd "\$2"
579 git checkout "\$3"
580 sudo python setup.py install
581 EOF
582
583 for i in `seq 1 ${NUM_OPENSTACK_SITES}`
584 do
585     if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
586         echo "Configure HAProxy"
587         ODL_HAPROXYIP_PARAM=OPENSTACK_HAPROXY_${i}_IP
588         ha_proxy_index=$(( $ha_proxy_index + $os_interval ))
589         odl_index=$(((i - 1) * 3 + 1))
590         ODL_IP_PARAM1=ODL_SYSTEM_$((odl_index++))_IP
591         ODL_IP_PARAM2=ODL_SYSTEM_$((odl_index++))_IP
592         ODL_IP_PARAM3=ODL_SYSTEM_$((odl_index++))_IP
593         ODLMGRIP[$i]=${!ODL_HAPROXYIP_PARAM} # ODL Northbound uses HAProxy VIP
594         ODL_OVS_MGRS[$i]="${!ODL_IP_PARAM1},${!ODL_IP_PARAM2},${!ODL_IP_PARAM3}" # OVSDB connects to all ODL IPs
595
596         configure_haproxy_for_neutron_requests ${!ODL_HAPROXYIP_PARAM} "${ODL_OVS_MGRS[$i]}"
597     else
598         ODL_IP_PARAM=ODL_SYSTEM_${i}_IP
599         ODL_OVS_MGRS[$i]="${!ODL_IP_PARAM}" # ODL Northbound uses ODL IP
600         ODLMGRIP[$i]=${!ODL_IP_PARAM} # OVSDB connects to ODL IP
601     fi
602 done
603
604 for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`
605 do
606     echo "Stack the Control Node"
607     CONTROLIP=OPENSTACK_CONTROL_NODE_${i}_IP
608     create_etc_hosts ${!CONTROLIP}
609     scp ${WORKSPACE}/hosts_file ${!CONTROLIP}:/tmp/hosts
610     scp ${WORKSPACE}/get_devstack.sh ${!CONTROLIP}:/tmp
611     ${SSH} ${!CONTROLIP} "bash /tmp/get_devstack.sh"
612     create_control_node_local_conf ${!CONTROLIP} ${ODLMGRIP[$i]} "${ODL_OVS_MGRS[$i]}"
613     scp ${WORKSPACE}/local.conf_control_${!CONTROLIP} ${!CONTROLIP}:/opt/stack/devstack/local.conf
614     ssh ${!CONTROLIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
615     ssh ${!CONTROLIP} "ps -ef | grep stack.sh"
616     ssh ${!CONTROLIP} "ls -lrt /opt/stack/devstack/nohup.out"
617     os_node_list+=(${!CONTROLIP})
618
619     #Workaround for stable/newton jobs
620     if [ "${ODL_ML2_BRANCH}" == "stable/newton" ]; then
621         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"
622     fi
623 done
624
625 for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`
626 do
627     echo "Stack the Compute Node"
628     NUM_COMPUTES_PER_SITE=$((NUM_OPENSTACK_COMPUTE_NODES / NUM_OPENSTACK_SITES))
629     SITE_INDEX=$((((i - 1) / NUM_COMPUTES_PER_SITE) + 1)) # We need the site index to infer the control node IP for this compute
630     COMPUTEIP=OPENSTACK_COMPUTE_NODE_${i}_IP
631     CONTROLIP=OPENSTACK_CONTROL_NODE_${SITE_INDEX}_IP
632     create_etc_hosts ${!COMPUTEIP} ${!CONTROLIP}
633     scp ${WORKSPACE}/hosts_file ${!COMPUTEIP}:/tmp/hosts
634     scp ${WORKSPACE}/get_devstack.sh  ${!COMPUTEIP}:/tmp
635     ${SSH} ${!COMPUTEIP} "bash /tmp/get_devstack.sh"
636     create_compute_node_local_conf ${!COMPUTEIP} ${!CONTROLIP} ${ODLMGRIP[$SITE_INDEX]} "${ODL_OVS_MGRS[$SITE_INDEX]}"
637     scp ${WORKSPACE}/local.conf_compute_${!COMPUTEIP} ${!COMPUTEIP}:/opt/stack/devstack/local.conf
638     ssh ${!COMPUTEIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
639     ssh ${!COMPUTEIP} "ps -ef | grep stack.sh"
640     os_node_list+=(${!COMPUTEIP})
641 done
642
643 echo ${os_node_list[*]}
644
645 cat > ${WORKSPACE}/check_stacking.sh << EOF
646 > /tmp/stack_progress
647 ps -ef | grep "stack.sh" | grep -v grep
648 ret=\$?
649 if [ \${ret} -eq 1 ]; then
650   grep "This is your host IP address:" /opt/stack/devstack/nohup.out
651   if [ \$? -eq 0 ]; then
652      echo "Stacking Complete" > /tmp/stack_progress
653   else
654      echo "Stacking Failed" > /tmp/stack_progress
655   fi
656 elif [ \${ret} -eq 0 ]; then
657   echo "Still Stacking" > /tmp/stack_progress
658 fi
659 EOF
660
661 #the checking is repeated for an hour
662 iteration=0
663 in_progress=1
664 while [ ${in_progress} -eq 1 ]; do
665 iteration=$(($iteration + 1))
666 for index in "${!os_node_list[@]}"
667 do
668 echo "Check the status of stacking in ${os_node_list[index]}"
669 scp ${WORKSPACE}/check_stacking.sh  ${os_node_list[index]}:/tmp
670 ${SSH} ${os_node_list[index]} "bash /tmp/check_stacking.sh"
671 scp ${os_node_list[index]}:/tmp/stack_progress .
672 #debug
673 cat stack_progress
674 stacking_status=`cat stack_progress`
675 if [ "$stacking_status" == "Still Stacking" ]; then
676   continue
677 elif [ "$stacking_status" == "Stacking Failed" ]; then
678   collect_logs_and_exit
679   exit 1
680 elif [ "$stacking_status" == "Stacking Complete" ]; then
681   unset 'os_node_list[index]'
682   if  [ ${#os_node_list[@]} -eq 0 ]; then
683      in_progress=0
684   fi
685 fi
686 done
687  echo "sleep for a minute before the next check"
688  sleep 60
689  if [ ${iteration} -eq 60 ]; then
690   collect_logs_and_exit
691   exit 1
692  fi
693 done
694
695 NUM_COMPUTES_PER_SITE=$((NUM_OPENSTACK_COMPUTE_NODES / NUM_OPENSTACK_SITES))
696 for i in `seq 1 ${NUM_OPENSTACK_SITES}`
697 do
698     echo "Configure the Control Node"
699     CONTROLIP=OPENSTACK_CONTROL_NODE_${i}_IP
700     # Gather Compute IPs for the site
701     for j in `seq 1 ${NUM_COMPUTES_PER_SITE}`
702     do
703         COMPUTE_INDEX=$(((i-1) * NUM_COMPUTES_PER_SITE + j))
704         IP_VAR=OPENSTACK_COMPUTE_NODE_${COMPUTE_INDEX}_IP
705         COMPUTE_IPS[$((j-1))]=${!IP_VAR}
706     done
707
708     # Need to disable firewalld and iptables in compute nodes as well
709     for ip in ${COMPUTE_IPS[*]}
710     do
711         scp ${WORKSPACE}/disable_firewall.sh "${ip}:/tmp"
712         ${SSH} "${ip}" "sudo bash /tmp/disable_firewall.sh"
713     done
714
715     #Need to disable firewalld and iptables in control node
716     echo "Stop Firewall in Control Node for compute nodes to be able to reach the ports and add to hypervisor-list"
717     scp ${WORKSPACE}/disable_firewall.sh ${!CONTROLIP}:/tmp
718     ${SSH} ${!CONTROLIP} "sudo bash /tmp/disable_firewall.sh"
719
720     echo "sleep for 60s and print hypervisor-list"
721     sleep 60
722     # In anything after Newton, if we do not enable the n-cpu in control node
723     # We need to discover hosts manually and ensure that they are mapped to cells.
724     # reference: https://ask.openstack.org/en/question/102256/how-to-configure-placement-service-for-compute-node-on-ocata/
725     if [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then
726         scp ${WORKSPACE}/setup_host_cell_mapping.sh  ${!CONTROLIP}:/tmp
727         ${SSH} ${!CONTROLIP} "sudo bash /tmp/setup_host_cell_mapping.sh"
728     fi
729     ${SSH} ${!CONTROLIP} "cd /opt/stack/devstack; source openrc admin admin; nova hypervisor-list"
730     # in the case that we are doing openstack (control + compute) all in one node, then the number of hypervisors
731     # will be the same as the number of openstack systems. However, if we are doing multinode openstack then the
732     # assumption is we have a single control node and the rest are compute nodes, so the number of expected hypervisors
733     # is one less than the total number of openstack systems
734     if [ $((NUM_OPENSTACK_SYSTEM / NUM_OPENSTACK_SITES)) -eq 1 ]; then
735         expected_num_hypervisors=1
736     else
737         expected_num_hypervisors=${NUM_COMPUTES_PER_SITE}
738     fi
739     num_hypervisors=$(${SSH} ${!CONTROLIP} "cd /opt/stack/devstack; source openrc admin admin; openstack hypervisor list -f value | wc -l" | tail -1 | tr -d "\r")
740     if ! [ "${num_hypervisors}" ] || ! [ ${num_hypervisors} -eq ${expected_num_hypervisors} ]; then
741         echo "Error: Only $num_hypervisors hypervisors detected, expected $expected_num_hypervisors"
742         collect_logs_and_exit
743         exit 1
744     fi
745
746
747     # upgrading pip, urllib3 and httplib2 so that tempest tests can be run on openstack control node
748     # this needs to happen after devstack runs because it seems devstack is pulling in specific versions
749     # of these libs that are not working for tempest.
750     ${SSH} ${!CONTROLIP} "sudo pip install --upgrade pip"
751     ${SSH} ${!CONTROLIP} "sudo pip install urllib3 --upgrade"
752     ${SSH} ${!CONTROLIP} "sudo pip install httplib2 --upgrade"
753
754     # Gather Compute IPs for the site
755     for j in `seq 1 ${NUM_COMPUTES_PER_SITE}`
756     do
757         COMPUTE_INDEX=$(((i-1) * NUM_COMPUTES_PER_SITE + j))
758         IP_VAR=OPENSTACK_COMPUTE_NODE_${COMPUTE_INDEX}_IP
759         COMPUTE_IPS[$((j-1))]=${!IP_VAR}
760     done
761
762     # Need to disable firewalld and iptables in compute nodes as well
763     for ip in ${COMPUTE_IPS[*]}
764     do
765         scp ${WORKSPACE}/disable_firewall.sh "${ip}:/tmp"
766         ${SSH} "${ip}" "sudo bash /tmp/disable_firewall.sh"
767     done
768
769     # External Network
770     echo "prepare external networks by adding vxlan tunnels between all nodes on a separate bridge..."
771     # FIXME Should there be a unique gateway IP and devstack index for each site?
772     devstack_index=1
773     for ip in ${!CONTROLIP} ${COMPUTE_IPS[*]}
774     do
775         # 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
776         ${SSH} $ip "sudo ovs-vsctl --if-exists del-port br-int $PUBLIC_BRIDGE"
777         ${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++))"
778     done
779
780     # ipsec support
781     if [ "${IPSEC_VXLAN_TUNNELS_ENABLED}" == "yes" ]; then
782         ALL_NODES=(${!CONTROLIP} ${COMPUTE_IPS[*]})
783         for ((inx_ip1=0; inx_ip1<$((${#ALL_NODES[@]} - 1)); inx_ip1++))
784         do
785             for ((inx_ip2=$((inx_ip1 + 1)); inx_ip2<${#ALL_NODES[@]}; inx_ip2++))
786             do
787                 KEY1=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
788                 KEY2=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
789                 ID=0x$(dd if=/dev/urandom count=4 bs=1 2> /dev/null| xxd -p -c 8)
790                 ip1=${ALL_NODES[$inx_ip1]}
791                 ip2=${ALL_NODES[$inx_ip2]}
792                 ${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"
793                 ${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"
794                 ${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"
795                 ${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"
796
797                 ${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"
798                 ${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"
799                 ${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"
800                 ${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"
801             done
802         done
803
804         for ip in ${!CONTROLIP} ${COMPUTE_IPS[*]}
805         do
806             echo "ip xfrm configuration for node $ip:"
807             ${SSH} $ip "sudo ip xfrm policy list"
808             ${SSH} $ip "sudo ip xfrm state list"
809         done
810     fi
811
812     # Control Node - PUBLIC_BRIDGE will act as the external router
813     # Parameter values below are used in integration/test - changing them requires updates in intergration/test as well
814     EXTNET_GATEWAY_IP="10.10.10.250"
815     EXTNET_INTERNET_IP="10.9.9.9"
816     EXTNET_PNF_IP="10.10.10.253"
817     ${SSH} ${!CONTROLIP} "sudo ifconfig ${PUBLIC_BRIDGE} up ${EXTNET_GATEWAY_IP}/24"
818
819     # Control Node - external net PNF simulation
820     ${SSH} ${!CONTROLIP} "
821         sudo ip netns add pnf_ns;
822         sudo ip link add pnf_veth0 type veth peer name pnf_veth1;
823         sudo ip link set pnf_veth1 netns pnf_ns;
824         sudo ip link set pnf_veth0 up;
825         sudo ip netns exec pnf_ns ifconfig pnf_veth1 up ${EXTNET_PNF_IP}/24;
826         sudo ovs-vsctl add-port ${PUBLIC_BRIDGE} pnf_veth0;
827     "
828
829     # Control Node - external net internet address simulation
830     ${SSH} ${!CONTROLIP} "
831         sudo ip tuntap add dev internet_tap mode tap;
832         sudo ifconfig internet_tap up ${EXTNET_INTERNET_IP}/24;
833     "
834
835     # Computes
836     compute_index=1
837     for compute_ip in ${COMPUTE_IPS[*]}
838     do
839         # Tunnel from controller to compute
840         COMPUTEPORT=compute$(( compute_index++ ))_vxlan
841         ${SSH} ${!CONTROLIP} "
842             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
843         "
844         # Tunnel from compute to controller
845         CONTROLPORT="control_vxlan"
846         ${SSH} $compute_ip "
847             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
848         "
849     done
850 done
851
852 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
853     odlmgrip=OPENSTACK_HAPROXY_1_IP
854     HA_PROXY_IP=${!odlmgrip}
855     HA_PROXY_1_IP=${!odlmgrip}
856     odlmgrip2=OPENSTACK_HAPROXY_2_IP
857     HA_PROXY_2_IP=${!odlmgrip2}
858     odlmgrip3=OPENSTACK_HAPROXY_1_IP
859     HA_PROXY_3_IP=${!odlmgrip3}
860 else
861     HA_PROXY_IP=${ODL_SYSTEM_IP}
862     HA_PROXY_1_IP=${ODL_SYSTEM_1_IP}
863     HA_PROXY_2_IP=${ODL_SYSTEM_2_IP}
864     HA_PROXY_3_IP=${ODL_SYSTEM_3_IP}
865 fi
866
867 echo "Locating test plan to use..."
868 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
869 if [ ! -f "${testplan_filepath}" ]; then
870     testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
871 fi
872
873 echo "Changing the testplan path..."
874 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
875 cat testplan.txt
876
877 if [ -z "${SUITES}" ]; then
878     SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
879 fi
880
881 if [ "${OPENSTACK_BRANCH}" == "stable/pike" ]; then # Pike
882    AUTH="http://${!CONTROLIP}/identity"
883 else
884    AUTH="http://${!CONTROLIP}:35357/v3"
885 fi
886
887 #Environment Variables Needed to execute Openstack Client for Netvirt Jobs
888 cat > /tmp/os_netvirt_client_rc << EOF
889 export OS_USERNAME=admin
890 export OS_PASSWORD=admin
891 export OS_PROJECT_NAME=admin
892 export OS_USER_DOMAIN_NAME=default
893 export OS_PROJECT_DOMAIN_NAME=default
894 export OS_AUTH_URL=${AUTH}
895 export OS_IDENTITY_API_VERSION=3
896 export OS_IMAGE_API_VERSION=2
897 export OS_TENANT_NAME=admin
898 unset OS_CLOUD
899 EOF
900
901 source /tmp/os_netvirt_client_rc
902
903 #FIXME currently support only 1 site
904 echo "Starting Robot test suites ${SUITES} ..."
905 # please add pybot -v arguments on a single line and alphabetized
906 pybot -N ${TESTPLAN} --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} \
907     -v BUNDLEFOLDER:${BUNDLEFOLDER} \
908     -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
909     -v CONTROLLER_USER:${USER} \
910     -v DEVSTACK_DEPLOY_PATH:/opt/stack/devstack \
911     -v HA_PROXY_IP:${HA_PROXY_IP} \
912     -v HA_PROXY_1_IP:${HA_PROXY_1_IP} \
913     -v HA_PROXY_2_IP:${HA_PROXY_2_IP} \
914     -v HA_PROXY_3_IP:${HA_PROXY_3_IP} \
915     -v JDKVERSION:${JDKVERSION} \
916     -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
917     -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
918     -v NUM_OPENSTACK_SITES:${NUM_OPENSTACK_SITES} \
919     -v NUM_OS_SYSTEM:${NUM_OPENSTACK_SYSTEM} \
920     -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
921     -v ODL_SNAT_MODE:${ODL_SNAT_MODE} \
922     -v ODL_STREAM:${DISTROSTREAM} \
923     -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
924     -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_1_IP} \
925     -v ODL_SYSTEM_2_IP:${ODL_SYSTEM_2_IP} \
926     -v ODL_SYSTEM_3_IP:${ODL_SYSTEM_3_IP} \
927     -v ODL_SYSTEM_4_IP:${ODL_SYSTEM_4_IP} \
928     -v ODL_SYSTEM_5_IP:${ODL_SYSTEM_5_IP} \
929     -v ODL_SYSTEM_6_IP:${ODL_SYSTEM_6_IP} \
930     -v ODL_SYSTEM_7_IP:${ODL_SYSTEM_7_IP} \
931     -v ODL_SYSTEM_8_IP:${ODL_SYSTEM_8_IP} \
932     -v ODL_SYSTEM_9_IP:${ODL_SYSTEM_9_IP} \
933     -v OS_CONTROL_NODE_IP:${OPENSTACK_CONTROL_NODE_1_IP} \
934     -v OS_CONTROL_NODE_1_IP:${OPENSTACK_CONTROL_NODE_1_IP} \
935     -v OS_CONTROL_NODE_2_IP:${OPENSTACK_CONTROL_NODE_2_IP} \
936     -v OS_CONTROL_NODE_3_IP:${OPENSTACK_CONTROL_NODE_3_IP} \
937     -v OPENSTACK_BRANCH:${OPENSTACK_BRANCH} \
938     -v OS_COMPUTE_1_IP:${OPENSTACK_COMPUTE_NODE_1_IP} \
939     -v OS_COMPUTE_2_IP:${OPENSTACK_COMPUTE_NODE_2_IP} \
940     -v OS_COMPUTE_3_IP:${OPENSTACK_COMPUTE_NODE_3_IP} \
941     -v OS_COMPUTE_4_IP:${OPENSTACK_COMPUTE_NODE_4_IP} \
942     -v OS_COMPUTE_5_IP:${OPENSTACK_COMPUTE_NODE_5_IP} \
943     -v OS_COMPUTE_6_IP:${OPENSTACK_COMPUTE_NODE_6_IP} \
944     -v OS_USER:${USER} \
945     -v PUBLIC_PHYSICAL_NETWORK:${PUBLIC_PHYSICAL_NETWORK} \
946     -v SECURITY_GROUP_MODE:${SECURITY_GROUP_MODE} \
947     -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_1_IP} \
948     -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_1_IP} \
949     -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
950     -v USER_HOME:${HOME} \
951     -v WORKSPACE:/tmp \
952     ${TESTOPTIONS} ${SUITES} || true
953
954 echo "Examining the files in data/log and checking filesize"
955 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
956 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
957
958 echo "Tests Executed"
959 collect_logs_and_exit
960
961 true  # perhaps Jenkins is testing last exit code
962 # vim: ts=4 sw=4 sts=4 et ft=sh :