mknsd.sh - update to use shared_disk_ids file and to work with modern GPFS.
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Oct 2011 05:49:44 +0000 (16:49 +1100)
committerMartin Schwenke <martin@meltin.net>
Thu, 20 Oct 2011 05:49:44 +0000 (16:49 +1100)
Old code is left for potential backward compatibility.

Signed-off-by: Martin Schwenke <martin@meltin.net>
base/all/root/scripts/mknsd.sh

index 6ce5ef8d458c7fb7d8ec0ba41434600fc9b8981e..a44632119c45f71d88e66ca46b76ec3e9a3553b2 100755 (executable)
@@ -8,13 +8,23 @@ set -e
 echo
 echo "Setting up NSDs"
 nsdfile=/tmp/nsd.$$
-disks=$(multipath -dl | \
-    sed -n -e 's/.*[[:space:]]\([^[:space:]][^[:space:]]*\)[[:space:]]\(QEMU\|AUTCLSTR\),.*/\1/p'
-)
-(
-for d in $disks; do
-    echo $d:${nsd_servers}:::::
-done
-) > $nsdfile
+idfile=$(dirname $0)/shared_disk_ids
+if [ -r "$idfile" ] ; then
+    pat=$(tr '\n' '|' <"$idfile"  | sed -e 's@|$@@')
+    multipath -dl |
+    sed -r -n -e "s@^[^[:space:]]+[[:space:]]+\(($pat)\)[[:space:]](dm-[^[:space:]]+).*@\1 \2@p" |
+    while read name disk ; do
+       name=$(echo "$name" | tr -d -c '[:alnum:]')
+       echo "${disk}:${nsd_servers}::dataAndMetadata:1:${name}:"
+    done >$nsdfile
+else
+    disks=$(multipath -dl | \
+    sed -n -e 's/.*[[:space:]]\([^[:space:]][^[:space:]]*\)[[:space:]]\(QEMU\|AUTCLSTR\),.*/\1/p')
+    (  
+       for d in $disks; do
+           echo $d:${nsd_servers}:::::
+       done
+    ) > $nsdfile
+fi
 mmcrnsd -F $nsdfile
 mmlsnsd -m