
let projects declare that they will have a database to be saved, and we'll do it for them, in the mysql case. Eventually other saving issues should be left to per project save-state.sh scripts. services which aren't always enabled in grenade jobs have their settings files guarded with conditionals. Eventually we'll do conditional loading of these settings files, however for now this lets the rest of the infrastructure around running actions based on PLUGIN_DIRS and UPGRADE_SERVICES be *non* conditional, which simplifies them. Change-Id: I06cad95ca319e4403772e5fb394c0f8965e0bf9d
62 lines
1.5 KiB
Plaintext
62 lines
1.5 KiB
Plaintext
# functions - Grenade-specific functions
|
|
#
|
|
# The following variables are assumed to be defined by certain functions:
|
|
#
|
|
# - ``MYSQL_PASSWORD``
|
|
# - ``SAVE_DIR``
|
|
|
|
|
|
# Include the common functions
|
|
GRENADE_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
|
|
source ${TARGET_DEVSTACK_DIR}/functions
|
|
source ${GRENADE_DIR}/inc/upgrade
|
|
source ${GRENADE_DIR}/inc/plugin
|
|
|
|
# Save trace setting
|
|
XTRACE=$(set +o | grep xtrace)
|
|
set +o xtrace
|
|
|
|
# save_data() dumps service datastores into SAVE_DIR for base or
|
|
# target release.
|
|
function save_data {
|
|
local release=$1
|
|
local dir=$2
|
|
echo_summary "Dumping $release databases"
|
|
mkdir -p $SAVE_DIR
|
|
save_mysql_dbs $release $dir
|
|
|
|
# TODO(sdague): this should go into per project save-state scripts
|
|
if grep -q 'connection *= *mongo' /etc/ceilometer/ceilometer.conf; then
|
|
mongodump --db ceilometer --out $SAVE_DIR/ceilometer-dump.$release
|
|
fi
|
|
}
|
|
|
|
|
|
# Setup Exit Traps for debug purposes
|
|
trap exit_trap EXIT
|
|
function exit_trap {
|
|
# really important that this is the *first* line in this
|
|
# function, otherwise we corrupt the exit code
|
|
local r=$?
|
|
# we don't need tracing during this
|
|
set +o xtrace
|
|
if [[ $r -ne 0 ]]; then
|
|
# unwind the call stack on failures
|
|
local frame=0
|
|
while caller $frame; do
|
|
((frame++));
|
|
done
|
|
|
|
echo "Exit code: $r"
|
|
if [[ -x $TARGET_DEVSTACK_DIR/tools/worlddump.py ]]; then
|
|
$TARGET_DEVSTACK_DIR/tools/worlddump.py -d $LOGDIR
|
|
sleep 1
|
|
fi
|
|
fi
|
|
exit $r
|
|
}
|
|
|
|
|
|
# Restore xtrace
|
|
$XTRACE
|