cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Ryan O'Hara <rohara@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/2] fence_scsi: write devices to tmp file on unfence
Date: Tue,  1 Mar 2011 09:55:21 -0600	[thread overview]
Message-ID: <1298994921-32503-1-git-send-email-rohara@redhat.com> (raw)

When unfencing occurs (action=on), write list of devices that were
successfully registered to /var/run/cluster/fence_scsi.dev file. This
file will be used by the optional watchdog script. Note that the devices
are not added to the tmp file until the verification step.

Signed-off-by: Ryan O'Hara <rohara@redhat.com>
---
 fence/agents/scsi/fence_scsi.pl |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index e162dfe..56653fc 100644
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -40,6 +40,7 @@ sub do_action_on ($@)
     my $self = (caller(0))[3];
     my ($node_key, @devices) = @_;
 
+    dev_unlink ();
     key_write ($node_key);
 
     foreach $dev (@devices) {
@@ -126,6 +127,9 @@ sub do_verify_on ($@)
             next;
         }
 
+	## write dev to device file once registration is verified
+	dev_write ($dev);
+
         ## check that a reservation exists
         if (!get_reservation_key ($dev)) {
             log_debug ("no reservation exists on device $dev");
@@ -337,12 +341,38 @@ sub do_reset (S)
     return;
 }
 
+sub dev_unlink ()
+{
+    my $self = (caller(0))[3];
+    my $file = "/var/run/cluster/fence_scsi.dev";
+
+    if (-e $file) {
+	unlink ($file) or die "$!\n";
+    }
+
+    return;
+}
+
+sub dev_write ($)
+{
+    my $self = (caller(0))[3];
+    my $file = "/var/run/cluster/fence_scsi.dev";
+    my $dev = shift;
+
+    open (\*FILE, ">>$file") or die "$!\n";
+    print FILE "$dev\n";
+    close (FILE);
+
+    return;
+}
+
 sub key_read ()
 {
     my $self = (caller(0))[3];
+    my $file = "/var/run/cluster/fence_scsi.key";
     my $key;
 
-    open (\*FILE, "</var/run/cluster/fence_scsi.key") or die "$!\n";
+    open (\*FILE, "<$file") or die "$!\n";
     chomp ($key = <FILE>);
     close (FILE);
 
@@ -352,9 +382,11 @@ sub key_read ()
 sub key_write ($)
 {
     my $self = (caller(0))[3];
+    my $file = "/var/run/cluster/fence_scsi.key";
+    my $key = shift;
 
-    open (\*FILE, ">/var/run/cluster/fence_scsi.key") or die "$!\n";
-    print FILE "$_[0]\n";
+    open (\*FILE, ">$file") or die "$!\n";
+    print FILE "$key\n";
     close (FILE);
 
     return;
-- 
1.7.3.4



                 reply	other threads:[~2011-03-01 15:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1298994921-32503-1-git-send-email-rohara@redhat.com \
    --to=rohara@redhat.com \
    /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 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).