FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 03-01-2011, 02:55 PM
"Ryan O'Hara"
 
Default fence_scsi: write devices to tmp file on unfence

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 "$!
";
+ }
+
+ 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 "$!
";
+ print FILE "$dev
";
+ 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 "$!
";
+ open (*FILE, "<$file") or die "$!
";
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 "$!
";
- print FILE "$_[0]
";
+ open (*FILE, ">$file") or die "$!
";
+ print FILE "$key
";
close (FILE);

return;
--
1.7.3.4
 

Thread Tools




All times are GMT. The time now is 06:49 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org