Gitweb:
http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=116512...
Commit: 116512c174f4acef0faee4459158c45ddf6922d2
Parent: 8b127ebff6a38b0c6dd9c2a1ad738e2d7637e0fa
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Jan 22 15:35:20 2014 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Jan 22 15:35:20 2014 +0100
fence_scsi: Replace automatic key generation to work with corosync clusters instead of
cman
Resolves: rhbz#994466
---
fence/agents/scsi/fence_scsi.pl | 38 ++++++++++++++++++++++----------------
1 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index c959417..3ad0f09 100644
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -5,6 +5,7 @@ use File::Basename;
use File::Path;
use Getopt::Std;
use POSIX;
+use B;
#BEGIN_VERSION_GENERATION
$RELEASE_VERSION="";
@@ -426,10 +427,10 @@ sub get_key ($)
sub get_node_id ($)
{
my $self = (caller(0))[3];
- my $node_id;
+ my $node = $_[0];
- my $cmd = "cman_tool nodes -n $_[0] -F id";
- my $out = qx { $cmd 2> /dev/null };
+ my $cmd = "/sbin/corosync-cmapctl nodelist.";
+ my @out = qx { $cmd 2> /dev/null };
my $err = ($?>>8);
if ($err != 0) {
@@ -438,11 +439,14 @@ sub get_node_id ($)
# die "[error]: $self\n" if ($?>>8);
- chomp ($out);
-
- $node_id = $out;
-
- return ($node_id);
+ foreach my $line (@out) {
+ chomp($line);
+ if ($line =~ /.(\d+?).ring._addr \(str\) = ${node}$/) {
+ return $1;
+ }
+ }
+
+ log_error("$self (unable to parse output of corosync-cmapctl or node does not
exist)");
}
sub get_cluster_id ()
@@ -450,8 +454,8 @@ sub get_cluster_id ()
my $self = (caller(0))[3];
my $cluster_id;
- my $cmd = "cman_tool status";
- my @out = qx { $cmd 2> /dev/null };
+ my $cmd = "/sbin/corosync-cmapctl totem.cluster_name";
+ my $out = qx { $cmd 2> /dev/null };
my $err = ($?>>8);
if ($err != 0) {
@@ -460,12 +464,14 @@ sub get_cluster_id ()
# die "[error]: $self\n" if ($?>>8);
- foreach (@out) {
- chomp;
- my ($param, $value) = split (/\s*:\s*/, $_);
- if ($param =~ /^cluster\s+id/i) {
- $cluster_id = $value;
- }
+ chomp($out);
+
+ if ($out =~ /=\s(.*?)$/) {
+ my $cluster_name = $1;
+ # tranform string to a number
+ $cluster_id = (hex B::hash($cluster_name)) % 65536;
+ } else {
+ log_error("$self (unable to parse output of corosync-cmapctl)");
}
return ($cluster_id);