summaryrefslogtreecommitdiffstats
path: root/utils/lab-reconfiguration/create_venv.sh
diff options
context:
space:
mode:
authorPeter Bandzi <pbandzi@cisco.com>2015-07-21 16:31:40 +0200
committerPeter Bandzi <pbandzi@cisco.com>2015-07-22 10:00:04 +0200
commit2beb18fbd56e7474e6da103634ce1feb697a4965 (patch)
treec45cf7109ab6be7ff281676f565e4b506720e0d0 /utils/lab-reconfiguration/create_venv.sh
parent85b729b515037043e21bbbcf3128045af1979c5e (diff)
Script for reconfiguring UCS network
Script will reconfigure POD-2 network for foreman or fuel Networ is specified in yaml file. Template must be created on UCS. JIRA: OCTO-109 Change-Id: I375a387c7607eb5dea126812569d8e19fda0c5c0 Signed-off-by: Peter Bandzi <pbandzi@cisco.com>
Diffstat (limited to 'utils/lab-reconfiguration/create_venv.sh')
-rwxr-xr-xutils/lab-reconfiguration/create_venv.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/utils/lab-reconfiguration/create_venv.sh b/utils/lab-reconfiguration/create_venv.sh
new file mode 100755
index 000000000..19d9b49c4
--- /dev/null
+++ b/utils/lab-reconfiguration/create_venv.sh
@@ -0,0 +1,35 @@
+#!/bin/bash -e
+
+# Script checks that venv exists. If it doesn't it will be created
+# It requires python2.7 and virtualenv packages installed
+
+BASEDIR=`dirname $0`
+
+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 "$BASEDIR/venv" ]; then
+ venv_install $BASEDIR/venv
+ echo "Virtualenv created."
+fi
+
+if [ ! -f "$BASEDIR/venv/updated" -o $BASEDIR/requirements.pip -nt $BASEDIR/venv/updated ]; then
+ source $BASEDIR/venv/bin/activate
+ pip install -r $BASEDIR/requirements.pip
+ touch $BASEDIR/venv/updated
+ echo "Requirements installed."
+ deactivate
+fi
+set +e