Merge "Added configure_tempest() function"
[functest.git] / testcases / vIMS / CI / create_venv.sh
1 #!/bin/bash -e
2
3 # Script checks that venv exists. If it doesn't it will be created
4 # It requires python2.7 and virtualenv packages installed
5
6 BASEDIR=`dirname $0`
7 VENV_PATH=$1
8 VENV_NAME="venv_cloudify"
9 function venv_install() {
10     if command -v virtualenv-2.7; then
11         virtualenv-2.7 $1
12     elif command -v virtualenv2; then
13         virtualenv2 $1
14     elif command -v virtualenv; then
15         virtualenv $1
16     else
17         echo Cannot find virtualenv command.
18         return 1
19     fi
20 }
21
22 # exit when something goes wrong during venv install
23 set -e
24 if [ ! -d "$VENV_PATH/$VENV_NAME" ]; then
25     venv_install $VENV_PATH/$VENV_NAME
26     echo "Virtualenv" + $VENV_NAME + "created."
27 fi
28
29 if [ ! -f "$VENV_PATH/$VENV_NAME/updated" -o $BASEDIR/requirements.pip -nt $VENV_PATH/$VENV_NAME/updated ]; then
30     source $VENV_PATH/$VENV_NAME/bin/activate
31     pip install -r $BASEDIR/requirements.pip
32     touch $VENV_PATH/$VENV_NAME/updated
33     echo "Requirements installed."
34     deactivate
35 fi
36 set +e