Revision 89dd74d7 src/tm_mad/vmfs/delete

View differences:

src/tm_mad/vmfs/delete
60 60
# remote_system_ds directory for the VM (remotely)
61 61
#-------------------------------------------------------------------------------
62 62

  
63
if [ `is_disk $DST_PATH` -eq 1 ]; then
64
	exit 0
65
fi
66

  
67 63
log "Deleting $DST_PATH"
68 64

  
69 65
if [ "$USE_SSH" == "yes" ]; then
70
	ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH"
66
    ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH"
71 67
else
72
	DIRS_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID|grep -v "Content Listing"|grep -v "\-\-\-\-\-\-\-\-"|egrep -v "^[[:space:]]*$"`
73
	for dir in $DIRS_TO_ERASE; do
74
		FILES_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID/$dir|grep -v "Content Listing"|grep -v "\-\-\-\-\-\-\-\-"|egrep -v "^[[:space:]]*$"`
75
		for file in $FILES_TO_ERASE; do
76
			exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir/$file" \
77
	                     "Cannot delete [$DSID]$VMID/$dir/$file in $DST_HOST"
78
	    done
79
    	exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir" \
80
         "Cannot delete [$DSID]$VMID in $DST_HOST"
81
	done
82
	exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID" \
68
    if [ `is_disk $DST_PATH` -eq 1 ]; then
69
            dir=$(basename $DST_PATH)
70
            FILES_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID/$dir|grep -v "Content Listing"|grep -Fv "--------"|egrep -v "^[[:space:]]*$"`
71
            for file in $FILES_TO_ERASE; do
72
                exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir/$file" \
73
                             "Cannot delete [$DSID]$VMID/$dir/$file in $DST_HOST"
74
            done
75
            exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir" \
76
             "Cannot delete [$DSID]$VMID in $DST_HOST"
77
    else
78
        DIRS_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID|grep -v "Content Listing"|grep -Fv "--------"|egrep -v "^[[:space:]]*$"`
79
        for dir in $DIRS_TO_ERASE; do
80
            FILES_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID/$dir|grep -v "Content Listing"|grep -Fv "--------"|egrep -v "^[[:space:]]*$"`
81
            for file in $FILES_TO_ERASE; do
82
                exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir/$file" \
83
                             "Cannot delete [$DSID]$VMID/$dir/$file in $DST_HOST"
84
            done
85
            exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir" \
83 86
             "Cannot delete [$DSID]$VMID in $DST_HOST"
87
        done
88
    fi
84 89
fi
85 90

  
86 91
exit 0

Also available in: Unified diff