Shared disks: put IDs into a file on each node.
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Oct 2011 03:54:53 +0000 (14:54 +1100)
committerMartin Schwenke <martin@meltin.net>
Thu, 20 Oct 2011 04:02:50 +0000 (15:02 +1100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
config.d/10shareddisk.defconf

index 188a6bb8bb180844e413b7fd3a455b15a1b1513b..9edcae15a25519239e9b64a49fc2fa17fe45c170 100644 (file)
@@ -93,10 +93,14 @@ EOF
 
 ##############################
 
+shared_disk_ids="tmp/shared_disk_ids"
+
 register_hook create_cluster_hooks shared_disk_setup
 
 shared_disk_setup ()
 {
+    rm -f "$shared_disk_ids"
+
     if [ -n "$SHAREDDISKSIZE" -a -n "$SHAREDDISK_TEMPLATE" -a \
        -n "$SHAREDDISK_COUNT" -a "$SHAREDDISK_COUNT" != 0 ] ; then
 
@@ -140,6 +144,7 @@ EOF
            # setup a nice ID at the start of the disk
            "$SHARED_DISK_ID_GEN" "$i" > tmp/diskid
            dd if=tmp/diskid of=$VIRTBASE/$CLUSTER/shared$i conv=notrunc bs=1 > /dev/null 2>&1
+           head -n 1 tmp/diskid >>"$shared_disk_ids"
        done
        echo
 
@@ -162,6 +167,18 @@ shared_disk_id_default ()
     echo "${t:0:13}"
 }
 
+install_shared_disk_ids ()
+{
+    if [ -r "$shared_disk_ids" ] ; then
+       local t="/root/scripts/${shared_disk_ids##*/}"
+       echo "Installing shared disk ID file \"${t}\""
+       diskimage mkdir_p "/root/scripts"
+       diskimage put "$shared_disk_ids" "$t"
+    fi
+}
+
+register_hook setup_base_hooks install_shared_disk_ids
+
 ##########
 
 # Allow other configuration files to override this function but still