grenade/prep-target
Dean Troyer 11c51c3f68 Use DevStack functions in upgrade scripts
* Source target DevStack's functions in upgrade scripts to match what the
  project config functions expect.
* Source target DevStack's lib/tls in upgrade scripts that source
  target's lib/keystone (is_ssl_enabled_service())

Change-Id: Iab78d1efb7e40a3a67408f6e9a071723a3e931ff
2014-03-03 08:15:02 -06:00

111 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# ``prep-target`` handles the preparations for installing and configuring
# the "target" configuration of DevStack.
# Keep track of the devstack 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
# For debugging
set -o xtrace
# System Preparation
# ==================
# perform cleanup to ensure a clean starting environment
##add a config opt to still do this?
#rm -rf $TARGET_DEVSTACK_DIR
# Get DevStack if it doesn't exist
if [[ ! -d $TARGET_DEVSTACK_DIR ]]; then
git_clone $TARGET_DEVSTACK_REPO $TARGET_DEVSTACK_DIR $TARGET_DEVSTACK_BRANCH
fi
# Load up a copy of the downloaded images if not present
if [[ -d $BASE_RELEASE_DIR/images ]]; then
rsync -a $BASE_RELEASE_DIR/images $TARGET_DEVSTACK_DIR/files
fi
# Set up target localrc
# if localrc exists and localrc.orig does not exist, save localrc to localrc.orig
if [[ -r $TARGET_DEVSTACK_DIR/localrc && ! -r $TARGET_DEVSTACK_DIR/localrc.orig ]]; then
mv $TARGET_DEVSTACK_DIR/localrc $TARGET_DEVSTACK_DIR/localrc.orig
fi
# put devstack.localrc.target in place as localrc
sed -e "
s|\@TARGET_RELEASE_DIR\@|$TARGET_RELEASE_DIR|
s|\@DATA_DIR@|$DATA_DIR|
" $GRENADE_DIR/devstack.localrc.target >$TARGET_DEVSTACK_DIR/localrc
# if localrc.orig exists, append it to localrc
if [[ -r $TARGET_DEVSTACK_DIR/localrc.orig ]]; then
echo "#vvvvvvvvvv devstack-vm-gate.sh localrc vvvvvvvvvv" >>$TARGET_DEVSTACK_DIR/localrc
cat $TARGET_DEVSTACK_DIR/localrc.orig >>$TARGET_DEVSTACK_DIR/localrc
fi
# if devstack.localrc exists append it to locarc
if [[ -r $GRENADE_DIR/devstack.localrc ]]; then
echo "#vvvvvvvvvv devstack.localrc vvvvvvvvvv" >>$TARGET_DEVSTACK_DIR/localrc
cat $GRENADE_DIR/devstack.localrc >>$TARGET_DEVSTACK_DIR/localrc
fi
# Set up Screen
# =============
# Get target config
source $TARGET_DEVSTACK_DIR/functions
source $TARGET_DEVSTACK_DIR/stackrc
# Set a reasonable statusbar
SCREEN_HARDSTATUS=${SCREEN_HARDSTATUS:-'%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'}
screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"
# Prep the service check bits
init_service_check
# Set up Logging
# ==============
# Set up logging for ``stack.sh``
# Set ``LOGFILE`` to turn on logging
# Append '.xxxxxxxx' to the given name to maintain history
# where 'xxxxxxxx' is a representation of the date the file was created
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then
LOGDAYS=${LOGDAYS:-7}
CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT")
fi
if [[ -n "$LOGFILE" ]]; then
# First clean up old log files. Use the user-specified ``LOGFILE``
# as the template to search for, appending '.*' to match the date
# we added on earlier runs.
LOGDIR=$(dirname "$LOGFILE")
LOGNAME=$(basename "$LOGFILE")
mkdir -p $LOGDIR
find $LOGDIR -maxdepth 1 -name $LOGNAME.\* -mtime +$LOGDAYS -exec rm {} \;
LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
SUMFILE=$LOGFILE.${CURRENT_LOG_TIME}.summary
fi
if [[ -n "$SCREEN_LOGDIR" ]]; then
mkdir -p $SCREEN_LOGDIR
fi