tm_delete_lvm.sh

Delete script for LVM by Sebastien Goasguen - Ruben S. Montero, 07/27/2009 01:48 am

Download (2 kB)

 
1
#!/bin/bash
2
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad   #
5
# Complutense de Madrid (dsa-research.org)                                   #
6
#                                                                            #
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
8
# not use this file except in compliance with the License. You may obtain    #
9
# a copy of the License at                                                   #
10
#                                                                            #
11
# http://www.apache.org/licenses/LICENSE-2.0                                 #
12
#                                                                            #
13
# Unless required by applicable law or agreed to in writing, software        #
14
# distributed under the License is distributed on an "AS IS" BASIS,          #
15
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
16
# See the License for the specific language governing permissions and        #
17
# limitations under the License.                                             #
18
#--------------------------------------------------------------------------- #
19
# Modified by Sebastien Goasguen <sebgoa@clemson.edu>
20
21
SRC=$1
22
DST=$2
23
24
if [ -z "${ONE_LOCATION}" ]; then
25
   TMCOMMON=/usr/lib/one/mads/tm_common.sh
26
else
27
   TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
28
fi
29
30
. $TMCOMMON
31
32
#SRC_PATH=`arg_path $SRC`
33
#SRC_HOST=`arg_host $SRC`
34
35
DST_PATH=`arg_path $DST`
36
DST_HOST=`arg_host $DST`
37
38
log "DST: $DST_PATH"
39
40
DST_DIR=`dirname $DST_PATH`
41
VOL_NAME=`echo $DST_PATH | awk -F/ '{print $4"-"$6}' | sed s/disk.//g`
42
DST_DIR_IMAGES=`echo $DST_PATH | awk -F/ '{print "/"$2"/"$3"/"$4}'`
43
44
log "Deleting $DST_DIR_IMAGES..."
45
exec_and_log "ssh $DST_HOST rm -rf $DST_DIR_IMAGES"
46
47
log "Removing Logical Volume $VOL_NAME..."
48
exec_and_log "ssh $DST_HOST sudo /usr/sbin/lvremove -f /dev/xen_vg/$VOL_NAME "