add the argument WORKDIR in daisy-img-modify.sh 27/33327/2
authorzhongjun <zhong.jun@zte.com.cn>
Thu, 13 Apr 2017 07:14:45 +0000 (15:14 +0800)
committerzhongjun <zhong.jun@zte.com.cn>
Fri, 14 Apr 2017 07:42:02 +0000 (15:42 +0800)
the daisy install tmp workdir can be configurated as an input
argument in deploy.sh,and it also should be used in subshell
daisy-img-modify.sh,so add the input argument -w workdir
in daisy-img-modify.sh.

1.add an input argument -w workdir in daisy-img-modify.sh.
2.modify the WORKDIR default value to /tmp/workdir/daisy.
3.code refactor to put the centos7.qcow2 file clean statement
from the deploy.sh to daisy-img-modify.sh.

Change-Id: Id375a15ad2839c209329e644c5e032d044604e7d
Signed-off-by: zhongjun <zhong.jun@zte.com.cn>
ci/deploy/deploy.sh
tools/daisy-img-modify.sh

index 4ec2c2f..3d0ee56 100755 (executable)
@@ -137,7 +137,7 @@ DHA=$REMOTE_SPACE/labs/$LAB_NAME/$POD_NAME/daisy/config/deploy.yml
 NETWORK=$REMOTE_SPACE/labs/$LAB_NAME/$POD_NAME/daisy/config/network.yml
 
 # set temporay workdir
-WORKDIR=${WORKDIR:-/tmp/workdir}
+WORKDIR=${WORKDIR:-/tmp/workdir/daisy}
 
 [[ $POD_NAME =~ (virtual) ]] && IS_BARE=0
 
@@ -258,16 +258,12 @@ else
     virsh destroy daisy
     virsh undefine daisy
 fi
-if [ -f $WORKDIR/daisy/centos7.qcow2 ]; then
-    rm -rf $WORKDIR/daisy/centos7.qcow2
-fi
 
 echo "=======create daisy node================"
+$CREATE_QCOW2_PATH/daisy-img-modify.sh -c $CREATE_QCOW2_PATH/centos-img-modify.sh -w $WORKDIR -a $DAISY_IP $PARAS_IMAGE
 if [ $IS_BARE == 0 ];then
-    $CREATE_QCOW2_PATH/daisy-img-modify.sh -c $CREATE_QCOW2_PATH/centos-img-modify.sh -a $DAISY_IP $PARAS_IMAGE
     create_node $VMDELOY_DAISY_SERVER_NET daisy1 $VMDEPLOY_DAISY_SERVER_VM daisy
 else
-    $CREATE_QCOW2_PATH/daisy-img-modify.sh -c $CREATE_QCOW2_PATH/centos-img-modify.sh -a $DAISY_IP $PARAS_IMAGE
     virsh define $BMDEPLOY_DAISY_SERVER_VM
     virsh start daisy
 fi
index 8e02516..f172cee 100755 (executable)
@@ -15,19 +15,21 @@ usage()
 {
     cat << EOF
 USAGE: `basename $0` [-c sub-Command] [-a IP Address] [-g Gateway IP address] [-s image Size in GB]
-
+                     [-w workdir]
 OPTIONS:
   -c sub-command to modify the content
   -a IP address for the sub-command to set in the image
   -g gateway IP address for the sub-command to set in the image
   -s image size of gigabytes. If it is absent, the image size will not be changed.
+  -w workdir for temporary usage, optional
+  -h print this message and exit
 
 EXAMPLE:
     sudo `basename $0` -c centos-img-modify.sh -a 10.20.11.2 -g 10.20.11.1 -s 100
 EOF
 }
 
-while getopts "c:a:g:s:h" OPTION
+while getopts "c:a:g:s:w:h" OPTION
 do
     case $OPTION in
         c)
@@ -47,6 +49,9 @@ do
         s)
             img_size=${OPTARG}
             ;;
+        w)
+            WORKDIR=${OPTARG}
+            ;;
         h)
             usage
             exit 0
@@ -206,6 +211,9 @@ cleanup() {
         kpartx -dv $raw_imgfile || eliminate
     fi
     rm -f $raw_imgfile
+    if [ -f $imgfile ]; then
+        rm -rf $imgfile
+    fi
     rm -rf $mountdir
 }