+# Following three functions are debugging helpers when debugging devstack changes.
+# Keeping them for now so we can simply call them when needed.
+ctrlhn=""
+comp1hn=""
+comp2hn=""
+function get_hostnames () {
+ set +e
+ local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
+ local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
+ local comp2ip=${OPENSTACK_COMPUTE_NODE_2_IP}
+ ctrlhn=$(${SSH} ${ctrlip} "hostname")
+ comp1hn=$(${SSH} ${comp1ip} "hostname")
+ comp2hn=$(${SSH} ${comp2ip} "hostname")
+ echo "hostnames: ${ctrlhn}, ${comp1hn}, ${comp2hn}"
+ set -e
+}
+
+function check_firewall() {
+ set +e
+ echo $-
+ local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
+ local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
+ local comp2ip=${OPENSTACK_COMPUTE_NODE_2_IP}
+
+ echo "check_firewall on control"
+ ${SSH} ${ctrlip} "
+ sudo systemctl status firewalld
+ sudo systemctl -l status iptables
+ sudo iptables --line-numbers -nvL
+ " || true
+ echo "check_firewall on compute 1"
+ ${SSH} ${comp1ip} "
+ sudo systemctl status firewalld
+ sudo systemctl -l status iptables
+ sudo iptables --line-numbers -nvL
+ " || true
+ echo "check_firewall on compute 2"
+ ${SSH} ${comp2ip} "
+ sudo systemctl status firewalld
+ sudo systemctl -l status iptables
+ sudo iptables --line-numbers -nvL
+ " || true
+}
+
+function get_service () {
+ set +e
+ local iter=$1
+ #local idx=$2
+ local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
+ local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
+
+ #if [ ${idx} -eq 1 ]; then
+ if [ ${iter} -eq 1 ] || [ ${iter} -gt 16 ]; then
+ curl http://${ctrlip}:5000
+ curl http://${ctrlip}:35357
+ curl http://${ctrlip}/identity
+ ${SSH} ${ctrlip} "
+ source /opt/stack/devstack/openrc admin admin;
+ env
+ openstack configuration show --unmask;
+ openstack service list
+ openstack --os-cloud devstack-admin --os-region RegionOne compute service list
+ openstack hypervisor list;
+ " || true
+ check_firewall
+ fi
+ #fi
+ set -e
+}
+
+# Check if rabbitmq is ready by looking for a pid in it's status.
+# The function returns the status of the grep command which callers can check.
+function is_rabbitmq_ready() {
+ local -r ip=$1
+ rm -f rabbit.txt
+ ${SSH} ${ip} "sudo rabbitmqctl status" > rabbit.txt
+ grep pid rabbit.txt
+}
+
+# retry the given command ($3) until success for a number of iterations ($1)
+# sleeping ($2) between tries.
+function retry() {
+ set +e
+ local -r -i max_tries=${1}
+ local -r -i sleep_time=${2}
+ local -r cmd=${3}
+ local -i retries=1
+ local -i rc=1
+ while true; do
+ echo "retry ${cmd}: attempt: ${retries}"
+ ${cmd}
+ rc=$?
+ if ((${rc} == 0)); then
+ break;
+ else
+ if ((${retries} == ${max_tries})); then
+ break
+ else
+ ((retries++))
+ sleep ${sleep_time}
+ fi
+ fi
+ done
+ set -e
+ return ${rc}
+}
+