77 lines
2.5 KiB
Plaintext
77 lines
2.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
|
|
FUNC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
|
|
source ${FUNC_DIR}/functions-common
|
|
|
|
# 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
|
|
local mysql_services="keystone glance nova cinder ironic"
|
|
|
|
echo_summary "Sourcing $release DevStack config"
|
|
source $dir/functions
|
|
source $dir/stackrc
|
|
echo_summary "Dumping $release databases"
|
|
mkdir -p $SAVE_DIR
|
|
if grep -q 'connection *= *mysql' /etc/ceilometer/ceilometer.conf; then
|
|
mysql_services+=" ceilometer"
|
|
elif grep -q 'connection *= *mongo' /etc/ceilometer/ceilometer.conf; then
|
|
mongodump --db ceilometer --out $SAVE_DIR/ceilometer-dump.$release
|
|
fi
|
|
for db in $mysql_services ; do
|
|
if mysql -uroot -p$MYSQL_PASSWORD -c $db -e ''; then
|
|
mysqldump -uroot -p$MYSQL_PASSWORD $db >$SAVE_DIR/$db.sql.$release
|
|
fi
|
|
done
|
|
neutron_db_names=$(mysql -uroot -p$MYSQL_PASSWORD -e "show databases;" | grep neutron || :)
|
|
for neutron_db in $neutron_db_names; do
|
|
mysqldump -uroot -p$MYSQL_PASSWORD $neutron_db >$SAVE_DIR/$neutron_db.sql.$release
|
|
done
|
|
}
|
|
|
|
|
|
# This function triggers the upgrade process for each project if it exists,
|
|
# otherwise it shows up a warning message about the lack of this file.
|
|
function upgrade_project {
|
|
# NOTE(maurosr): Ideally in a new upgrade test right after a release no new
|
|
# configuration is need, so we can go on without the from-<release> directory.
|
|
# This is also useful due to cross dependencie between d-g and grenade when
|
|
# enabling grenade to run a an upgrade between a new pair of releases.
|
|
|
|
project=$1
|
|
base_dir=$2
|
|
base_branch=$3
|
|
target_branch=$4
|
|
|
|
if [[ "$base_branch" == "$target_branch" ]]; then
|
|
direction="within"
|
|
else
|
|
direction="from"
|
|
fi
|
|
|
|
upgrade_dir=$(get_release_name_from_branch $base_branch)
|
|
upgrade_file=${base_dir}/${direction}"-"${upgrade_dir}/"upgrade-"${project}
|
|
if [[ -e ${upgrade_file} ]]; then
|
|
source ${upgrade_file} && configure_${project}_upgrade
|
|
else
|
|
echo "Warning: No new configurations were found for OpenStack $project."
|
|
echo "If your patch fails during the upgrade this may be the cause."
|
|
fi
|
|
}
|
|
|
|
# Restore xtrace
|
|
$XTRACE
|