fixed adopt tests - still need hand-holding
[ganeti-extstorage-zfs] / sbin / lvrename
index c51e734..8a10502 100755 (executable)
@@ -1,11 +1,17 @@
-#!/bin/sh -x
+#!/bin/sh -ex
 
 . /usr/share/ganeti/extstorage/zfs/defaults.sh
 
 # lvrename ffzgvg cc9b16d9-7d14-452a-9150-74521bd8e721.disk0 d275c91f-70a7-4270-972c-b020fde9580b.disk0_data
 
 if [ "$EXTP_VG" = "$1" ] ; then
-       zfs rename $EXTP_ZFS/$2 $EXTP_ZFS/$3
+       # delete snapshots which can't be renamed
+
+       zfs rename $EXTP_ZFS/$2 $EXTP_ZFS/$3 || (
+               # rename filesystems with snapshots using clone/promote
+               zfs snap  $EXTP_ZFS/$2@$3
+               zfs clone $EXTP_ZFS/$2@$3 $EXTP_ZFS/$3
+       )
 else
        /sbin/lvm lvrename $*
 fi