cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-11-27 22:40 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-11-27 22:40 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rohara at sourceware.org	2006-11-27 22:40:07

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Fix comment.
	Fix exit status be rval.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/07/12 22:09:37	1.1
+++ cluster/fence/agents/scsi/scsi_reserve	2006/11/27 22:40:07	1.2
@@ -25,9 +25,9 @@
                 | awk --posix ' $1 ~ /[-a-z]{5}c/ { print $2 } ' \
                 | sed -e 's/([0-9]*)//' | sort | uniq )
 
-# if not scsi devices were found we can exit now
+# if no scsi devices were found we can exit now
 #
-[ -z "$scsi_devices" ] && exit 0
+[ -z $scsi_devices ] && exit 0
 
 # get the node name and node addr from cman
 #
@@ -136,4 +136,5 @@
 
 esac
 
-exit $status
+exit $rval
+



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2008-01-24 22:20 cfeist
  0 siblings, 0 replies; 20+ messages in thread
From: cfeist @ 2008-01-24 22:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	cfeist at sourceware.org	2008-01-24 22:20:24

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Added back in change to description line to make chkconfig work properly.

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

--- cluster/fence/agents/scsi/scsi_reserve	2008/01/18 23:02:58	1.1.2.9
+++ cluster/fence/agents/scsi/scsi_reserve	2008/01/24 22:20:23	1.1.2.10
@@ -3,7 +3,7 @@
 # scsi_reserve:
 #
 # chkconfig: 345 25 75
-# description:
+# description: start/stop persistent reservation service for lvm
 # config: /etc/sysconfig/scsi_reserve
 
 . /etc/init.d/functions



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2007-01-26 17:56 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2007-01-26 17:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2007-01-26 17:56:14

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Record SCSI persistent reservation key in /var/lock/subsys/scsi_reserve.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/14 18:31:36	1.1.6.8
+++ cluster/fence/agents/scsi/scsi_reserve	2007/01/26 17:56:14	1.1.6.9
@@ -46,7 +46,7 @@
 
 rval=0
 
-touch /var/lock/subsys/scsi_reserve
+echo "$key" > /var/lock/subsys/scsi_reserve
 
 cat /dev/null > /var/run/scsi_reserve
 



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-14 18:32 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-14 18:32 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-12-14 18:32:43

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Allow 'stop' to release the reservation if and only if there are no other
	keys registered with a given device. Prior to this fix, if was not possible
	for 'scsi_reserve stop' to unregister/release on the node that was holding
	the reservation.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/12 23:20:47	1.1.2.6
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/14 18:32:43	1.1.2.7
@@ -8,22 +8,22 @@
 # check for sg_persist command provided by sg3_utils package
 #
 if ! sg_persist -V &> /dev/null ; then
-    echo "error: sg_persist not found"
-    exit 2
+   echo "error: sg_persist not found"
+   exit 2
 fi
 
 # check for gethostip command provided by syslinux package
 #
 if ! gethostip -h &> /dev/null ; then
-    echo "error: gethostip not found"
-    exit 3
+   echo "error: gethostip not found"
+   exit 3
 fi
 
 # get scsi devices that are part of clustered volumes
 #
 scsi_devices=$( lvs -o vg_attr,devices --noheadings \
-                | awk --posix ' $1 ~ /[-a-z]{5}c/ { print $2 } ' \
-                | sed -e 's/([0-9]*)//' | sort | uniq )
+		| awk --posix ' $1 ~ /[-a-z]{5}c/ { print $2 } ' \
+		| sed -e 's/([0-9]*)//' | sort | uniq )
 
 # if no scsi devices were found we can exit now
 #
@@ -97,13 +97,25 @@
 do
   echo -n "Unregistering device: $dev"
 
+  # get list of keys registered for this device
+  #
+  reg_keys=$( sg_persist -d $dev -i -k | grep '^[[:space:]]*0x' )
+
   # 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
-      error=1
+      if echo "$reg_keys" | grep -qivE "${key#0}" ; then
+	  error=1
+      else
+	  for error in 1
+	  do
+	    sg_persist -d $dev -o -G -K $key -S 0 &>/dev/null || break
+	    error=0
+	  done
+      fi
   else
       for error in 1
-	do
+      do
 	sg_persist -d $dev -o -G -K $key -S 0 &>/dev/null || break
 	error=0
       done
@@ -137,7 +149,7 @@
 done
 
 if [ -z "$devices" ]; then
