aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/vnf/ims/create_venv.sh
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-11-24 18:25:52 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2016-11-25 15:09:35 +0100
commit165ff17205d99b18df36e5ac6f34ede858e3da17 (patch)
tree3199a34b651204cd62bdc78b5c5fc19c73ca3f02 /functest/opnfv_tests/vnf/ims/create_venv.sh
parent96aef41089d2c62913320028dd9618197d0e75c5 (diff)
file/dir renaming for consistency
JIRA: FUNCTEST-579 Change-Id: Iaa545db70bfb76770df0a3d17871e29ce518ff2d Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'functest/opnfv_tests/vnf/ims/create_venv.sh')
-rwxr-xr-xfunctest/opnfv_tests/vnf/ims/create_venv.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/functest/opnfv_tests/vnf/ims/create_venv.sh b/functest/opnfv_tests/vnf/ims/create_venv.sh
new file mode 100755
index 00000000..575fd177
--- /dev/null
+++ b/functest/opnfv_tests/vnf/ims/create_venv.sh
@@ -0,0 +1,44 @@
+#!/bin/bash -e
+
+# Script checks that venv exists. If it doesn't it will be created
+# It requires python2.7 and virtualenv packages installed
+#
+# Copyright (c) 2015 Orange
+# valentin.boucher@orange.com
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+
+BASEDIR=`dirname $0`
+VENV_PATH=$1
+VENV_NAME="venv_cloudify"
+function venv_install() {
+ if command -v virtualenv-2.7; then
+ virtualenv-2.7 $1
+ elif command -v virtualenv2; then
+ virtualenv2 $1
+ elif command -v virtualenv; then
+ virtualenv $1
+ else
+ echo Cannot find virtualenv command.
+ return 1
+ fi
+}
+
+# exit when something goes wrong during venv install
+set -e
+if [ ! -d "$VENV_PATH/$VENV_NAME" ]; then
+ venv_install $VENV_PATH/$VENV_NAME
+ echo "Virtualenv" + $VENV_NAME + "created."
+fi
+
+if [ ! -f "$VENV_PATH/$VENV_NAME/updated" -o $BASEDIR/requirements.pip -nt $VENV_PATH/$VENV_NAME/updated ]; then
+ source $VENV_PATH/$VENV_NAME/bin/activate
+ pip install -r $BASEDIR/requirements.pip
+ touch $VENV_PATH/$VENV_NAME/updated
+ echo "Requirements installed."
+ deactivate
+fi
+set +e