fix-removing-persistent-lvm-volumes.diff
src/tm_mad/lvm/delete | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 | |
3 |
# for debugging purposes |
|
4 |
#set -x |
|
5 |
#exec 2>/tmp/err-$$.txt |
|
6 | ||
3 | 7 |
# -------------------------------------------------------------------------- # |
4 | 8 |
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # |
5 | 9 |
# # |
... | ... | |
43 | 47 |
DELETE_CMD=$(cat <<EOF |
44 | 48 |
DEV=\$(readlink $DST_PATH) |
45 | 49 |
LV=\$(basename \$DEV) |
46 |
VM=$(echo \$LV|cut -d- -f4) |
|
47 |
DISK_ID=$(echo \$LV|cut -d- -f5) |
|
50 | ||
51 |
# volume naming schema: |
|
52 |
# lv-one-{IMGID} ... persistent volume |
|
53 |
# lv-one-{PARENTIMGID-{VMID}-{DISKID} ... nonpersistent volume cloned from persistnent at vm creation |
|
54 |
# lv-one-{VMID}-{DISKID} ... nonpersistnet volume initialized at vm creation |
|
55 | ||
56 |
LV_NAME_ELEMENT_3="\$(echo \$LV|cut -d- -f3)" |
|
57 |
LV_NAME_ELEMENT_4="\$(echo \$LV|cut -d- -f4)" |
|
58 |
LV_NAME_ELEMENT_5="\$(echo \$LV|cut -d- -f5)" |
|
59 | ||
60 |
# lv-one-{PARENTIMGID-{VMID}-{DISKID} |
|
61 |
if [ -n "\$LV_NAME_ELEMENT_4" -a -n "\$LV_NAME_ELEMENT_5" ] |
|
62 |
then |
|
63 |
VM="\$LV_NAME_ELEMENT_4" |
|
64 |
DISK_ID="\$LV_NAME_ELEMENT_5" |
|
65 |
fi |
|
66 | ||
67 |
# lv-one-{VMID}-{DISKID} , reusing values from previous parsing |
|
68 |
if [ -z "\$LV_NAME_ELEMENT_5" -a -n "\$LV_NAME_ELEMENT_3" -a -n "\$LV_NAME_ELEMENT_4" ] |
|
69 |
then |
|
70 |
VM="\$LV_NAME_ELEMENT_3" |
|
71 |
DISK_ID="\$LV_NAME_ELEMENT_4" |
|
72 |
fi |
|
48 | 73 | |
49 | 74 |
if [ -n "\$VM" -a -n "\$DISK_ID" ]; then |
50 | 75 |
$SUDO $LVREMOVE -f \$DEV |