-    echo "No devices registered."
+    echo "No devices resgistered."
 else
     echo "Found ${#devices[@]} registered device(s):"
 



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-14 18:31 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-14 18:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-12-14 18:31:36

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Allow 'stop' to release the reservation if and only if there are no other
	keys registered with a given device. Prior to this fix, if was not possible
	for 'scsi_reserve stop' to unregister/release on the node that was holding
	the reservation.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/12 23:20:28	1.1.6.7
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/14 18:31:36	1.1.6.8
@@ -97,10 +97,22 @@
 do
   echo -n "Unregistering device: $dev"
 
+  # get list of keys registered for this device
+  #
+  reg_keys=$( sg_persist -d $dev -i -k | grep '^[[:space:]]*0x' )
+
   # 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
-      error=1
+      if echo "$reg_keys" | grep -qivE "${key#0}" ; then
+	  error=1
+      else
+	  for error in 1
+	  do
+	    sg_persist -d $dev -o -G -K $key -S 0 &>/dev/null || break
+	    error=0
+	  done
+      fi
   else
       for error in 1
       do



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-12 23:20 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-12 23:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-12-12 23:20:47

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Record devices that are successfully registered to /var/run/scsi_reserve.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/12 21:32:53	1.1.2.5
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/12 23:20:47	1.1.2.6
@@ -48,6 +48,8 @@
 
 touch /var/lock/subsys/scsi_reserve
 
+cat /dev/null > /var/run/scsi_reserve
+
 # register each device using our key
 #
 for dev in $scsi_devices
@@ -62,11 +64,13 @@
   done
 
   if [ $error -eq 0 ]; then
+      echo $dev >> /var/run/scsi_reserve
       success
   else
       # perhaps we are already resgistered
       #
       if sg_persist -d $dev -i -k 2>/dev/null | grep -qiE "${key#0}" ; then
+	  echo $dev >> /var/run/scsi_reserve
           success
       else
           failure



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-12 23:20 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-12 23:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-12-12 23:20:29

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Record devices that are successfully registered to /var/run/scsi_reserve.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/12 21:32:51	1.1.6.6
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/12 23:20:28	1.1.6.7
@@ -48,6 +48,8 @@
 
 touch /var/lock/subsys/scsi_reserve
 
+cat /dev/null > /var/run/scsi_reserve
+
 # register each device using our key
 #
 for dev in $scsi_devices
@@ -62,11 +64,13 @@
   done
 
   if [ $error -eq 0 ]; then
+      echo $dev >> /var/run/scsi_reserve
       success
   else
       # perhaps we are already resgistered
       #
       if sg_persist -d $dev -i -k 2>/dev/null | grep -qiE "${key#0}" ; then
+	  echo $dev >> /var/run/scsi_reserve
           success
       else
           failure



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-12 21:32 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-12 21:32 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-12-12 21:32:55

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Fix success/failure reporting when registering devices at startup.
	If our node (key) is already registered with a given device, do not
	report failure since this is misleading.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/08 22:22:34	1.1.2.4
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/12 21:32:53	1.1.2.5
@@ -38,6 +38,8 @@
 #
 key=$( gethostip -x $node_name )
 
+###############################################################################
+
 case $1 in
 
 start)
@@ -62,8 +64,14 @@
   if [ $error -eq 0 ]; then
       success
   else
-      failure
-      rval=1
+      # perhaps we are already resgistered
+      #
+      if sg_persist -d $dev -i -k 2>/dev/null | grep -qiE "${key#0}" ; then
+          success
+      else
+          failure
+          rval=1
+      fi
   fi
 
   echo
@@ -108,6 +116,7 @@
 done
 
 rm -f /var/lock/subsys/scsi_reserve
+
 ;;
 
 status)



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-12 21:32 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-12 21:32 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-12-12 21:32:53

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Fix success/failure reporting when registering devices at startup.
	If our node (key) is already registered with a given device, do not
	report failure since this is misleading.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/08 22:26:12	1.1.6.5
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/12 21:32:51	1.1.6.6
@@ -52,6 +52,7 @@
 #
 for dev in $scsi_devices
 do
+
   echo -n "Registering device: $dev"
 
   for error in 1
@@ -63,15 +64,22 @@
   if [ $error -eq 0 ]; then
       success
   else
-      failure
-      rval=1
+      # perhaps we are already resgistered
+      #
+      if sg_persist -d $dev -i -k 2>/dev/null | grep -qiE "${key#0}" ; then
+          success
+      else
+          failure
+          rval=1
+      fi
   fi
 
+  echo
+
   # create a reservation
   #
   sg_persist -d $dev -o -R -K $key -T 5 &>/dev/null
 
-  echo
 done
 ;;
 
@@ -133,7 +141,6 @@
 	echo $i
     done
 fi
