Store shared disk IDs in a variable instead of a file
authorMartin Schwenke <martin@meltin.net>
Mon, 30 Jun 2014 04:39:49 +0000 (14:39 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 2 Jul 2014 10:26:52 +0000 (20:26 +1000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
base/all/root/scripts/setup_clusterfs_gpfs.sh
config.d/10shareddisk.defconf

index 8ab0156..e7ea6cf 100755 (executable)
@@ -10,6 +10,7 @@ gpfs_num_nsds="@@GPFS_DEFAULT_NSDS@@"
 cluster_name="@@CLUSTER@@"
 mountpoint="@@CLUSTERFS_DEFAULT_MOUNTPOINT@@"
 nodes_storage_gpfs="@@NODES_STORAGE_GPFS@@"
+shared_disk_ids="@@SHARED_DISK_IDS@@"
 
 dir=$(dirname "$0")
 
@@ -132,14 +133,8 @@ gpfs_mknsd ()
     echo
     echo "Setting up NSDs"
 
-    _idfile="${dir}/shared_disk_ids.${cluster_name}"
-    if [ ! -r "$_idfile" ] ; then
-       echo "ERROR: missing disk ID file \"${_idfile}\""
-       exit 1
-    fi
-
     # Create an extended regexp that matches any of the IDs
-    pat=$(tr '\n' '|' <"$_idfile"  | sed -e 's@|$@@')
+    pat=$(echo "$shared_disk_ids" | sed -e 's@  *@|@g')
 
     # Now get devices and names from multipath
     multipath -dl |
index 7b7b645..612ee09 100644 (file)
@@ -78,7 +78,7 @@ shared_disk_template ()
     for SHARED_DISK_NUM in $(seq 1 $SHAREDDISK_COUNT) ; do
        local DISK="${VIRTBASE}/${CLUSTER}/shared${SHARED_DISK_NUM}"
        run_hooks hack_disk_hooks "shared"
-       local serial=$(sed -n "${SHARED_DISK_NUM}p" "$shared_disk_ids")
+       local serial=$(awk "{ print \$${SHARED_DISK_NUM} }" <<<"$SHARED_DISK_IDS")
        for p in $(seq 1 $paths) ; do
            local dev="${devices[$n]}"
            [ -n "$dev" ] || die "Too many shared disks!  The function shared_disk_template needs to be hacked to allow more shared disks..."
@@ -111,8 +111,7 @@ register_hook create_cluster_hooks shared_disk_setup
 
 shared_disk_setup ()
 {
-    shared_disk_ids="tmp/shared_disk_ids.${CLUSTER}"
-    rm -f "$shared_disk_ids"
+    SHARED_DISK_IDS=""
 
     # Early exit if no shared disks
     have_shared_disks || return 0
@@ -165,7 +164,8 @@ EOF
        # setup a nice ID at the start of the disk
        "$SHARED_DISK_ID_GEN" "$SHARED_DISK_NUM" > tmp/diskid
        dd if=tmp/diskid of="$di" conv=notrunc bs=1 > /dev/null 2>&1
-       head -n 1 tmp/diskid >>"$shared_disk_ids"
+       local this_id=$(head -n 1 tmp/diskid)
+       SHARED_DISK_IDS="${SHARED_DISK_IDS}${SHARED_DISK_IDS:+ }${this_id}"
     done
     echo
 
@@ -183,24 +183,12 @@ 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
-}
-
 shared_disk_setup_base ()
 {
     _SHARED_DISK_TEMPLATE=""
 
     node_has_shared_disks "$type" || return 0
 
-    install_shared_disk_ids
-
     if [ "$SHARED_DISK_TYPE" = "iscsi" ] ; then
        shared_disk_iscsi_setup_base
     else