Olivier Bourdon 7c376f7f5d Add MOS 10.0 support and fix 9.x for updates
Change-Id: I91d69a6f537bb7c85311aa34a857605e627aee9d
2017-04-11 07:54:54 +00:00

90 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
#
# Script to setup a Python virtual environment (if needed) and install all the
# project's dependencies
set -e
# Initialize the variables
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VENV_PATH=${VENV_PATH:-"${BASE_DIR}"/venv-stacklight-tests}
if [ -z "${FUELQA_GITREF}" ]; then
if [ -z "${ISO_PATH}" ]; then
echo "ISO_PATH and FUELQA_GITREF are missing. Please specify at least one."
exit 1
fi
# Pick up the correct fuel-qa branch depending on the ISO version
FUEL_VERSION=$(basename "${ISO_PATH}" | egrep -o '[0-9]+\.[0-9]+')
case "$FUEL_VERSION" in
7.0)
FUELQA_GITREF="stable/7.0"
;;
8.0)
FUELQA_GITREF="stable/8.0"
;;
9.0 | 9.1 | 9.2)
FUELQA_GITREF="stable/mitaka"
;;
10.0)
FUELQA_GITREF="stable/newton"
;;
*)
echo "Don't know which fuel-qa branch to use for ${ISO_PATH}"
echo "Please specify it explicitly with the FUELQA_GITREF variable"
exit 1
esac
fi
FUEL_REV=`echo $FUELQA_GITREF | sed -e 's?stable/??' -e 's/\.0.*//' -e 's/mitaka/9/' -e's/newton/10/'`
# Create the virtual environment if it doesn't exist yet
if [[ ! -f "$VENV_PATH"/bin/activate ]]; then
if ! which virtualenv; then
echo 'Cannot find the virtualenv executable!'
echo 'You should install it either using pip or your distribution package manager.'
exit 1
fi
echo "Creating virtual environment in '$VENV_PATH'"
virtualenv "$VENV_PATH"
. "$VENV_PATH"/bin/activate
# Always upgrade to the latest version of pip
pip install -U pip
else
. "$VENV_PATH"/bin/activate
fi
echo "Using virtual environment at '$VIRTUAL_ENV'"
if [[ "$(pip show fuelweb-test)" == "" ]]; then
# Install fuel-qa in the virtual environment
echo "Checking out fuel-qa, reference: $FUELQA_GITREF"
FUELQA_DIR=$(mktemp -d)
git clone https://github.com/openstack/fuel-qa.git -- "$FUELQA_DIR"
pushd "$FUELQA_DIR"
git checkout "$FUELQA_GITREF"
cp "${BASE_DIR}"/{MANIFEST.in,setup.py} ./
python setup.py sdist
pip install dist/fuelweb_test*.tar.gz
# Clean up stuff
popd
rm -rf "$FUELQA_DIR"
fi
# Install the project's dependencies
pip install -r"${BASE_DIR}/../../requirements/mos${FUEL_REV}-requirements.txt"
# List the Python packages (this can be useful for troubleshooting)
pip freeze
echo
echo
echo "The setup is now complete."
echo "Run this command in your shell to activate your Python virtual environment:"
echo " . $VIRTUAL_ENV/bin/activate"