-
 ;;
 
 esac



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-08 22:26 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-08 22:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-12-08 22:26:12

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Replace /var/lock/subsys/${0##*/} with /var/lock/subsys/scsi_reserve.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/12/08 17:37:22	1.1.6.4
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/08 22:26:12	1.1.6.5
@@ -46,7 +46,7 @@
 
 rval=0
 
-touch /var/lock/subsys/${0##*/}
+touch /var/lock/subsys/scsi_reserve
 
 # register each device using our key
 #
@@ -107,7 +107,7 @@
   echo
 done
 
-rm -f /var/lock/subsys/${0##*/}
+rm -f /var/lock/subsys/scsi_reserve
 
 ;;
 



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-08 22:22 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-08 22:22 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-12-08 22:22:34

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Replace /var/lock/subsys/${0##*/} with /var/lock/subsys/scsi_reserve.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/11/29 20:54:42	1.1.2.3
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/08 22:22:34	1.1.2.4
@@ -44,7 +44,7 @@
 
 rval=0
 
-touch /var/lock/subsys/${0##*/}
+touch /var/lock/subsys/scsi_reserve
 
 # register each device using our key
 #
@@ -107,7 +107,7 @@
   echo
 done
 
-rm -f /var/lock/subsys/${0##*/}
+rm -f /var/lock/subsys/scsi_reserve
 ;;
 
 status)



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-08 17:37 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-08 17:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-12-08 17:37:22

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Add echo statement to force a newline after success/failure.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/11/29 16:47:34	1.1.6.3
+++ cluster/fence/agents/scsi/scsi_reserve	2006/12/08 17:37:22	1.1.6.4
@@ -71,6 +71,7 @@
   #
   sg_persist -d $dev -o -R -K $key -T 5 &>/dev/null
 
+  echo
 done
 ;;
 



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-12-01 20:31 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-12-01 20:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL50
Changes by:	rohara at 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
+



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-11-29 20:54 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-11-29 20:54 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-11-29 20:54:42

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Fix unregister code to report failure correctly.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/11/29 20:50:22	1.1.2.2
+++ cluster/fence/agents/scsi/scsi_reserve	2006/11/29 20:54:42	1.1.2.3
@@ -83,12 +83,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



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-11-29 20:50 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-11-29 20:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-11-29 20:50:22

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Variable should be quoted in conditional statement.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/11/27 22:41:42	1.1.2.1
+++ cluster/fence/agents/scsi/scsi_reserve	2006/11/29 20:50:22	1.1.2.2
@@ -27,12 +27,12 @@
 
 # if no scsi devices were found we can exit now
 #
-[ -z $scsi_devices ] && exit 0
+[ -z "$scsi_devices" ] && exit 0
 
 # 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
 #
@@ -56,7 +56,6 @@
   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
 
@@ -69,7 +68,7 @@
 
   echo
 
-  # attempt to create a reservation
+  # create a reservation
   #
   sg_persist -d $dev -o -R -K $key -T 5 &>/dev/null
 
@@ -123,7 +122,7 @@
   fi
 done
 
-if [ -z $devices ]; then
+if [ -z "$devices" ]; then
     echo "No devices registered."
 else
     echo "Found ${#devices[@]} registered device(s):"



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-11-29 16:47 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-11-29 16:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-11-29 16:47:34

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Variable must be quoted in conditional statement.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/11/27 23:41:05	1.1.6.2
+++ cluster/fence/agents/scsi/scsi_reserve	2006/11/29 16:47:34	1.1.6.3
@@ -27,7 +27,7 @@
 
 # if no scsi devices were found we can exit now
 #
-[ -z $scsi_devices ] && exit 0
+[ -z "$scsi_devices" ] && exit 0
 
 # get the node name and node addr from cman
 #
@@ -123,7 +123,7 @@
   fi
 done
 
-if [ -z $devices ]; then
+if [ -z "$devices" ]; then
     echo "No devices resgistered."
 else
     echo "Found ${#devices[@]} registered device(s):"



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-11-27 23:41 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-11-27 23:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-11-27 23:41:05

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Remove debug code.
	Change reporting of failure during 'stop' command.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/11/27 22:27:39	1.1.6.1
+++ cluster/fence/agents/scsi/scsi_reserve	2006/11/27 23:41:05	1.1.6.2
@@ -12,10 +12,6 @@
    exit 2
 fi
 
-# debug
-#
-echo "debug: found sg_persist"
-
 # check for gethostip command provided by syslinux package
 #
 if ! gethostip -h &> /dev/null ; then
@@ -23,46 +19,26 @@
    exit 3
 fi
 
-# debug
-#
-echo "debug: found gethostip"
-
 # get scsi devices that are part of clustered volumes
 #
 scsi_devices=$( lvs -o vg_attr,devices --noheadings \
 		| awk --posix ' $1 ~ /[-a-z]{5}c/ { print $2 } ' \
 		| sed -e 's/([0-9]*)//' | sort | uniq )
 
-# debug
-#
-for dev in $scsi_devices
-do
-  echo "debug: scsi_device = $dev"
-done
-
 # if no scsi devices were found we can exit now
 #
-[ -z "$scsi_devices" ] && exit 0
+[ -z $scsi_devices ] && exit 0
 
 # 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 }' )
 
-# debug
-#
-echo "debug: node_name = $node_name"
-echo "debug: node_addr = $node_addr"
-
 # create unique key for this host
 #
 key=$( gethostip -x $node_name )
 
-# debug
-#
-echo "debug: key = $key"
-
-################################################################################
+###############################################################################
 
 case $1 in
 
@@ -106,11 +82,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
@@ -159,5 +137,5 @@
 
 esac
 
-exit $status
+exit $rval
 



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-11-27 22:41 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-11-27 22:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-11-27 22:41:42

Modified files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Fix comment.
	Fix exit status to be rval.

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

--- cluster/fence/agents/scsi/scsi_reserve	2006/07/12 22:09:37	1.1
+++ cluster/fence/agents/scsi/scsi_reserve	2006/11/27 22:41:42	1.1.2.1
@@ -25,9 +25,9 @@
                 | awk --posix ' $1 ~ /[-a-z]{5}c/ { print $2 } ' \
                 | sed -e 's/([0-9]*)//' | sort | uniq )
 
-# if not scsi devices were found we can exit now
+# if no scsi devices were found we can exit now
 #
-[ -z "$scsi_devices" ] && exit 0
+[ -z $scsi_devices ] && exit 0
 
 # get the node name and node addr from cman
 #
@@ -136,4 +136,5 @@
 
 esac
 
-exit $status
+exit $rval
+



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-11-27 22:27 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-11-27 22:27 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-11-27 22:27:39

Added files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Initial checkin for scsi_reserve init script (RHEL4).

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

/cvs/cluster/cluster/fence/agents/scsi/scsi_reserve,v  -->  standard output
revision 1.1.6.1
--- cluster/fence/agents/scsi/scsi_reserve
+++ -	2006-11-27 22:27:40.515592000 +0000
@@ -0,0 +1,163 @@
+#!/bin/bash
+#
+# chkconfig: 345 25 75
+# description: start/stop persistent reservation service for lvm
+
+. /etc/init.d/functions
+
+# check for sg_persist command provided by sg3_utils package
+#
+if ! sg_persist -V &> /dev/null ; then
+   echo "error: sg_persist not found"
+   exit 2
+fi
+
+# debug
+#
+echo "debug: found sg_persist"
+
+# check for gethostip command provided by syslinux package
+#
+if ! gethostip -h &> /dev/null ; then
+   echo "error: gethostip not found"
+   exit 3
+fi
+
+# debug
+#
+echo "debug: found gethostip"
+
+# get scsi devices that are part of clustered volumes
+#
+scsi_devices=$( lvs -o vg_attr,devices --noheadings \
+		| awk --posix ' $1 ~ /[-a-z]{5}c/ { print $2 } ' \
+		| sed -e 's/([0-9]*)//' | sort | uniq )
+
+# debug
+#
+for dev in $scsi_devices
+do
+  echo "debug: scsi_device = $dev"
+done
+
+# if no scsi devices were found we can exit now
+#
+[ -z "$scsi_devices" ] && exit 0
+
+# 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 }' )
+
+# debug
+#
+echo "debug: node_name = $node_name"
+echo "debug: node_addr = $node_addr"
+
+# create unique key for this host
+#
+key=$( gethostip -x $node_name )
+
+# debug
+#
+echo "debug: key = $key"
+
+################################################################################
+
+case $1 in
+
+start)
+
+rval=0
+
+touch /var/lock/subsys/${0##*/}
+
+# register each device using our key
+#
+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
+    error=0
+  done
+
+  if [ $error -eq 0 ]; then
+      success
+  else
+      failure
+      rval=1
+  fi
+
+  # create a reservation
+  #
+  sg_persist -d $dev -o -R -K $key -T 5 &>/dev/null
+
+done
+;;
+
+stop)
+
+rval=0
+
+# unregister each device for this node
+#
+for dev in $scsi_devices
+do
+  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
+	error=0
+      done
+  fi
+
+  if [ $error -eq 0 ]; then
+      success
+  else
+      failure
+      rval=1
+  fi
+
+  echo
+done
+
+rm -f /var/lock/subsys/${0##*/}
+
+;;
+
+status)
+
+rval=0
+
+# find devices that are registered with our key
+#
+for dev in $scsi_devices
+do
+  if sg_persist -d $dev -i -k 2>/dev/null | grep -qiE "${key#0}" ; then
+      devices[${#devices[@]}]=$dev
+  fi
+done
+
+if [ -z $devices ]; then
+    echo "No devices resgistered."
+else
+    echo "Found ${#devices[@]} registered device(s):"
+
+    for i in "${devices[@]}" ; do
+	echo $i
+    done
+fi
+
+;;
+
+esac
+
+exit $status
+



^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
@ 2006-07-12 22:09 rohara
  0 siblings, 0 replies; 20+ messages in thread
From: rohara @ 2006-07-12 22:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rohara at sourceware.org	2006-07-12 22:09:37

Added files:
	fence/agents/scsi: scsi_reserve 

Log message:
	Moved from fence/scripts directory.

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

/cvs/cluster/cluster/fence/agents/scsi/scsi_reserve,v  -->  standard output
revision 1.1
--- cluster/fence/agents/scsi/scsi_reserve
+++ -	2006-07-12 22:09:37.438853000 +0000
@@ -0,0 +1,139 @@
+#!/bin/bash
+#
+# chkconfig: 345 25 75
+# description: start/stop persistent reservation service for lvm
+
+. /etc/init.d/functions
+
+# check for sg_persist command provided by sg3_utils package
+#
+if ! sg_persist -V &> /dev/null ; then
+    echo "error: sg_persist not found"
+    exit 2
+fi
+
+# check for gethostip command provided by syslinux package
+#
+if ! gethostip -h &> /dev/null ; then
+    echo "error: gethostip not found"
+    exit 3
+fi
+
+# get scsi devices that are part of clustered volumes
+#
+scsi_devices=$( lvs -o vg_attr,devices --noheadings \
+                | awk --posix ' $1 ~ /[-a-z]{5}c/ { print $2 } ' \
+                | sed -e 's/([0-9]*)//' | sort | uniq )
+
+# if not scsi devices were found we can exit now
+#
+[ -z "$scsi_devices" ] && exit 0
+
+# 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}' )
+
+# create unique key for this host
+#
+key=$( gethostip -x $node_name )
+
+case $1 in
+
+start)
+
+rval=0
+
+touch /var/lock/subsys/${0##*/}
+
+# register each device using our key
+#
+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
+
+  if [ $error -eq 0 ]; then
+      success
+  else
+      failure
+      rval=1
+  fi
+
+  echo
+
+  # attempt to create a reservation
+  #
+  sg_persist -d $dev -o -R -K $key -T 5 &>/dev/null
+
+done
+;;
+
+stop)
+
+rval=0
+
+# unregister each device for this node
+#
+for dev in $scsi_devices
+do
+
+  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
+	error=0
+      done
+  fi
+
+  if [ $error -eq 0 ]; then
+      success
+  else
+      failure
+      rval=1
+  fi
+
+  echo
+done
+
+rm -f /var/lock/subsys/${0##*/}
+;;
+
+status)
+
+rval=0
+
+# find devices that are registered with our key
+#
+for dev in $scsi_devices
+do
+  if sg_persist -d $dev -i -k 2>/dev/null | grep -qiE "${key#0}" ; then
+      devices[${#devices[@]}]=$dev
+  fi
+done
+
+if [ -z $devices ]; then
+    echo "No devices registered."
+else
+    echo "Found ${#devices[@]} registered device(s):"
+
+    for i in "${devices[@]}" ; do
+	echo $i
+    done
+fi
+;;
+
+esac
+
+exit $status



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2008-01-24 22:20 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-27 22:40 [Cluster-devel] cluster/fence/agents/scsi scsi_reserve rohara
  -- strict thread matches above, loose matches on Subject: below --
2008-01-24 22:20 cfeist
2007-01-26 17:56 rohara
2006-12-14 18:32 rohara
2006-12-14 18:31 rohara
2006-12-12 23:20 rohara
2006-12-12 23:20 rohara
2006-12-12 21:32 rohara
2006-12-12 21:32 rohara
2006-12-08 22:26 rohara
2006-12-08 22:22 rohara
2006-12-08 17:37 rohara
2006-12-01 20:31 rohara
2006-11-29 20:54 rohara
2006-11-29 20:50 rohara
2006-11-29 16:47 rohara
2006-11-27 23:41 rohara
2006-11-27 22:41 rohara
2006-11-27 22:27 rohara
2006-07-12 22:09 rohara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).