download packages from public IP to local repo and create the dev workflow 73/5173/6
authorMatthewLi <matthew.lijun@huawei.com>
Thu, 24 Dec 2015 01:38:50 +0000 (17:38 -0800)
committerMatthewLi <matthew.lijun@huawei.com>
Mon, 28 Dec 2015 02:11:06 +0000 (21:11 -0500)
JIRA: BOTTLENECK-36

Change-Id: I861a2eddb509c00f3418a6f15cb00c22be346ed0
Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
utils/infra_setup/vm_dev_setup/README.rst [new file with mode: 0644]
utils/infra_setup/vm_dev_setup/package.conf [new file with mode: 0644]
utils/infra_setup/vm_dev_setup/setup_env.sh [new file with mode: 0755]

diff --git a/utils/infra_setup/vm_dev_setup/README.rst b/utils/infra_setup/vm_dev_setup/README.rst
new file mode 100644 (file)
index 0000000..49a8f7f
--- /dev/null
@@ -0,0 +1,14 @@
+.. this folder is used to setup env for bottlenecks after ssh into VMs.
+
+how to use the script in this directory
+=======================================
+
+The script vm_setup.sh is used to git clone the bottlenecks code repo
+and download the dependent packages into the Cache from the public IP
+where they stored.
+
+The parameters are defined in package.conf file.
+
+Revision: _sha1_
+
+Build date: |today|
diff --git a/utils/infra_setup/vm_dev_setup/package.conf b/utils/infra_setup/vm_dev_setup/package.conf
new file mode 100644 (file)
index 0000000..e7210f3
--- /dev/null
@@ -0,0 +1,8 @@
+TIMEOUT=10
+export PACKAGE_URL=${PACKAGE_URL:-http://artifacts.opnfv.org}
+
+export BOTTLENECKS_REPO=${BOTTLENECKS_REPO:-https://gerrit.opnfv.org/gerrit/bottlenecks}
+export BOTTLENECKS_REPO_DIR=${BOTTLENECKS_REPO_DIR:-/bottlenecks}
+export RUBBOS_CACHE_DIR=${CACHE_DIR:-$BOTTLENECKS_REPO_DIR/rubbos/app_tools}
+export RUBBOS_RUN_DIR=${RUBBOS_RUN_DIR:-$BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts}
+export RUBBOS_EXE_DIR=${RUBBOS_EXE_DIR:-$BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts}
diff --git a/utils/infra_setup/vm_dev_setup/setup_env.sh b/utils/infra_setup/vm_dev_setup/setup_env.sh
new file mode 100755 (executable)
index 0000000..a0018c8
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+set -ex
+
+bottlenecks_prepare_env()
+{
+    set +e
+    for i in $PreInstall_Packages; do
+        if ! apt --installed list 2>/dev/null |grep "\<$i\>"
+        then
+            sudo apt-get install  -y --force-yes  $i
+        fi
+    done
+    set -e
+
+    if [ -d $RUBBOS_CACHE_DIR ]; then
+        rm -rf $RUBBOS_CACHE_DIR
+    fi
+    mkdir -p $RUBBOS_CACHE_DIR
+}
+
+bottlenecks_download_repo()
+{
+    if [ -d $BOTTELENECKS_REPO_DIR/.git ]; then
+        cd $BOTTLENECKS_REPO_DIR
+        git pull origin master
+        cd -
+    else
+        rm -rf $BOTTLENECKS_REPO_DIR
+        git clone $BOTTLENECKS_REPO $BOTTLENECKS_REPO_DIR
+    fi
+}
+
+bottlenecks_download_packages()
+{
+    for i in ; do #list the packages
+       if [[ ! $i ]]; then
+           continue
+       fi
+       curl --connect-timeout 10 -o $RUBBOS_CACHE_DIR/$i $PACKAGE_URL 2>/dev/null
+    done
+}
+
+bottlenecks_rubbos_install_exe()
+{
+    cd $RUBBOS_RUN_DIR
+    ./run.sh
+    cd $RUBBOS_EXE_DIR
+    ./CONTROL_rubbos_exec.sh
+}
+
+main()
+{
+    PreInstall_Packages="gcc gettext g++ libaio1 libaio-dev make"
+    SCRIPT_DIR=`cd ${BASH_SOURCE[0]%/*};pwd`
+
+    source $SCRIPT_DIR/package.conf
+
+    bottlenecks_prepare_env
+    bottlenecks_download_repo
+    bottlenecks_download_packages
+    bottlenecks_rubbos_install_exe
+}
+
+main