summaryrefslogtreecommitdiffstats
path: root/bin/lvc.sh
diff options
context:
space:
mode:
authorPhilip Hands <phil@hands.com>2016-05-14 22:03:14 +0200
committerHolger Levsen <holger@layer-acht.org>2016-05-14 23:04:27 +0200
commit183047ae67b06004bdef17561678e5021c9b5a19 (patch)
tree124279fc9ffa5275d9195383e8ca8989122b68eb /bin/lvc.sh
parent306b243742aab4f21925cbd4d171702fb56e9083 (diff)
downloadjenkins.debian.net-183047ae67b06004bdef17561678e5021c9b5a19.tar.xz
lvc: discard snapshots if target volume is missing
Diffstat (limited to 'bin/lvc.sh')
-rwxr-xr-xbin/lvc.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/bin/lvc.sh b/bin/lvc.sh
index 5b1e5b31..c58c7aa6 100755
--- a/bin/lvc.sh
+++ b/bin/lvc.sh
@@ -30,6 +30,13 @@ fetch_if_newer() {
curl $curlopts -o $file $url
}
+discard_snapshots() {
+ domain=$1
+ for snap in $(sudo /usr/bin/virsh snapshot-list $domain --name) ; do
+ sudo /usr/bin/virsh snapshot-delete $domain $snap
+ done
+}
+
#
# define workspace + results
#
@@ -43,6 +50,11 @@ mkdir -p $RESULTS
mkdir -p $WORKSPACE/DebianToasterStorage
+# FIXME this should discover the 'target' bit of the path, probably via: virsh vol-list
+if [ ! -e "$WORKSPACE/DebianToasterStorage/target" ] ; then
+ discard_snapshots DebianToaster
+fi
+
trap cleanup_all INT TERM EXIT
#