230 lines
7.0 KiB
Django/Jinja
230 lines
7.0 KiB
Django/Jinja
function previous_release_from {
|
|
local release="${1:-master}"
|
|
local type="${2:-mixed_upgrade}"
|
|
local previous_version=""
|
|
case "${type}" in
|
|
'mixed_upgrade')
|
|
previous_version=$(previous_release_mixed_upgrade_case "${release}");;
|
|
'ffu_upgrade'|'ffu_undercloud_upgrade'|'ffu_standalone_upgrade')
|
|
previous_version=$(previous_release_ffu_upgrade_case "${release}");;
|
|
*)
|
|
echo "UNKNOWN_TYPE"
|
|
return 1
|
|
;;
|
|
esac
|
|
echo "${previous_version}"
|
|
}
|
|
|
|
function previous_release_mixed_upgrade_case {
|
|
local release="${1:-master}"
|
|
case "${release}" in
|
|
''|master|promotion-testing-hash-master)
|
|
echo "zed"
|
|
;;
|
|
zed|promotion-testing-hash-zed)
|
|
echo "wallaby"
|
|
;;
|
|
wallaby|promotion-testing-hash-wallaby)
|
|
echo "victoria"
|
|
;;
|
|
victoria|promotion-testing-hash-victoria)
|
|
echo "ussuri"
|
|
;;
|
|
ussuri|promotion-testing-hash-ussuri)
|
|
echo "train"
|
|
;;
|
|
*)
|
|
echo "UNKNOWN_RELEASE"
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
function previous_release_ffu_upgrade_case {
|
|
local release="${1:-master}"
|
|
|
|
case "${release}" in
|
|
''|master)
|
|
echo "wallaby"
|
|
;;
|
|
wallaby)
|
|
echo "train"
|
|
;;
|
|
*)
|
|
echo "INVALID_RELEASE_FOR_FFU"
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
function is_featureset {
|
|
local type="${1}"
|
|
local featureset_file="${2}"
|
|
|
|
[ $(shyaml get-value "${type}" "False"< "${featureset_file}") = "True" ]
|
|
}
|
|
|
|
function create_collect_logs_script {
|
|
cat > $LOGS_DIR/collect_logs.sh <<END
|
|
#!/bin/bash
|
|
set -x
|
|
|
|
export NODEPOOL_PROVIDER=${NODEPOOL_PROVIDER:-''}
|
|
export STATS_TESTENV=${STATS_TESTENV:-''}
|
|
export STATS_OOOQ=${STATS_OOOQ:-''}
|
|
export ZUUL_PIPELINE=${ZUUL_PIPELINE:-''}
|
|
export LOCAL_WORKING_DIR="$WORKSPACE/.quickstart"
|
|
export OPT_WORKDIR=$LOCAL_WORKING_DIR
|
|
export WORKING_DIR="$HOME"
|
|
export LOGS_DIR=$WORKSPACE/logs
|
|
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
|
export ANSIBLE_CONFIG=$OOOQ_DIR/ansible.cfg
|
|
export ARA_DATABASE=sqlite:///${LOCAL_WORKING_DIR}/ara.sqlite
|
|
export ZUUL_CHANGES=${ZUUL_CHANGES:-''}
|
|
export NODES_FILE=${NODES_FILE:-''}
|
|
export TOCI_JOBTYPE=$TOCI_JOBTYPE
|
|
export STABLE_RELEASE=${STABLE_RELEASE:-''}
|
|
export QUICKSTART_RELEASE=${QUICKSTART_RELEASE:-''}
|
|
|
|
set +u
|
|
source $LOCAL_WORKING_DIR/bin/activate
|
|
set -u
|
|
source $OOOQ_DIR/ansible_ssh_env.sh
|
|
|
|
sudo unbound-control dump_cache > $LOGS_DIR/dns_cache.txt
|
|
|
|
mkdir -p $LOGS_DIR/quickstart_files
|
|
find $LOCAL_WORKING_DIR -maxdepth 1 -type f -not -name "*sqlite" | while read i; do cp -l \$i $LOGS_DIR/quickstart_files/\$(basename \$i); done
|
|
|
|
$QUICKSTART_COLLECTLOGS_CMD > $LOGS_DIR/quickstart_collect_logs.log || \
|
|
echo "WARNING: quickstart collect-logs failed, check quickstart_collectlogs.log for details"
|
|
|
|
cp $LOGS_DIR/undercloud/var/log/postci.txt.gz $LOGS_DIR/ || true
|
|
|
|
if [[ -e $LOGS_DIR/undercloud/home/$USER/tempest/testrepository.subunit.gz ]]; then
|
|
cp $LOGS_DIR/undercloud/home/$USER/tempest/testrepository.subunit.gz ${LOGS_DIR}/testrepository.subunit.gz
|
|
fi
|
|
|
|
# Copy tempest.html to root dir
|
|
if [ -f $LOGS_DIR/undercloud/home/$USER/tempest/tempest.html.gz ]; then
|
|
cp $LOGS_DIR/undercloud/home/$USER/tempest/tempest.html.gz ${LOGS_DIR}
|
|
fi
|
|
|
|
# Copy tempest and .testrepository directory to /opt/stack/new/tempest and
|
|
# unzip
|
|
sudo -s -- <<SUDO
|
|
mkdir -p /opt/stack/new
|
|
if [ -d $LOGS_DIR/undercloud/home/$USER/tempest ]; then
|
|
cp -Rf $LOGS_DIR/undercloud/home/$USER/tempest /opt/stack/new
|
|
fi
|
|
if [ -d /opt/stack/new/tempest/.testrepository ]; then
|
|
gzip -d -r /opt/stack/new/tempest/.testrepository
|
|
fi
|
|
SUDO
|
|
|
|
# clean up base log dir
|
|
if [[ -e $LOGS_DIR/releases.sh ]]; then
|
|
mv $LOGS_DIR/releases.sh $LOGS_DIR/quickstart_files/
|
|
fi
|
|
if [[ -e $LOGS_DIR/playbook_executions.log ]]; then
|
|
mv $LOGS_DIR/playbook_executions.log $LOGS_DIR/quickstart_files/
|
|
fi
|
|
if [[ -e $LOGS_DIR/emit_releases_file.log ]]; then
|
|
mv $LOGS_DIR/emit_releases_file.log $LOGS_DIR/quickstart_files/
|
|
fi
|
|
|
|
# record the size of the logs directory
|
|
# -L, --dereference dereference all symbolic links
|
|
# Note: tail -n +1 is to prevent the error 'Broken Pipe' e.g. 'sort: write failed: standard output: Broken pipe'
|
|
|
|
du -L -ch $LOGS_DIR/* | tail -n +1 | sort -rh | head -n 200 &> $LOGS_DIR/quickstart_files/log-size.txt || true
|
|
END
|
|
|
|
}
|
|
|
|
get_extra_vars_from_release()
|
|
{
|
|
local release_name=$1
|
|
local release_hash=$2
|
|
local newest_release_hash=${3:-""}
|
|
local release_file=$LOCAL_WORKING_DIR/config/release/tripleo-ci/${DISTRIBUTION:-CentOS}-${DISTRIBUTION_MAJOR_VERSION:-7}/$release_name.yml
|
|
echo "--extra-vars @$release_file -e dlrn_hash=$release_hash -e get_build_command=$release_hash ${newest_release_hash:+-e dlrn_hash_newest=$newest_release_hash}"
|
|
}
|
|
|
|
# Enclose IPv6 addresses in brackets.
|
|
# This is needed for scp command where the first column of IPv6 address gets
|
|
# interpreted as the separator between address and path otherwise.
|
|
# $1 : IP address to sanitize
|
|
function sanitize_ip_address {
|
|
ip=$1
|
|
if [[ $ip =~ .*:.* ]]; then
|
|
echo \[$ip\]
|
|
else
|
|
echo $ip
|
|
fi
|
|
}
|
|
|
|
function python_cmd() {
|
|
distribution=unknown
|
|
distribution_major_version=unknown
|
|
# we prefer python2 because on few systems python->python3
|
|
python_cmd=python3
|
|
|
|
if [ -f /etc/os-release ]; then
|
|
. /etc/os-release
|
|
distribution_major_version=${VERSION_ID%.*}
|
|
case $NAME in
|
|
"Red Hat"*) distribution="RedHat"
|
|
if [ "$distribution_major_version" -ge "8" ]; then
|
|
python_cmd=python3
|
|
fi
|
|
;;
|
|
"CentOS"*)
|
|
distribution="CentOS"
|
|
if [ "$distribution_major_version" -ge "8" ]; then
|
|
python_cmd=python3
|
|
fi
|
|
;;
|
|
"Fedora"*)
|
|
distribution="Fedora"
|
|
if [ "$distribution_major_version" -ge "28" ]; then
|
|
python_cmd=python3
|
|
fi
|
|
;;
|
|
"Ubuntu"*)
|
|
distribution="Ubuntu"
|
|
;;
|
|
"Debian"*)
|
|
distribution="Debian"
|
|
;;
|
|
esac
|
|
elif [ -f /etc/lsb-release ]; then
|
|
. /etc/lsb-release
|
|
distribution=${DISTRIB_ID}xx
|
|
distribution_major_version=${DISTRIB_RELEASE%.*}
|
|
elif [ -f /etc/debian_version ]; then
|
|
distribution="Debian"
|
|
distribution_major_version=$(cat /etc/debian_version | cut -d. -f1)
|
|
else
|
|
# Covers for FreeBSD and many others
|
|
distribution=$(uname -s)
|
|
if [ $distribution = Darwin ]; then
|
|
distribution="MacOSX"
|
|
distribution_major_version=$(sw_vers -productVersion | cut -d. -f1)
|
|
fi
|
|
which $python_cmd 2>&1 >/dev/null || {
|
|
python_cmd=/usr/local/bin/python2.7
|
|
}
|
|
fi
|
|
echo $python_cmd
|
|
}
|
|
|
|
function package_manager() {
|
|
PKG="$(command -v dnf || command -v yum)"
|
|
if [ "$(python_cmd)" == "python3" ]; then
|
|
echo "${PKG} -y --exclude=python2* $*"
|
|
else
|
|
echo "${PKG} -y --exclude=python3* $*"
|
|
fi
|
|
}
|