grenade/prep-target
Dean Troyer 78c87114a4 Install additional pacakges into venvs
Populate ADDITIONAL_VENV_PACKAGES on target side so venvs get
the packages they need.

Depends-On: I9cf298b936fd10c95e2ce5f51aab0d49d4b7f37f
Change-Id: Icc324fe6b0a8464027a624f9773030d08ca7c176
2015-04-22 13:40:30 -07:00

118 lines
3.1 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)
# Source params
source $GRENADE_DIR/grenaderc
# 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
# For debugging
set -o xtrace
# System Preparation
# ==================
# 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
# Build a wheel cache
source $TARGET_DEVSTACK_DIR/stackrc
if [[ -n ${WHEELHOUSE:-} && ! -d ${WHEELHOUSE:-} ]]; then
WHEELHOUSE=$WHEELHOUSE $TARGET_DEVSTACK_DIR/tools/build_wheels.sh
fi
# Find additional Python packages for venvs
install_database_python
# Set up Screen
# =============
# Get target config
source $TARGET_DEVSTACK_DIR/functions
source $TARGET_DEVSTACK_DIR/stackrc
# Set a reasonable screen statusbar
SCREEN_HARDSTATUS=${SCREEN_HARDSTATUS:-'%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'}
screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"
# Set up needed directories
# =========================
#
# This ensures that we have a clean service status directory so that
# we know for sure if services are coming up / down when we expect
# them.
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
# Retain credentials
# ==================
# Preserve accrc files for future usage
cp -a $BASE_DEVSTACK_DIR/accrc $TARGET_DEVSTACK_DIR/accrc
# Set up requirements
# ===================
# Pull down the new global requirements repository
#
# FIXME: this also pulls in new pbr which is not really needed, we
# should separate that in the future.
source $TARGET_DEVSTACK_DIR/lib/infra
install_infra
# Start helper services
# =====================
# Start dstat if it's in the ENABLED_SERVICES list. We really want
# this running before any services start to see what's going on when
# they start up, especialy if there are failures.
source $TARGET_DEVSTACK_DIR/lib/dstat
start_dstat