Revision 494efbc7 src/tm_mad/vmfs/delete

View differences:

src/tm_mad/vmfs/delete
16 16
# limitations under the License.                                             #
17 17
#--------------------------------------------------------------------------- #
18 18

  
19
#-----------------------------------------------------------------------------
20
#-----------------------------------------------------------------------------
21

  
22
function vifs_rmdir {
23
    DIR_TO_RM="$1"
24
    FILES_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID/$DIR_TO_RM | \
25
grep -v "Content Listing"|grep -Fv "--------"|egrep -v "^[[:space:]]*$"`
26

  
27
    for file in $FILES_TO_ERASE; do
28
        exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$DIR_TO_RM/$file" \
29
            "Cannot delete [$DSID]$VMID/$dir/$file in $DST_HOST"
30
    done
31

  
32
    exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$dir" \
33
        "Cannot delete [$DSID]$VMID in $DST_HOST"
34
}
35

  
36
#-----------------------------------------------------------------------------
37
#-----------------------------------------------------------------------------
38

  
19 39
# DELETE <host:remote_system_ds/disk.i|host:remote_system_ds/> vmid dsid
20 40
#   - host is the target host to deploy the VM
21 41
#   - remote_system_ds is the path for the system datastore in the host
......
40 60

  
41 61
. $TMCOMMON
42 62

  
63

  
64

  
43 65
DST_PATH=`arg_path $DST`
44 66
DST_HOST=`arg_host $DST`
45 67

  
......
66 88
    ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH"
67 89
else
68 90
    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"
91
        vifs_rmdir $(basename $DST_PATH)
77 92
    else
78 93
        DIRS_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID|grep -v "Content Listing"|grep -Fv "--------"|egrep -v "^[[:space:]]*$"`
94

  
79 95
        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" \
86
             "Cannot delete [$DSID]$VMID in $DST_HOST"
96
            vifs_rmdir $dir
87 97
        done
88 98
    fi
89 99
fi

Also available in: Unified diff