avoid needless package reinstall 97/17997/1
authorQiLiang <liangqi1@huawei.com>
Thu, 4 Aug 2016 10:06:50 +0000 (18:06 +0800)
committerQiLiang <liangqi1@huawei.com>
Thu, 4 Aug 2016 10:24:26 +0000 (18:24 +0800)
If you do not run deploy.sh for the first time, then export below env
before run deploy.sh can avoid needless package reinstall.

export DEPLOY_FIRST_TIME="false"

JIRA: COMPASS-449

Change-Id: Ia3b51bd02f4a131d57bf5793900faad9e1acb09e
Signed-off-by: QiLiang <liangqi1@huawei.com>
deploy/launch.sh
deploy/prepare.sh

index 9947bd8..488e0fd 100755 (executable)
@@ -12,6 +12,8 @@ WORK_DIR=$COMPASS_DIR/work/deploy
 
 mkdir -p $WORK_DIR/script
 
+export DEPLOY_FIRST_TIME=${DEPLOY_FIRST_TIME-"true"}
+
 source ${COMPASS_DIR}/deploy/prepare.sh
 prepare_python_env
 source ${COMPASS_DIR}/util/log.sh
index e7d8444..a4f606a 100755 (executable)
@@ -36,11 +36,14 @@ function download_iso()
 }
 
 function prepare_env() {
-    sudo apt-get update -y
-    sudo apt-get install -y --force-yes mkisofs bc curl ipmitool openvswitch-switch
-    sudo apt-get install -y --force-yes git python-dev
-    sudo apt-get install -y --force-yes libxslt-dev libxml2-dev libvirt-dev build-essential qemu-utils qemu-kvm libvirt-bin virtinst libmysqld-dev
-    sudo apt-get install -y --force-yes libffi-dev libssl-dev
+   if [[ "$DEPLOY_FIRST_TIME" == "true" ]]; then
+        sudo apt-get update -y
+        sudo apt-get install -y --force-yes mkisofs bc curl ipmitool openvswitch-switch
+        sudo apt-get install -y --force-yes git python-dev
+        sudo apt-get install -y --force-yes libxslt-dev libxml2-dev libvirt-dev build-essential qemu-utils qemu-kvm libvirt-bin virtinst libmysqld-dev
+        sudo apt-get install -y --force-yes libffi-dev libssl-dev
+    fi
+
     sudo service libvirt-bin restart
     if sudo service openvswitch-switch status|grep stop; then
         sudo service openvswitch-switch start
@@ -71,7 +74,7 @@ function prepare_env() {
     sudo cp ${COMPASS_DIR}/deploy/qemu_hook.sh /etc/libvirt/hooks/qemu
 }
 
-function  prepare_python_env() {
+function  _prepare_python_env() {
    rm -rf $WORK_DIR/venv
    mkdir -p $WORK_DIR/venv
 
@@ -88,3 +91,17 @@ function  prepare_python_env() {
    pip install --upgrade oslo.config
    pip install --upgrade ansible
 }
+
+function prepare_python_env()
+{
+    if [[ "$DEPLOY_FIRST_TIME" == "true" ]]; then
+        _prepare_python_env
+    else
+        source $WORK_DIR/venv/bin/activate
+        if [[ $? -ne 0 ]]; then
+            _prepare_python_env
+        fi
+    fi
+    which python
+}
+