diff --git a/src/tm_mad/common/delete b/src/tm_mad/common/delete index 9ae6e42f29..e2dd4bb636 100755 --- a/src/tm_mad/common/delete +++ b/src/tm_mad/common/delete @@ -36,16 +36,12 @@ fi . $TMCOMMON #------------------------------------------------------------------------------- -# Return if deleting a disk, we will delete them when removing the +# Return if deleting a disk, we will delete them when removing the # remote_system_ds directory for the VM (remotely) #------------------------------------------------------------------------------- DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` -if [ `is_disk $DST_PATH` -eq 1 ]; then - exit 0 -fi - log "Deleting $DST_PATH" ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH" diff --git a/src/tm_mad/iscsi/delete b/src/tm_mad/iscsi/delete index 0f068deb11..4964af081e 100755 --- a/src/tm_mad/iscsi/delete +++ b/src/tm_mad/iscsi/delete @@ -124,6 +124,9 @@ DELETE_CMD=$(cat < vmid dsid # - host is the target host to deploy the VM # - remote_system_ds is the path for the system datastore in the host @@ -40,6 +60,8 @@ fi . $TMCOMMON + + DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` @@ -60,27 +82,20 @@ vmfs_set_up # remote_system_ds directory for the VM (remotely) #------------------------------------------------------------------------------- -if [ `is_disk $DST_PATH` -eq 1 ]; then - exit 0 -fi - log "Deleting $DST_PATH" if [ "$USE_SSH" == "yes" ]; then - ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH" + ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH" else - DIRS_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID|grep -v "Content Listing"|grep -v "\-\-\-\-\-\-\-\-"|egrep -v "^[[:space:]]*$"` - for dir in $DIRS_TO_ERASE; do - FILES_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID/$dir|grep -v "Content Listing"|grep -v "\-\-\-\-\-\-\-\-"|egrep -v "^[[:space:]]*$"` - for file in $FILES_TO_ERASE; do - exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir/$file" \ - "Cannot delete [$DSID]$VMID/$dir/$file in $DST_HOST" - done - exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir" \ - "Cannot delete [$DSID]$VMID in $DST_HOST" - done - exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID" \ - "Cannot delete [$DSID]$VMID in $DST_HOST" + if [ `is_disk $DST_PATH` -eq 1 ]; then + vifs_rmdir $(basename $DST_PATH) + else + DIRS_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID|grep -v "Content Listing"|grep -Fv "--------"|egrep -v "^[[:space:]]*$"` + + for dir in $DIRS_TO_ERASE; do + vifs_rmdir $dir + done + fi fi exit 0