list all istance rbd disks and snapshots
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 27 Jul 2018 22:11:54 +0000 (00:11 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 27 Jul 2018 22:11:54 +0000 (00:11 +0200)
gnt-rbd.sh [new file with mode: 0755]

diff --git a/gnt-rbd.sh b/gnt-rbd.sh
new file mode 100755 (executable)
index 0000000..ff96693
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh -e
+
+dir=/dev/shm/instance
+test -e $dir || mkdir $dir
+
+gnt-instance list -o name,disk_template | grep ' rbd$' | cut -d' ' -f1 | while read instance ; do
+       if [ ! -e $dir/$instance ] ; then
+               gnt-instance info $instance | tee > $dir/$instance
+       fi
+done
+
+grep --with-filename logical_id /dev/shm/instance/* | sed "s/^.*\///; s/:.*, '/ /; s/'.*$//;" | tee /dev/shm/instance-rbd | while read instance disk ; do
+       echo "$instance $disk"
+       rbd snap ls $disk | sed "s/^/# /"
+done
+