make gnt-node work with vg and lv emulation
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 24 Jun 2014 20:01:26 +0000 (22:01 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 24 Jun 2014 20:04:38 +0000 (22:04 +0200)
This also unbreaks hbal, so it's useful :-)

Commands report real disk use (after compression), not volume sizes
as they do on uncompressed file systems

README
defaults.sh
parameters.list
sbin/lvs [new file with mode: 0755]
sbin/vgs [new file with mode: 0755]

diff --git a/README b/README
index 520ff6c..82b71c7 100644 (file)
--- a/README
+++ b/README
@@ -38,6 +38,21 @@ Now ssh into ganeti master node and do following:
 
   ln -sf /usr/share/ganeti/extstorage/zfs/bin/daily-block-snapshot /etc/cron.daily/
 
+5. install lvm wrapper scripts to report zfs volumes as lv
+
+  find /usr/share/ganeti/extstorage/zfs/sbin/ -type f | xargs -i ln -v -s -f {} /sbin/
+
+This scripts enable gnt-node commands to work:
+
+root@vmh02:/home/dpavlin# gnt-node list arh-hw
+Node               DTotal DFree MTotal MNode MFree Pinst Sinst
+arh-hw.gnt.ffzg.hr  87.8G 87.2G   7.8G  252M  5.6G     1     0
+
+root@vmh02:/home/dpavlin# gnt-node list-storage arh-hw
+Node               Type   Name     Size  Used   Free Allocatable
+arh-hw.gnt.ffzg.hr lvm-vg arh-hw 190.0G 62.7G 127.3G Y
+arh-hw.gnt.ffzg.hr lvm-vg ffzgvg  87.8G  610M  87.2G Y
+
 
 HELPER SCRIPTS
 
index a724950..7d8ab66 100644 (file)
@@ -13,3 +13,6 @@ test -z "$EXTP_CREATE" && EXTP_CREATE="-s -b 4k -o compression=lz4"
 
 # on zfs destroy remove snapshots of instance disks
 test -z "$EXTP_DESTROY" && EXTP_DESTROY="-r"
+
+# emulate VG configured in cluster for wrapper scripts in sbin
+test -z "$EXTP_VG" && EXTP_VG='ffzgvg'
index 62b071a..d08761b 100644 (file)
@@ -1,3 +1,4 @@
 zfs    where to create instance zfs volumes
 create         zfs create -V options
 destroy                gnt-instance remove also removes snapshots (set empty to disable)
+vg             cluster lvm volume group
diff --git a/sbin/lvs b/sbin/lvs
new file mode 100755 (executable)
index 0000000..1ccb137
--- /dev/null
+++ b/sbin/lvs
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. /usr/share/ganeti/extstorage/zfs/defaults.sh
+
+/sbin/lvm lvs $*
+
+# lvs --noheadings --units=m --nosuffix '--separator=|' -ovg_name,lv_name,lv_size,lv_attr
+if echo $* | -q grep vg_name,lv_name,lv_size,lv_attr ; then
+
+       zfs get volsize -t volume -r $EXPN_ZFS -H -p -o name,value | sed "s:$EXPN_ZFS::" | awk '{ print "  '$EXPN_VG'|"$1"|" $2 / 1024 / 1024 "|-wi-ao--" }'
+
+fi
+
diff --git a/sbin/vgs b/sbin/vgs
new file mode 100755 (executable)
index 0000000..fc3b2d6
--- /dev/null
+++ b/sbin/vgs
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+. /usr/share/ganeti/extstorage/zfs/defaults.sh
+
+set -x
+
+/sbin/lvm vgs $*
+
+# gnt-node list-storage
+# vgs --noheadings --units=m --nosuffix --separator '|' --options vg_name,vg_size,vg_free
+if echo $* | grep -q vg_name,vg_size,vg_free ; then
+       zfs list -H -p -o used,available $EXTP_ZFS | awk '{ print "  '$EXTP_VG'|" ( $1 + $2 ) / 1024 / 1024 "|" $2 / 1024 / 1024 }'
+
+# gnt-node list
+# vgs --noheadings --nosuffix --units=m --unbuffered '--separator=|' -ovg_name,vg_free,vg_attr,vg_size
+elif echo $* | grep -q vg_name,vg_free,vg_attr,vg_size ; then
+       zfs list -H -p -o available,used $EXTP_ZFS | awk '{ print "  '$EXTP_VG'|" $1 / 1024 / 1024 "|wz--n-|" ( $1 + $2 ) / 1024 / 1024 }'
+
+fi