Merge "Refactor init functions to simplify Grenade upgrades"

This commit is contained in:
Jenkins 2013-02-16 20:25:54 +00:00 committed by Gerrit Code Review
commit bd02bfb416
3 changed files with 71 additions and 46 deletions

View File

@ -254,37 +254,55 @@ create_cinder_accounts() {
fi
}
# create_cinder_cache_dir() - Part of the init_cinder() process
function create_cinder_cache_dir() {
# Create cache dir
sudo mkdir -p $CINDER_AUTH_CACHE_DIR
sudo chown $STACK_USER $CINDER_AUTH_CACHE_DIR
rm -f $CINDER_AUTH_CACHE_DIR/*
}
create_cinder_volume_group() {
# Configure a default volume group called '`stack-volumes`' for the volume
# service if it does not yet exist. If you don't wish to use a file backed
# volume group, create your own volume group called ``stack-volumes`` before
# invoking ``stack.sh``.
#
# By default, the backing file is 5G in size, and is stored in ``/opt/stack/data``.
if ! sudo vgs $VOLUME_GROUP; then
VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file}
# Only create if the file doesn't already exists
[[ -f $VOLUME_BACKING_FILE ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE
DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE`
# Only create if the loopback device doesn't contain $VOLUME_GROUP
if ! sudo vgs $VOLUME_GROUP; then
sudo vgcreate $VOLUME_GROUP $DEV
fi
fi
mkdir -p $CINDER_STATE_PATH/volumes
}
# init_cinder() - Initialize database and volume group
function init_cinder() {
# Force nova volumes off
NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/osapi_volume,//")
if is_service_enabled $DATABASE_BACKENDS; then
# (re)create cinder database
# (Re)create cinder database
recreate_database cinder utf8
# (re)create cinder database
# Migrate cinder database
$CINDER_BIN_DIR/cinder-manage db sync
fi
if is_service_enabled c-vol; then
# Configure a default volume group called '`stack-volumes`' for the volume
# service if it does not yet exist. If you don't wish to use a file backed
# volume group, create your own volume group called ``stack-volumes`` before
# invoking ``stack.sh``.
#
# By default, the backing file is 5G in size, and is stored in ``/opt/stack/data``.
if ! sudo vgs $VOLUME_GROUP; then
VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file}
# Only create if the file doesn't already exists
[[ -f $VOLUME_BACKING_FILE ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE
DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE`
# Only create if the loopback device doesn't contain $VOLUME_GROUP
if ! sudo vgs $VOLUME_GROUP; then sudo vgcreate $VOLUME_GROUP $DEV; fi
fi
mkdir -p $CINDER_STATE_PATH/volumes
create_cinder_volume_group
if sudo vgs $VOLUME_GROUP; then
if is_fedora || is_suse; then
@ -299,10 +317,7 @@ function init_cinder() {
fi
fi
# Create cache dir
sudo mkdir -p $CINDER_AUTH_CACHE_DIR
sudo chown $STACK_USER $CINDER_AUTH_CACHE_DIR
rm -f $CINDER_AUTH_CACHE_DIR/*
create_cinder_cache_dir
}
# install_cinder() - Collect source and prepare

View File

@ -141,6 +141,17 @@ function configure_glance() {
cp -p $GLANCE_DIR/etc/policy.json $GLANCE_POLICY_JSON
}
# create_glance_cache_dir() - Part of the init_glance() process
function create_glance_cache_dir() {
# Create cache dir
sudo mkdir -p $GLANCE_AUTH_CACHE_DIR/api
sudo chown $STACK_USER $GLANCE_AUTH_CACHE_DIR/api
rm -f $GLANCE_AUTH_CACHE_DIR/api/*
sudo mkdir -p $GLANCE_AUTH_CACHE_DIR/registry
sudo chown $STACK_USER $GLANCE_AUTH_CACHE_DIR/registry
rm -f $GLANCE_AUTH_CACHE_DIR/registry/*
}
# init_glance() - Initialize databases, etc.
function init_glance() {
# Delete existing images
@ -151,18 +162,13 @@ function init_glance() {
rm -rf $GLANCE_CACHE_DIR
mkdir -p $GLANCE_CACHE_DIR
# (re)create glance database
# (Re)create glance database
recreate_database glance utf8
# Migrate glance database
$GLANCE_BIN_DIR/glance-manage db_sync
# Create cache dir
sudo mkdir -p $GLANCE_AUTH_CACHE_DIR/api
sudo chown $STACK_USER $GLANCE_AUTH_CACHE_DIR/api
rm -f $GLANCE_AUTH_CACHE_DIR/api/*
sudo mkdir -p $GLANCE_AUTH_CACHE_DIR/registry
sudo chown $STACK_USER $GLANCE_AUTH_CACHE_DIR/registry
rm -f $GLANCE_AUTH_CACHE_DIR/registry/*
create_glance_cache_dir
}
# install_glanceclient() - Collect source and prepare

View File

@ -446,6 +446,14 @@ function create_nova_conf() {
done
}
# create_nova_cache_dir() - Part of the init_nova() process
function create_nova_cache_dir() {
# Create cache dir
sudo mkdir -p $NOVA_AUTH_CACHE_DIR
sudo chown $STACK_USER $NOVA_AUTH_CACHE_DIR
rm -f $NOVA_AUTH_CACHE_DIR/*
}
function create_nova_conf_nova_network() {
iniset $NOVA_CONF DEFAULT network_manager "nova.network.manager.$NET_MAN"
iniset $NOVA_CONF DEFAULT public_interface "$PUBLIC_INTERFACE"
@ -456,14 +464,17 @@ function create_nova_conf_nova_network() {
fi
}
# create_nova_keys_dir() - Part of the init_nova() process
function create_nova_keys_dir() {
# Create keys dir
sudo mkdir -p ${NOVA_STATE_PATH}/keys
sudo chown -R $STACK_USER ${NOVA_STATE_PATH}
}
# init_nova() - Initialize databases, etc.
function init_nova() {
# Nova Database
# -------------
# All nova components talk to a central database. We will need to do this step
# only once for an entire cluster.
# All nova components talk to a central database.
# Only do this step once on the API node for an entire cluster.
if is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-api; then
# (Re)create nova database
# Explicitly use latin1: to avoid lp#829209, nova expects the database to
@ -471,7 +482,7 @@ function init_nova() {
# 082_essex.py in nova)
recreate_database nova latin1
# (Re)create nova database
# Migrate nova database
$NOVA_BIN_DIR/nova-manage db sync
# (Re)create nova baremetal database
@ -481,15 +492,8 @@ function init_nova() {
fi
fi
# Create cache dir
sudo mkdir -p $NOVA_AUTH_CACHE_DIR
sudo chown $STACK_USER $NOVA_AUTH_CACHE_DIR
rm -f $NOVA_AUTH_CACHE_DIR/*
# Create the keys folder
sudo mkdir -p ${NOVA_STATE_PATH}/keys
# make sure we own NOVA_STATE_PATH and all subdirs
sudo chown -R $STACK_USER ${NOVA_STATE_PATH}
create_nova_cache_dir
create_nova_keys_dir
}
# install_novaclient() - Collect source and prepare