All of lore.kernel.org
 help / color / mirror / Atom feed
From: rohara@sourceware.org <rohara@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/fence/agents/scsi scsi_reserve
Date: 12 Jul 2006 22:09:37 -0000	[thread overview]
Message-ID: <20060712220937.4201.qmail@sourceware.org> (raw)

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



             reply	other threads:[~2006-07-12 22:09 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060712220937.4201.qmail@sourceware.org \
    --to=rohara@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.