[Cluster-devel] cluster/fence/agents/scsi fence_scsi.pl

rohara at sourceware.org rohara at sourceware.org
Fri Dec 1 17:53:23 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-12-01 17:53:22

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

Log message:
	Remove "self" parameter. This was used to specify the name of the node
	performing the fence operation, and was passed to the agent. This is
	no longer used. Instead, we get the name of the local node in the agent
	by parsing the output from 'cman_tool status'.

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

--- cluster/fence/agents/scsi/fence_scsi.pl	2006/07/12 20:34:17	1.5
+++ cluster/fence/agents/scsi/fence_scsi.pl	2006/12/01 17:53:22	1.5.2.1
@@ -4,7 +4,6 @@
 use IPC::Open3;
 use POSIX;
 
-my $verbose = 0;
 my @volumes;
 
 $_ = $0;
@@ -71,6 +70,45 @@
     return unpack("H*", $addr);
 }
 
+sub get_node_name
+{
+    return $opt_n;
+}
+
+sub get_host_name
+{
+    my $host_name;
+
+    my ($in, $out, $err);
+    my $cmd = "cman_tool status";
+
+    my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
+
+    waitpid($pid, 0);
+
+    die "Unable to execute cman_tool.\n" if ($?>>8);
+
+    while (<$out>)
+    {
+	chomp;
+	print "OUT: $_\n" if $opt_v;
+
+	my ($name, $value) = split(/\s*:\s*/, $_);
+
+	if ($name eq "Node name")
+	{
+	    $host_name = $value;
+	    last;
+	}
+    }
+
+    close($in);
+    close($out);
+    close($err);
+
+    return $host_name;
+}
+
 sub get_options_stdin
 {
     my $opt;
@@ -107,10 +145,6 @@
 	{
 	    $opt_n = $val;
 	}
-	elsif ($name eq "self")
-	{
-	    $opt_s = $val;
-	}
 	elsif ($name eq "verbose")
 	{
 	    $opt_v = $val;
@@ -174,10 +208,11 @@
 
 sub fence_node
 {
-    # my $name = (POSIX::uname())[1];
+    my $host_name = get_host_name();
+    my $node_name = get_node_name();
 
-    my $host_key = get_key($opt_s);
-    my $node_key = get_key($opt_n);
+    my $host_key = get_key($host_name);
+    my $node_key = get_key($node_name);
     
     my $cmd;
     my ($in, $out, $err);
@@ -197,18 +232,14 @@
 
 	waitpid($pid, 0);
 
-	if ($opt_v)
+	die "Unable to execute sg_persist.\n" if ($?>>8);
+
+	while (<$out>)
 	{
-	    print "$cmd\n";
-	    while (<$out>)
-	    {
-		chomp;
-		print "OUT: $_\n";
-	    }
+	    chomp;
+	    print "OUT: $_\n" if $opt_v;
 	}
 
-	die "Unable to execute sg_persist.\n" if ($?>>8);
-
 	close($in);
 	close($out);
 	close($err);
@@ -225,15 +256,14 @@
     version if defined $opt_V;
 
     fail_usage "Unkown parameter." if (@ARGV > 0);
+
     fail_usage "No '-n' flag specified." unless defined $opt_n;
-    fail_usage "No '-s' flag specified." unless defined $opt_s;
 
 } else {
 
     get_options_stdin();
 
     fail "failed: missing 'node'" unless defined $opt_n;
-    fail "failed: missing 'self'" unless defined $opt_s;
 
 }
 
@@ -242,3 +272,4 @@
 get_scsi_devices;
 
 fence_node;
+




More information about the Cluster-devel mailing list