From a1f536dc573fa8181fc5f29b02a395c475e167ed Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Wed, 24 Jun 2015 17:29:15 -0400 Subject: [PATCH] feature #3782: ds/snap_delete for qcow2 --- src/datastore_mad/remotes/fs/snap_delete | 67 +++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) mode change 120000 => 100755 src/datastore_mad/remotes/fs/snap_delete diff --git a/src/datastore_mad/remotes/fs/snap_delete b/src/datastore_mad/remotes/fs/snap_delete deleted file mode 120000 index 9c454e8cd4..0000000000 --- a/src/datastore_mad/remotes/fs/snap_delete +++ /dev/null @@ -1 +0,0 @@ -../common/not_supported.sh \ No newline at end of file diff --git a/src/datastore_mad/remotes/fs/snap_delete b/src/datastore_mad/remotes/fs/snap_delete new file mode 100755 index 0000000000..dbcc07e222 --- /dev/null +++ b/src/datastore_mad/remotes/fs/snap_delete @@ -0,0 +1,66 @@ +#!/bin/bash -x + +# -------------------------------------------------------------------------- # +# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +DRV_ACTION=$1 +ID=$2 + +if [ -z "${ONE_LOCATION}" ]; then + TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh + DATASTORES=/var/lib/one/datastores +else + TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh + DATASTORES=$ONE_LOCATION/var/datastores +fi + +. $TMCOMMON + +DRIVER_PATH=$(dirname $0) + +# -------- Get image and datastore arguments from OpenNebula core ------------ + +DRV_ACTION=$1 +ID=$2 + +XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION" + +unset i XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \ + /DS_DRIVER_ACTION_DATA/IMAGE/TARGET_SNAPSHOT ) + +unset i + +DISK_SRC="${XPATH_ELEMENTS[i++]}" +SNAP_ID="${XPATH_ELEMENTS[i++]}" + + +SRC_PATH=`arg_path $SRC` + +SYSTEM_DS_PATH=$(dirname ${SRC_PATH}) + +DISK_ID=$(basename ${SRC} | cut -d. -f2) +DISK_PATH="${DISK_SRC}" +SNAP_DIR="${DISK_PATH}.snap" +SNAP_PATH="${SNAP_DIR}/${SNAP_ID}" +SNAP_PATH_RELATIVE=$(basename ${SNAP_PATH}) +CURRENT_PATH=${DISK_PATH} + +rm ${SNAP_PATH} +