cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/fence/scripts scsi_reserve
@ 2006-07-12 22:08 rohara
  0 siblings, 0 replies; 4+ messages in thread
From: rohara @ 2006-07-12 22:08 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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

Removed files:
	fence/scripts  : scsi_reserve 

Log message:
	Move scsi_reserve init script to fencing agent directory.

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



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

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rohara at sourceware.org	2006-07-12 16:55:28

Modified files:
	fence/scripts  : scsi_reserve 

Log message:
	Added success and failure commands in start/stop.
	
	scsi_reserve start - success if we can register with a device.
	scsi_reserve stop  - success if wa can unregister with a device.
	
	Note that we always try to create a reservation for a device in start,
	but we do not care about success/failure. If it fails, it is probably
	because a reservation already exists.

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

--- cluster/fence/scripts/scsi_reserve	2006/07/06 16:07:23	1.2
+++ cluster/fence/scripts/scsi_reserve	2006/07/12 16:55:28	1.3
@@ -50,17 +50,29 @@
 #
 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
+    # sg_persist -d $dev -o -R -K $key -T 5 &>/dev/null || break
     error=0
   done
-  if [ $error -ne 0 ]; then
+
+  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
 ;;
 
@@ -75,7 +87,7 @@
 
   if sg_persist -d $dev -i -r 2>/dev/null | grep -qiE "${key#0}" ; then
       echo "Unable to unregister device: $dev"
-      error=0
+      error=1
   else
       echo -n "Unregistering device: $dev"
       for error in 1
@@ -84,9 +96,14 @@
 	error=0
       done
   fi
-  if [ $error -ne 0 ]; then
+
+  if [ $error -eq 0 ]; then
+      success
+  else
+      failure
       rval=1
   fi
+
   echo
 done
 



^ permalink raw reply	[flat|nested] 4+ messages in thread
* [Cluster-devel] cluster/fence/scripts scsi_reserve
@ 2006-07-06 16:07 rohara
  0 siblings, 0 replies; 4+ messages in thread
From: rohara @ 2006-07-06 16:07 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rohara at sourceware.org	2006-07-06 16:07:23

Modified files:
	fence/scripts  : scsi_reserve 

Log message:
	Added parameters for chkconfig.
	
	Script will be started for levels 3, 4, and 5.
	Start priority is 25.
	Stop priority is 75.

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

--- cluster/fence/scripts/scsi_reserve	2006/06/29 17:24:33	1.1
+++ cluster/fence/scripts/scsi_reserve	2006/07/06 16:07:23	1.2
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# chkconfig:
+# chkconfig: 345 25 75
 # description: start/stop persistent reservation service for lvm
 
 . /etc/init.d/functions



^ permalink raw reply	[flat|nested] 4+ messages in thread
* [Cluster-devel] cluster/fence/scripts scsi_reserve
@ 2006-06-29 17:24 rohara
  0 siblings, 0 replies; 4+ messages in thread
From: rohara @ 2006-06-29 17:24 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rohara at sourceware.org	2006-06-29 17:24:34

Added files:
	fence/scripts  : scsi_reserve 

Log message:
	Initial check-in of SCSI persistent reservation init script.

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

/cvs/cluster/cluster/fence/scripts/scsi_reserve,v  -->  standard output
revision 1.1
--- cluster/fence/scripts/scsi_reserve
+++ -	2006-06-29 17:24:35.150795000 +0000
@@ -0,0 +1,122 @@
+#!/bin/bash
+#
+# chkconfig:
+# 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 -ne 0 ]; then
+      rval=1
+  fi
+  echo
+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=0
+  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 -ne 0 ]; then
+      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] 4+ messages in thread

end of thread, other threads:[~2006-07-12 22:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-12 22:08 [Cluster-devel] cluster/fence/scripts scsi_reserve rohara
  -- strict thread matches above, loose matches on Subject: below --
2006-07-12 16:55 rohara
2006-07-06 16:07 rohara
2006-06-29 17:24 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).