grenade/save-state
John L. Villalovos 88eab6757a Fix broken logic for detecting if executable exists
Code was checking if $(executable) was executable. But $(executable)
would run the executable and get the output from the executable. This
output was not the path to the executable.

Fix this and also use correct name for iptables-save (was iptable-save)

Change-Id: Ie2ccd405cd01acea7201a199b4c8c12922e46e4f
2016-11-12 09:29:14 -08:00

71 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# ``save-state``
echo "*********************************************************************"
echo "Begin $0"
echo "*********************************************************************"
set -o errexit
# Clean up any resources that may be in use
cleanup() {
set +o errexit
echo "*********************************************************************"
echo "ERROR: Abort $0"
echo "*********************************************************************"
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
# Keep track of the grenade directory
GRENADE_DIR=$(cd $(dirname "$0") && pwd)
# Source params
source $GRENADE_DIR/grenaderc
# Import common functions
source $GRENADE_DIR/functions
# Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
# and ``DISTRO``
GetDistro
# For debugging
set -o xtrace
# Save databases
# --------------
save_data $BASE_RELEASE $BASE_DEVSTACK_DIR
# Save ebtables/iptables
# ----------------------
# NOTE(sileht): If nova is not installed these tools are not present
if [[ $(type -P iptables-save) != "" ]]; then
sudo iptables-save >$SAVE_DIR/iptables.$BASE_RELEASE
fi
if [[ $(type -P ebtables) != "" ]]; then
sudo ebtables -t broute -L >$SAVE_DIR/ebtables-broute.$BASE_RELEASE
sudo ebtables -t filter -L >$SAVE_DIR/ebtables-filter.$BASE_RELEASE
sudo ebtables -t nat -L >$SAVE_DIR/ebtables-nat.$BASE_RELEASE
fi
# Log RabbitMQ state
# ------------------
if $(source $BASE_DEVSTACK_DIR/stackrc; is_service_enabled rabbit); then
sudo rabbitmqctl list_queues messages consumers arguments name >$SAVE_DIR/rabbitmq-queues.txt
sudo rabbitmqctl report >$SAVE_DIR/rabbitmq-report.txt
fi
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End $0"
echo "*********************************************************************"