1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-29 18:50:08 +03:00

feature #3782: tm/snap_delete for presistent qcow2

This commit is contained in:
Javi Fontan 2015-06-24 19:04:37 -04:00
parent dad5461f75
commit 1fd7c533cd

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
@ -31,14 +31,41 @@ else
DATASTORES=$ONE_LOCATION/var/datastores
fi
DRIVER_PATH=$(dirname $0)
. $TMCOMMON
SRC_PATH=`arg_path $SRC`
SYSTEM_DS_PATH=$(dirname ${SRC_PATH})
#-------------------------------------------------------------------------------
# Get Image information
#-------------------------------------------------------------------------------
DISK_ID=$(basename ${SRC} | cut -d. -f2)
DISK_PATH="${SYSTEM_DS_PATH}/disk.${DISK_ID}"
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
unset i j 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]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE)
DISK_SRC="${XPATH_ELEMENTS[j++]}"
CLONE="${XPATH_ELEMENTS[j++]}"
SYSTEM_DS_PATH=$(dirname ${SRC_PATH})
IMAGE_DS_PATH=$(dirname ${DISK_SRC})
if [ "$CLONE" = "YES" ]; then
DISK_PATH="${SYSTEM_DS_PATH}/disk.${DISK_ID}"
else
DISK_PATH=$DISK_SRC
fi
SNAP_DIR="${DISK_PATH}.snap"
SNAP_PATH="${SNAP_DIR}/${SNAP_ID}"
SNAP_PATH_RELATIVE=$(basename ${SNAP_PATH})