[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/fence/agents/scsi scsi_reserve



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL50
Changes by:	rohara sourceware org	2006-12-01 20:31:30

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Fix various bugs, including: variable in if statement needs to be quoted,
	return correct exit status, report unregister (stop) failures correctly.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/scsi/scsi_reserve.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.1&r2=1.1.4.1

--- cluster/fence/agents/scsi/scsi_reserve	2006/07/12 22:09:37	1.1
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/01 20:31:30	1.1.4.1
@@ -31,13 +31,15 @@
 
 # get the node name and node addr from cman
 #
-node_name=$( cman_tool status | grep "Node name" | awk -F": " '{print $2}' )
-node_addr=$( cman_tool status | grep "Node addr" | awk -F": " '{print $2}' )
+node_name=$( cman_tool status | grep "Node name" | awk -F": " '{ print $2 }' )
+node_addr=$( cman_tool status | grep "Node addr" | awk -F": " '{ print $2 }' )
 
 # create unique key for this host
 #
 key=$( gethostip -x $node_name )
 
+###############################################################################
+
 case $1 in
 
 start)
@@ -50,13 +52,11 @@
 #
 for dev in $scsi_devices
 do
-
   echo -n "Registering device: $dev"
 
   for error in 1
   do
     sg_persist -d $dev -o -G -S $key &>/dev/null || break
-    # sg_persist -d $dev -o -R -K $key -T 5 &>/dev/null || break
     error=0
   done
 
@@ -84,12 +84,13 @@
 #
 for dev in $scsi_devices
 do
+  echo -n "Unregistering device: $dev"
 
+  # check if this node/key is the node/key holding the reservation
+  #
   if sg_persist -d $dev -i -r 2>/dev/null | grep -qiE "${key#0}" ; then
-      echo "Unable to unregister device: $dev"
       error=1
   else
-      echo -n "Unregistering device: $dev"
       for error in 1
 	do
 	sg_persist -d $dev -o -G -K $key -S 0 &>/dev/null || break
@@ -108,6 +109,7 @@
 done
 
 rm -f /var/lock/subsys/${0##*/}
+
 ;;
 
 status)
@@ -123,7 +125,7 @@
   fi
 done
 
-if [ -z $devices ]; then
+if [ -z "$devices" ]; then
     echo "No devices registered."
 else
     echo "Found ${#devices[ ]} registered device(s):"
@@ -136,4 +138,5 @@
 
 esac
 
-exit $status
+exit $rval
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]