Tidying up toci.sh
Moving env variables into toci-defaults, where they can all be defined and documented together. Change-Id: I7c75c90e52860063f8a7be1b907d4cd3afa3cc73
This commit is contained in:
parent
a5a9486409
commit
93359f62bc
50
toci-defaults
Normal file
50
toci-defaults
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Time the script was started
|
||||
export STARTTIME=$(date)
|
||||
|
||||
# All toci working files should go here
|
||||
export TOCI_WORKING_DIR=${TOCI_WORKING_DIR:-/opt/toci}
|
||||
export TRIPLEO_ROOT=$TOCI_WORKING_DIR # some scripts are expecting this
|
||||
|
||||
# Should toci get tripleo repositories
|
||||
export TOCI_GIT_CHECKOUT=${TOCI_GIT_CHECKOUT:-1}
|
||||
|
||||
# Files that should be cached between runs should go in here
|
||||
# e.g. downloaded images, git repo's etc...
|
||||
export TOCI_CACHE_DIR=${TOCI_CACHE_DIR:-/var/tmp/toci_cache}
|
||||
|
||||
# Any files to be uploaded to results server go here
|
||||
export TOCI_LOG_DIR=${TOCI_LOG_DIR:-$(mktemp -d --tmpdir toci_logs_XXXXXXX)}
|
||||
|
||||
# Set TOCI_ARCH to x86_64 to build 64 bit arch
|
||||
export TOCI_ARCH=${TOCI_ARCH:-'i386'}
|
||||
export TOCI_DIB_ARCH='i386'
|
||||
if [ "$TOCI_ARCH" == 'x86_64' ]; then
|
||||
export TOCI_DIB_ARCH='amd64'
|
||||
fi
|
||||
|
||||
# toci is building fedora images by default
|
||||
export TOCI_DISTROELEMENT=${TOCI_DISTROELEMENT:-'fedora selinux-permissive'}
|
||||
|
||||
# Set to 0 if you don't want an overcloud to be started
|
||||
export TOCI_DO_OVERCLOUD=${TOCI_DO_OVERCLOUD:-1}
|
||||
|
||||
# This is needed for help build the index.html if upload results to server
|
||||
export RESULT_CACHE=${RESULT_CACHE:-$TOCI_CACHE_DIR/results_cache.html}
|
||||
|
||||
# Add incubator scripts to path
|
||||
export PATH=$PATH:$TOCI_WORKING_DIR/tripleo-incubator/scripts
|
||||
|
||||
# Should toci remove VM's when finished
|
||||
export TOCI_CLEANUP=${TOCI_CLEANUP:-0}
|
||||
|
||||
# Should toci remove WORKING and LOG dirs when finished
|
||||
export TOCI_REMOVE=${TOCI_REMOVE:-0}
|
||||
|
||||
# Should toci upload results to a server
|
||||
export TOCI_UPLOAD=${TOCI_UPLOAD:-0}
|
||||
export TOCI_RESULTS_SERVER # nd server to upload to
|
||||
|
||||
# irc channel (on freenode) to notify on error
|
||||
export TOCI_IRC
|
76
toci.sh
76
toci.sh
@ -1,70 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. toci_functions.sh
|
||||
export TOCI_SOURCE_DIR=$(realpath $(dirname $0))
|
||||
|
||||
# Check for some dependencies
|
||||
commands=("patch" "make" "tar" "ssh" "arp" "busybox")
|
||||
for cmd in "${commands[@]}"; do
|
||||
which "${cmd}" > /dev/null 2>&1 || ERROR "$cmd: command not found"
|
||||
done
|
||||
# setup toci env variables
|
||||
source $TOCI_SOURCE_DIR/toci-defaults # defaults for env variables toci expects
|
||||
[ -e $TOCI_SOURCE_DIR/tocirc ] && source $TOCI_SOURCE_DIR/tocirc # env variables you may want to setup for this run
|
||||
[ -e ~/.toci ] && source ~/.toci # your local toci env setup
|
||||
|
||||
python -c 'import yaml' > /dev/null 2>&1 || ERROR "Please install PyYAML"
|
||||
. $TOCI_SOURCE_DIR/toci_functions.sh
|
||||
|
||||
# TODO : why do I need to do this, heat client complains without it
|
||||
python -c 'import keystoneclient' || ERROR "Please install python-keystoneclient"
|
||||
export PYTHONPATH=$(python -c 'import keystoneclient; print keystoneclient.__file__.rsplit("/", 1)[0]'):$PYTHONPATH
|
||||
check_dependencies
|
||||
|
||||
export STARTTIME=$(date)
|
||||
export TOCI_SOURCE_DIR=$PWD
|
||||
|
||||
# Toci defaults
|
||||
[ -e tocirc ] && source tocirc
|
||||
# env specific to this run, can contain
|
||||
# TOCI_RESULTS_SERVER, http_proxy, TOCI_UPLOAD, TOCI_REMOVE,
|
||||
[ -e ~/.toci ] && source ~/.toci
|
||||
|
||||
export TOCI_GIT_CHECKOUT
|
||||
|
||||
# All toci working files should go here
|
||||
export TOCI_WORKING_DIR=${TOCI_WORKING_DIR:-/opt/toci}
|
||||
mkdir -p $TOCI_WORKING_DIR
|
||||
# Any files to be uploaded to results server go here
|
||||
export TOCI_LOG_DIR=${TOCI_LOG_DIR:-$(mktemp -d --tmpdir toci_logs_XXXXXXX)}
|
||||
mkdir -p $TOCI_LOG_DIR
|
||||
# Files that should be cached between runs should go in here
|
||||
# e.g. downloaded images, git repo's etc...
|
||||
export TOCI_CACHE_DIR=/var/tmp/toci_cache
|
||||
|
||||
export TOCI_ARCH=${TOCI_ARCH:-'i386'}
|
||||
export TOCI_DIB_ARCH='i386'
|
||||
if [ "$TOCI_ARCH" == 'x86_64' ]; then
|
||||
export TOCI_DIB_ARCH='amd64'
|
||||
fi
|
||||
export TRIPLEO_ROOT=$TOCI_WORKING_DIR
|
||||
|
||||
export TOCI_DISTROELEMENT=${TOCI_DISTROELEMENT:-'fedora selinux-permissive'}
|
||||
|
||||
# Are we going to set up an overcloud
|
||||
export TOCI_DO_OVERCLOUD=${TOCI_DO_OVERCLOUD:-1}
|
||||
|
||||
RESULT_CACHE=$TOCI_CACHE_DIR/results_cache.html
|
||||
mkdir -p $TOCI_WORKING_DIR $TOCI_LOG_DIR $TOCI_CACHE_DIR
|
||||
|
||||
echo "Starting run $STARTTIME ( $TOCI_WORKING_DIR $TOCI_LOG_DIR )"
|
||||
|
||||
# On Exit write relevant toci env to a rc file
|
||||
trap get_tocienv EXIT
|
||||
|
||||
# If running in cron $USER isn't setup
|
||||
export USER=${USER:-$(whoami)}
|
||||
|
||||
mkdir -p $TOCI_CACHE_DIR
|
||||
|
||||
STATUS=0
|
||||
|
||||
mark_time Starting git
|
||||
./toci_git.sh > $TOCI_LOG_DIR/git.out 2>&1 || STATUS=1
|
||||
|
||||
|
||||
# set d-i-b env variables to fetch git repositories from local caches
|
||||
for repo in $TOCI_WORKING_DIR/*/.git ; do
|
||||
repo_dir=$(dirname $repo)
|
||||
@ -75,26 +33,26 @@ for repo in $TOCI_WORKING_DIR/*/.git ; do
|
||||
export DIB_REPOLOCATION_$repo_name=$repo_dir
|
||||
done
|
||||
|
||||
# Add incubator scripts to path
|
||||
export PATH=$PATH:$TOCI_WORKING_DIR/tripleo-incubator/scripts
|
||||
|
||||
mark_time Starting pre-cleanup
|
||||
./toci_cleanup.sh > $TOCI_LOG_DIR/cleanup.out 2>&1
|
||||
if [ $STATUS == 0 ] ; then
|
||||
mark_time Starting setup
|
||||
./toci_setup.sh > $TOCI_LOG_DIR/setup.out 2>&1 || STATUS=1
|
||||
fi
|
||||
|
||||
if [ $STATUS == 0 ] ; then
|
||||
mark_time Starting test
|
||||
./toci_test.sh > $TOCI_LOG_DIR/test.out 2>&1 || STATUS=1
|
||||
fi
|
||||
if [ ${TOCI_CLEANUP:-0} == 1 ] ; then
|
||||
|
||||
if [ $TOCI_CLEANUP == 1 ] ; then
|
||||
mark_time Starting cleanup
|
||||
./toci_cleanup.sh >> $TOCI_LOG_DIR/cleanup.out 2>&1 || STATUS=1
|
||||
fi
|
||||
|
||||
mark_time Finished
|
||||
|
||||
if [ ${TOCI_UPLOAD:-0} == 1 ] ; then
|
||||
if [ $TOCI_UPLOAD == 1 ] ; then
|
||||
cd $(dirname $TOCI_LOG_DIR)
|
||||
tar -czf - $(basename $TOCI_LOG_DIR) | ssh ec2-user@$TOCI_RESULTS_SERVER tar -C /var/www/html/toci -xzf -
|
||||
touch $RESULT_CACHE
|
||||
@ -116,12 +74,12 @@ if [ ${TOCI_UPLOAD:-0} == 1 ] ; then
|
||||
|
||||
fi
|
||||
|
||||
# Send a irc message
|
||||
if [ -n "$TOCI_IRC" -a $STATUS != 0 ] ; then
|
||||
# Send a irc message
|
||||
if [ -n "$TOCI_IRC" -a $STATUS != 0 ] ; then
|
||||
send_irc $TOCI_IRC ERROR during toci run, see http://$TOCI_RESULTS_SERVER/toci/$(basename $TOCI_LOG_DIR)/
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${TOCI_REMOVE:-0} == 1 ] ; then
|
||||
if [ $TOCI_REMOVE == 1 ] ; then
|
||||
rm -rf $TOCI_WORKING_DIR $TOCI_LOG_DIR
|
||||
fi
|
||||
|
||||
|
@ -86,3 +86,17 @@ ERROR(){
|
||||
echo $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check for some dependencies
|
||||
function check_dependencies(){
|
||||
commands=("patch" "make" "tar" "ssh" "arp" "busybox")
|
||||
for cmd in "${commands[@]}"; do
|
||||
which "${cmd}" > /dev/null 2>&1 || ERROR "$cmd: command not found"
|
||||
done
|
||||
|
||||
python -c 'import yaml' > /dev/null 2>&1 || ERROR "Please install PyYAML"
|
||||
|
||||
# TODO : why do I need to do this, heat client complains without it
|
||||
python -c 'import keystoneclient' || ERROR "Please install python-keystoneclient"
|
||||
export PYTHONPATH=$(python -c 'import keystoneclient; print keystoneclient.__file__.rsplit("/", 1)[0]'):$PYTHONPATH
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user