Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 120 lines (87 sloc) 3.62 KB
#!/usr/bin/env bash
# ``upgrade-volume``
# ``upgrade-nova`` must be complete for this to work!!!
echo "*********************************************************************"
echo "Begin $0"
echo "*********************************************************************"
# 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 $$
}
trap cleanup SIGHUP SIGINT SIGTERM
# Keep track of the grenade directory
GRENADE_DIR=$(cd $(dirname "$0") && pwd)
# 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
# Source params
source $GRENADE_DIR/grenaderc
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Upgrade Volumes
# ===============
# As cinder is new, an upgrade for nova-volume to nova-volume is performed
# first, then the migration to cinder is performed.
DATA_DIR=${DATA_DIR:-${DEST}/data}
cd $TRUNK_DEVSTACK_DIR
source $TRUNK_DEVSTACK_DIR/stackrc
SERVICE_HOST=${SERVICE_HOST:-localhost}
SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}
source $TRUNK_DEVSTACK_DIR/lib/keystone
source $TRUNK_DEVSTACK_DIR/lib/cinder
# Kill any running daemons
#stop_cinder
# Kill running Nova Volume and Cinder processes
for serv in c-sch c-api c-vol n-vol; do
screen -S $SCREEN_NAME -p $serv -X kill
done
# DevStack-specific
# -----------------
# DevStack changed the default storage for volumes between Essex and Folsom
# * move /opt/stack/nova-volumes-backing-file to
# /opt/stack/data/stack-volumes-backing-file
# * volume group name changed from nova-volumes to stack-volumes
# * default size is now 5GB, we don't change that here
# Put this here since Folsom DevStack defaults it in stack.sh
ESSEX_VOLUME_BACKING_FILE=${ESSEX_VOLUME_BACKING_FILE:-$DEST/nova-volumes-backing-file}
ESSEX_VOLUME_GROUP=${ESSEX_VOLUME_GROUP:-nova-volumes}
FOLSOM_VOLUME_BACKING_FILE=${FOLSOM_VOLUME_BACKING_FILE:-$DATA_DIR/stack-volumes-backing-file}
FOLSOM_VOLUME_GROUP=${FOLSOM_VOLUME_GROUP:-stack-volumes}
if [[ -r $ESSEX_VOLUME_BACKING_FILE ]]; then
echo "Essex file exists, save it"
# Release it from LVM
sudo vgchange -an $ESSEX_VOLUME_GROUP
sudo vgrename $ESSEX_VOLUME_GROUP $FOLSOM_VOLUME_GROUP
LOOP_DEV=$(sudo pvs -o pv_name,vg_name | awk "/$ESSEX_VOLUME_GROUP/ { print \$1 }")
sudo losetup -d $LOOP_DEV || true
mkdir -p $DATA_DIR
mv $ESSEX_VOLUME_BACKING_FILE $FOLSOM_VOLUME_BACKING_FILE
# Let DevStack startup handle it from here?
fi
# Migrate to Cinder
# -----------------
MYSQL_HOST=${MYSQL_HOST:-localhost}
MYSQL_USER=${MYSQL_USER:-root}
BASE_SQL_CONN=$(source $WORK_DEVSTACK_DIR/stackrc; echo ${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST})
install_cinder
configure_cinder
init_cinder
# Migrate the volume tables from nova to cinder
cinder-manage migrate import_db --src=$BASE_SQL_CONN --dest=$BASE_SQL_CONN || die "DB migration error"
start_cinder
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End $0"
echo "*********************************************************************"