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 12-06-2010, 11:30 PM
"Ryan O'Hara"
 
Default fence_scsi_test: add 'clear' action

Added new 'clear' action that will remove all registrations and
reservations on device(s). This action requires that the node be
registered with the devices to be cleared. See sg_persit(3) for
more information, specifically the -C option.

Resolves: rhbz#603838

Signed-off-by: Ryan O'Hara <rohara@redhat.com>
---
fence/agents/scsi/fence_scsi_test.pl | 87 ++++++++++++++++++++++++---------
1 files changed, 63 insertions(+), 24 deletions(-)

diff --git a/fence/agents/scsi/fence_scsi_test.pl b/fence/agents/scsi/fence_scsi_test.pl
index 25db6ba..5c2302c 100755
--- a/fence/agents/scsi/fence_scsi_test.pl
+++ b/fence/agents/scsi/fence_scsi_test.pl
@@ -68,6 +68,26 @@ sub do_action_off ($$$)
return ($err);
}

+sub do_action_clear ($$)
+{
+ my ($dev, $rk) = @_;
+
+ return (0) unless get_keys_register ($dev);
+
+ my $cmd = "sg_persist -n -o -C -K $rk -d $dev";
+ my @out = qx { $cmd 2> /dev/null };
+ my $err = ($?>>8);
+
+ if (defined $options{'v'}) {
+ $self = (caller(0))[3];
+ print " $self (dev=$dev rk=$rk)
";
+ print " cmd=$cmd
";
+ print " err=$err
";
+ }
+
+ return ($err);
+}
+
sub do_verify_on (@$$)
{
my @devices = @{(shift)};
@@ -119,6 +139,25 @@ sub do_verify_off ($$$)
return ($err);
}

+sub do_verify_clear ($$)
+{
+ my ($dev, $host_key) = @_;
+ my $err = 0;
+
+ if (defined $options{'v'}) {
+ $self = (caller(0))[3];
+ print " $self (dev=$dev host_key=$host_key)
";
+ }
+
+ @keys = get_keys_register ($dev);
+
+ if (scalar (@keys) != 0) {
+ $err++;
+ }
+
+ return ($err);
+}
+
sub do_key_write ($)
{
my $key = shift;
@@ -259,24 +298,6 @@ sub do_preempt_abort ($$$)
return ($err);
}

-sub do_clear ($$)
-{
- my ($dev, $rk) = @_;
-
- my $cmd = "sg_persist -n -o -C -K $rk -d $dev";
- my @out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- if (defined $options{'v'}) {
- $self = (caller(0))[3];
- print " $self (dev=$dev rk=$rk)
";
- print " cmd=$cmd
";
- print " err=$err
";
- }
-
- return ($err);
-}
-
sub do_reset ($)
{
my ($dev) = @_;
@@ -575,15 +596,17 @@ sub print_results ($)
sub print_usage
{
print "
";
- print "Usage: fence_scsi_test -o <on|off> -k <key> [options]
";
+ print "Usage: fence_scsi_test -o <action> [options]
";
print "
";
print "Actions:
";
print "
";
print " on Register <key> with the devices.
";
- print " off Remove <key> form the devices.
";
+ print " off Remove <key> from the devices.
";
+ print " clear Remove all registrations from the devices.
";
print "
";
print "Options:
";
print "
";
+ print " -k, --key=VALUE Key to use with current action.
";
print " -d, --devices=LIST Devices used for the current action.
";
print " -h, --help Display this help and exit.
";
print " -v, --verbose Verbose mode.
";
@@ -622,10 +645,12 @@ if (defined $options{'t'}) {
}
}

-if ($options{'k'} =~ /^[[:xdigit:]]+$/) {
- $node_key = lc ($options{'k'});
-} else {
- print_usage ();
+if ($options{'o'} !~ /^clear$/i) {
+ if ($options{'k'} =~ /^[[:xdigit:]]+$/) {
+ $node_key = lc ($options{'k'});
+ } else {
+ print_usage ();
+ }
}

for ($options{'o'}) {
@@ -637,6 +662,10 @@ for ($options{'o'}) {
do_key_read ($host_key);
last;
};
+ ($_ =~ /^clear/i) && do {
+ do_key_read ($host_key);
+ last;
+ };
print_usage ();
}

@@ -690,5 +719,15 @@ for ($options{'o'}) {
print "
" if (!defined $options{'v'});
last;
};
+ ($_ =~ /^clear$/i) && do {
+ print "
" if (!defined $options{'v'});
+ foreach (@devices) {
+ $results{$_}[0] = do_action_clear ($devices_name{$_}, $host_key);
+ $results{$_}[1] = do_verify_clear ($devices_name{$_}, $host_key);
+ print_results ($_);
+ }
+ print "
" if (!defined $options{'v'});
+ last;
+ };
print_usage ();
}
--
1.7.2.3
 

Thread Tools




All times are GMT. The time now is 07:04 PM.

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