cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/fence/agents/scsi fence_scsi_test.pl
@ 2006-12-08 20:48 rohara
  0 siblings, 0 replies; 6+ messages in thread
From: rohara @ 2006-12-08 20:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-12-08 20:48:00

Modified files:
	fence/agents/scsi: fence_scsi_test.pl 

Log message:
	Fix code to use get_key subroutine.
	Fix sg_persist commands to specify device via -d parameter.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/scsi/fence_scsi_test.pl.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1&r2=1.1.2.1

--- cluster/fence/agents/scsi/fence_scsi_test.pl	2006/11/03 17:31:54	1.1
+++ cluster/fence/agents/scsi/fence_scsi_test.pl	2006/12/08 20:48:00	1.1.2.1
@@ -19,6 +19,7 @@
 
 sub get_key
 {
+    my $name = @_;
     my $addr = gethostbyname($name) or die "$!\n";
 
     return unpack("H*", $addr);
@@ -32,7 +33,7 @@
     print "DEBUG: $func ($dev, $key)\n" if ($opt_d);
 
     my ($in, $out, $err);
-    my $cmd = "sg_persist $dev -o -G -S $key";
+    my $cmd = "sg_persist -d $dev -o -G -S $key";
 
     my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
 
@@ -42,7 +43,7 @@
 
     $results{$dev}[0] = $rval;
 
-    print "DEBUG: [$rval] $cmd\n" if $opt_d;
+    print "DEBUG: [$rval] $cmd\n" if ($opt_d);
 
     close($in);
     close($out);
@@ -56,10 +57,10 @@
     my $func = (caller(0))[3];
     my ($dev, $key) = @_;
 
-    print "DEBUG: $func ($dev, $key)\n" if $opt_d;
+    print "DEBUG: $func ($dev, $key)\n" if ($opt_d);
 
     my ($in, $out, $err);
-    my $cmd = "sg_persist $dev -o -G -K $key -S 0";
+    my $cmd = "sg_persist -d $dev -o -G -K $key -S 0";
 
     my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
 
@@ -69,7 +70,7 @@
 
     $results{$dev}[1] = $rval;
 
-    print "DEBUG: [$rval] $cmd\n" if $opt_d;
+    print "DEBUG: [$rval] $cmd\n" if ($opt_d);
 
     close($in);
     close($out);
@@ -98,6 +99,7 @@
 {
     my ($in, $out, $err);
     my $cmd = "lvs --noheadings --separator : -o vg_attr,devices";
+
     my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
 
     waitpid($pid, 0);
@@ -108,7 +110,7 @@
     {
 	chomp;
 
-	my ($vg_attr, $dev) = split /:/, $_, 3;
+	my ($vg_attr, $dev) = split(/:/, $_);
 
 	if ($vg_attr =~ /.*c$/)
 	{
@@ -125,8 +127,7 @@
 sub test_devices
 {
     my $name = hostname() or die "$!\n";
-    my $addr = gethostbyname($name) or die "$!\n";
-    my $key = unpack("H*", $addr);
+    my $key = get_key($name);
 
     foreach $dev (@devices)
     {
@@ -195,7 +196,7 @@
     print "  -h     Help. Prints out this usage information.\n\n";
 }
 
-### main ###
+### MAIN #######################################################
 
 if (getopts("cdhsv") == 0)
 {
@@ -232,3 +233,5 @@
 
 print_results;
 
+exit 0;
+



^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi fence_scsi_test.pl
@ 2007-03-06 19:10 rohara
  0 siblings, 0 replies; 6+ messages in thread
From: rohara @ 2007-03-06 19:10 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2007-03-06 19:10:34

Modified files:
	fence/agents/scsi: fence_scsi_test.pl 

Log message:
	Fix help message to refer to script as 'fence_scsi_test'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/scsi/fence_scsi_test.pl.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.1&r2=1.1.2.2

--- cluster/fence/agents/scsi/fence_scsi_test.pl	2006/12/08 20:48:00	1.1.2.1
+++ cluster/fence/agents/scsi/fence_scsi_test.pl	2007/03/06 19:10:34	1.1.2.2
@@ -178,7 +178,7 @@
 
 sub print_usage
 {
-    print "\nUsage: scsi_test [-c|-s] [-d] [-h]\n\n";
+    print "\nUsage: fence_scsi_test [-c|-s] [-d] [-h]\n\n";
 
     print "Options:\n\n";
 



^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi fence_scsi_test.pl
@ 2007-03-06 19:09 rohara
  0 siblings, 0 replies; 6+ messages in thread
From: rohara @ 2007-03-06 19:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2007-03-06 19:09:11

Modified files:
	fence/agents/scsi: fence_scsi_test.pl 

Log message:
	Fix help message to refer to script as 'fence_scsi_test'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/scsi/fence_scsi_test.pl.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.6.2&r2=1.1.6.3

--- cluster/fence/agents/scsi/fence_scsi_test.pl	2006/12/08 20:46:17	1.1.6.2
+++ cluster/fence/agents/scsi/fence_scsi_test.pl	2007/03/06 19:09:11	1.1.6.3
@@ -178,7 +178,7 @@
 
 sub print_usage
 {
-    print "\nUsage: scsi_test [-c|-s] [-d] [-h]\n\n";
+    print "\nUsage: fence_scsi_test [-c|-s] [-d] [-h]\n\n";
 
     print "Options:\n\n";
 



^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi fence_scsi_test.pl
@ 2007-03-06 19:07 rohara
  0 siblings, 0 replies; 6+ messages in thread
From: rohara @ 2007-03-06 19:07 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rohara at sourceware.org	2007-03-06 19:07:25

Modified files:
	fence/agents/scsi: fence_scsi_test.pl 

Log message:
	Fix help message to refer to script as 'fence_scsi_test'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/scsi/fence_scsi_test.pl.diff?cvsroot=cluster&r1=1.1&r2=1.2

--- cluster/fence/agents/scsi/fence_scsi_test.pl	2006/11/03 17:31:54	1.1
+++ cluster/fence/agents/scsi/fence_scsi_test.pl	2007/03/06 19:07:24	1.2
@@ -177,7 +177,7 @@
 
 sub print_usage
 {
-    print "\nUsage: scsi_test [-c|-s] [-d] [-h]\n\n";
+    print "\nUsage: fence_scsi_test [-c|-s] [-d] [-h]\n\n";
 
     print "Options:\n\n";
 



^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi fence_scsi_test.pl
@ 2006-12-08 20:46 rohara
  0 siblings, 0 replies; 6+ messages in thread
From: rohara @ 2006-12-08 20:46 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-12-08 20:46:17

Modified files:
	fence/agents/scsi: fence_scsi_test.pl 

Log message:
	Fix incorrect variable name.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/scsi/fence_scsi_test.pl.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.6.1&r2=1.1.6.2

--- cluster/fence/agents/scsi/fence_scsi_test.pl	2006/12/08 19:59:01	1.1.6.1
+++ cluster/fence/agents/scsi/fence_scsi_test.pl	2006/12/08 20:46:17	1.1.6.2
@@ -54,7 +54,7 @@
 
 sub unregister_device
 {
-    my $fun = (caller(0))[3];
+    my $func = (caller(0))[3];
     my ($dev, $key) = @_;
 
     print "DEBUG: $func ($dev, $key)\n" if ($opt_d);



^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/fence/agents/scsi fence_scsi_test.pl
@ 2006-12-08 19:59 rohara
  0 siblings, 0 replies; 6+ messages in thread
From: rohara @ 2006-12-08 19:59 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rohara at sourceware.org	2006-12-08 19:59:01

Added files:
	fence/agents/scsi: fence_scsi_test.pl 

Log message:
	Script to help test/configure/report SCSI persistent reservation capabilities.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/scsi/fence_scsi_test.pl.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.1.6.1

/cvs/cluster/cluster/fence/agents/scsi/fence_scsi_test.pl,v  -->  standard output
revision 1.1.6.1
--- cluster/fence/agents/scsi/fence_scsi_test.pl
+++ -	2006-12-08 19:59:02.507751000 +0000
@@ -0,0 +1,237 @@
+#!/usr/bin/perl
+
+use IPC::Open3;
+use Sys::Hostname;
+use Getopt::Std;
+use POSIX;
+
+my @devices;
+my %results;
+
+# WARNING!! Do not add code bewteen "#BEGIN_VERSION_GENERATION" and
+# "#END_VERSION_GENERATION"  It is generated by the Makefile
+
+#BEGIN_VERSION_GENERATION
+$FENCE_RELEASE_NAME="";
+$REDHAT_COPYRIGHT="";
+$BUILD_DATE="";
+#END_VERSION_GENERATION
+
+sub get_key
+{
+    my $name = @_;
+    my $addr = gethostbyname($name) or die "$!\n";
+
+    return unpack("H*", $addr);
+}
+
+sub register_device
+{
+    my $func = (caller(0))[3];
+    my ($dev, $key) = @_;
+
+    print "DEBUG: $func ($dev, $key)\n" if ($opt_d);
+
+    my ($in, $out, $err);
+    my $cmd = "sg_persist -d $dev -o -G -S $key";
+
+    my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
+
+    waitpid($pid, 0);
+
+    my $rval = WEXITSTATUS($?);
+
+    $results{$dev}[0] = $rval;
+
+    print "DEBUG: [$rval] $cmd\n" if ($opt_d);
+
+    close($in);
+    close($out);
+    close($err);
+
+    return $rval;
+}
+
+sub unregister_device
+{
+    my $fun = (caller(0))[3];
+    my ($dev, $key) = @_;
+
+    print "DEBUG: $func ($dev, $key)\n" if ($opt_d);
+
+    my ($in, $out, $err);
+    my $cmd = "sg_persist -d $dev -o -G -K $key -S 0";
+
+    my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
+
+    waitpid($pid, 0);
+
+    my $rval = WEXITSTATUS($?);
+
+    $results{$dev}[1] = $rval;
+
+    print "DEBUG: [$rval] $cmd\n" if ($opt_d);
+
+    close($in);
+    close($out);
+    close($err);
+
+    return $rval;
+}
+
+sub get_block_devices
+{
+    my $block_dir = "/sys/block";
+
+    opendir(DIR, $block_dir) or die "Error: $! $block_dir\n";
+
+    my @block_devices = grep { /^sd*/ } readdir(DIR);
+
+    closedir(DIR);
+
+    for $dev (@block_devices)
+    {
+	push @devices, "/dev/" . $dev;
+    }
+}
+
+sub get_cluster_devices
+{
+    my ($in, $out, $err);
+    my $cmd = "lvs --noheadings --separator : -o vg_attr,devices";
+
+    my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
+
+    waitpid($pid, 0);
+
+    die "Error: unable to exec lvs command.\n" if WEXITSTATUS($?);
+
+    while (<$out>)
+    {
+	chomp;
+
+	my ($vg_attr, $dev) = split(/:/, $_);
+
+	if ($vg_attr =~ /.*c$/)
+	{
+	    $dev =~ s/\(.*\)//;
+	    push @devices, $dev;
+	}
+    }
+
+    close($in);
+    close($out);
+    close($err);
+}
+
+sub test_devices
+{
+    my $name = hostname() or die "$!\n";
+    my $key = get_key($name);
+
+    foreach $dev (@devices)
+    {
+	if (register_device($dev, $key) != 0)
+	{
+	}
+	if (unregister_device($dev, $key) != 0)
+	{
+	}
+    }
+}
+
+sub print_results
+{
+    my $device_count = scalar(@devices);
+
+    my $failure_count = 0;
+    my $success_count = 0;
+
+    print "\nAttempted to register with devices:\n";
+    print "-------------------------------------\n";
+
+    for $dev (@devices)
+    {
+	print "\t$dev\t";
+	if ($results{$dev}[0] == 0)
+	{
+	    $success_count++;
+	    print "Success\n";
+	}
+	else
+	{
+	    $failure_count++;
+	    print "Failure\n";
+	}
+    }
+
+    print "-------------------------------------\n";
+    print "Number of devices tested: $device_count\n";
+    print "Number of devices passed: $success_count\n";
+    print "Number of devices failed: $failure_count\n\n";
+
+    if ($failure_count != 0)
+    {
+	exit(1);
+    }
+}
+
+sub print_usage
+{
+    print "\nUsage: scsi_test [-c|-s] [-d] [-h]\n\n";
+
+    print "Options:\n\n";
+
+    print "  -c     Cluster mode. This mode is intended to test\n";
+    print "         SCSI persistent reservation capabilties for\n";
+    print "         devices that are part of existing clustered\n";
+    print "         volumes. Only devices in LVM cluster volumes\n";
+    print "         will be tested.\n\n";
+    print "  -s     SCSI mode. This mode is intended to test SCSI\n";
+    print "         persistent reservation capabilities for all SCSI\n";
+    print "         devices visible on a node.\n\n";
+    print "  -d     Debug flag. This will print debugging information\n";
+    print "         such as the actual commands being run to register\n";
+    print "         and unregister a device.\n\n";
+    print "  -h     Help. Prints out this usage information.\n\n";
+}
+
+### MAIN #######################################################
+
+if (getopts("cdhsv") == 0)
+{
+    print_usage;
+    exit(1);
+}
+
+if ($opt_h)
+{
+    print_usage;
+    exit(0);
+}
+
+if ($opt_c)
+{
+    print "\nTesting devices in cluster volumes...\n";
+    get_cluster_devices;
+}
+
+if ($opt_s)
+{
+    print "\nTesting all SCSI block devices...\n";
+    get_block_devices;
+}
+
+if (!$opt_c && !$opt_s)
+{
+    print "\nPlease specify either cluster or SCSI mode.\n";
+    print_usage;
+    exit(1);
+}
+
+test_devices;
+
+print_results;
+
+exit 0;
+



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-06 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-08 20:48 [Cluster-devel] cluster/fence/agents/scsi fence_scsi_test.pl rohara
  -- strict thread matches above, loose matches on Subject: below --
2007-03-06 19:10 rohara
2007-03-06 19:09 rohara
2007-03-06 19:07 rohara
2006-12-08 20:46 rohara
2006-12-08 19:59 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).