Revision a1f536dc

View differences:

src/datastore_mad/remotes/fs/snap_delete
1
../common/not_supported.sh
src/datastore_mad/remotes/fs/snap_delete
1
#!/bin/bash -x
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs        #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
DRV_ACTION=$1
20
ID=$2
21

  
22
if [ -z "${ONE_LOCATION}" ]; then
23
    TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
24
    DATASTORES=/var/lib/one/datastores
25
else
26
    TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
27
    DATASTORES=$ONE_LOCATION/var/datastores
28
fi
29

  
30
. $TMCOMMON
31

  
32
DRIVER_PATH=$(dirname $0)
33

  
34
# -------- Get image and datastore arguments from OpenNebula core ------------
35

  
36
DRV_ACTION=$1
37
ID=$2
38

  
39
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
40

  
41
unset i XPATH_ELEMENTS
42

  
43
while IFS= read -r -d '' element; do
44
    XPATH_ELEMENTS[i++]="$element"
45
done < <($XPATH     /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \
46
                    /DS_DRIVER_ACTION_DATA/IMAGE/TARGET_SNAPSHOT )
47

  
48
unset i
49

  
50
DISK_SRC="${XPATH_ELEMENTS[i++]}"
51
SNAP_ID="${XPATH_ELEMENTS[i++]}"
52

  
53

  
54
SRC_PATH=`arg_path $SRC`
55

  
56
SYSTEM_DS_PATH=$(dirname ${SRC_PATH})
57

  
58
DISK_ID=$(basename ${SRC} | cut -d. -f2)
59
DISK_PATH="${DISK_SRC}"
60
SNAP_DIR="${DISK_PATH}.snap"
61
SNAP_PATH="${SNAP_DIR}/${SNAP_ID}"
62
SNAP_PATH_RELATIVE=$(basename ${SNAP_PATH})
63
CURRENT_PATH=${DISK_PATH}
64

  
65
rm ${SNAP_PATH}
66

  

Also available in: Unified diff