mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 03:12:55 +09:00
Bug #1911: Fix for wrong deleting of cdroms
This commit is contained in:
1 parent
98a3043a5a
commit
ea2f67a17d
3 files changed
+28
-13
No files matched your search
@@ -101,3 +101,22 @@ function get_tm_use_ssh {
|
||||
|
||||
echo $TM_USE_SSH
|
||||
}
|
||||
|
||||
#Return DISK_TYPE
|
||||
function disk_type
|
||||
{
|
||||
# Let's check if it is a CDROM
|
||||
DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}')
|
||||
XPATH="${ONE_LOCAL_VAR}/remotes/datastore/xpath.rb --stdin"
|
||||
|
||||
unset i XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(onevm show -x $VMID| $XPATH \
|
||||
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TYPE )
|
||||
|
||||
DISK_TYPE="${XPATH_ELEMENTS[0]}"
|
||||
|
||||
echo $DISK_TYPE
|
||||
}
|
||||
+1
-12
@@ -55,18 +55,7 @@ SYSTEM_DS_NAME=`basename $(dirname $(dirname $DST_PATH))`
|
||||
USE_SSH=$(get_tm_use_ssh $IMAGE_DS_NAME)
|
||||
|
||||
# Let's check if it is a CDROM
|
||||
DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}')
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
unset i XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(onevm show -x $VMID| $XPATH \
|
||||
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TYPE )
|
||||
|
||||
DISK_TYPE="${XPATH_ELEMENTS[0]}"
|
||||
DISK_TYPE=$(disk_type)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set up datastore
|
||||
|
||||
@@ -85,7 +85,14 @@ if [ "$USE_SSH" == "yes" ]; then
|
||||
ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH"
|
||||
else
|
||||
if [ `is_disk $DST_PATH` -eq 1 ]; then
|
||||
vifs_rmdir $(basename $DST_PATH)
|
||||
DISK_TYPE=$(disk_type)
|
||||
|
||||
if [ "$DISK_TYPE" != "CDROM" ]; then
|
||||
vifs_rmdir $(basename $DST_PATH)
|
||||
else
|
||||
exec_and_log "vifs $VI_PARAMS --force --rm [$DSID]$VMID/$DISK_ID.iso" \
|
||||
"Cannot delete [$DSID]$VMID/$DISK_ID in $DST_HOST"
|
||||
fi
|
||||
else
|
||||
DIRS_TO_ERASE=`vifs $VI_PARAMS --dir [$DSID]$VMID|grep -v "Content Listing"|grep -Fv -- "--------"|egrep -v "^[[:space:]]*$"`
|
||||
|
||||
|
||||
Reference in new issue
Block a user