[Cluster-devel] cluster/fence/agents/drac fence_drac.pl

rmccabe at sourceware.org rmccabe at sourceware.org
Mon Nov 27 16:40:43 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2006-11-27 16:40:42

Modified files:
	fence/agents/drac: fence_drac.pl 

Log message:
	add support for DRAC5 (bz# 211918)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/drac/fence_drac.pl.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.6&r2=1.3.2.7

--- cluster/fence/agents/drac/fence_drac.pl	2006/10/20 16:21:53	1.3.2.6
+++ cluster/fence/agents/drac/fence_drac.pl	2006/11/27 16:40:42	1.3.2.7
@@ -3,7 +3,7 @@
 ###############################################################################
 ###############################################################################
 ##
-##  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+##  Copyright (C) 2006 Red Hat, Inc.  All rights reserved.
 ##  
 ##  This copyrighted material is made available to anyone wishing to use,
 ##  modify, copy, or redistribute it subject to the terms and conditions
@@ -21,7 +21,10 @@
 #  
 #  PowerEdge 1855	DRAC/MC		1.1  (Build 03.03)
 #  PowerEdge 1855	DRAC/MC		1.2  (Build 03.03)
+#  PowerEdge 1855	DRAC/MC		1.3  (Build 06.12)
 #  PowerEdge 1850	DRAC 4/I	1.35 (Build 09.27)
+#  PowerEdge 1850	DRAC 4/I	1.40 (Build 08.24)
+#  PowerEdge 1950	DRAC 5		1.0  (Build 06.05.12)
 #
 
 use Getopt::Std;
@@ -41,11 +44,15 @@
 
 my $t = new Net::Telnet;
 
-my $DRAC_VERSION_UNKNOWN = '__unknown__';
-my $DRAC_VERSION_III_XT  = 'DRAC III/XT';
-my $DRAC_VERSION_MC      = 'DRAC/MC';
-my $DRAC_VERSION_4I	 = 'DRAC 4/I';
-my $DRAC_VERSION_4P	 = 'DRAC 4/P';
+my $DRAC_VERSION_UNKNOWN	= '__unknown__';
+my $DRAC_VERSION_III_XT		= 'DRAC III/XT';
+my $DRAC_VERSION_MC			= 'DRAC/MC';
+my $DRAC_VERSION_4I			= 'DRAC 4/I';
+my $DRAC_VERSION_4P			= 'DRAC 4/P';
+my $DRAC_VERSION_5			= 'DRAC 5';
+
+my $PWR_CMD_SUCCESS			= "/^OK/";
+my $PWR_CMD_SUCCESS_DRAC5	= "/^Server power operation successful$/";
 
 # WARNING!! Do not add code bewteen "#BEGIN_VERSION_GENERATION" and 
 # "#END_VERSION_GENERATION"  It is generated by the Makefile
@@ -129,7 +136,7 @@
 		fail "failed: telnet open failed: ". $t->errmsg."\n";
   
 	# Expect 'Login: ' 
-	($_) = $t->waitfor(Match => "/Login: /", Timeout=>15) or
+	($_) = $t->waitfor(Match => "/[Ll]ogin: /", Timeout=>15) or
 		fail "failed: telnet failed: ". $t->errmsg."\n" ;
 
 	# Determine DRAC version
@@ -148,7 +155,6 @@
 	}
 	else
 	{
-		print "WARNING: unable to detect DRAC version '$_'\n";
 		$drac_version = $DRAC_VERSION_UNKNOWN;
 	}
   }
@@ -176,12 +182,11 @@
   } 
 	else
 	{
-		print "WARNING: unsupported DRAC version '$drac_version'\n";
 		$drac_version = $DRAC_VERSION_UNKNOWN;
 	}
 
 	# Take a guess as to what the prompt might be if not already defined
-	$cmd_prompt="/(\\[$login\\]# |DRAC\\/MC:)/" unless defined $cmd_prompt;
+	$cmd_prompt="/(\\[$login\\]# |DRAC\\/MC:|\\\$ )/" unless defined $cmd_prompt;
 	
 
 	# Send login
@@ -194,9 +199,24 @@
 	# Send password
 	$t->print($passwd);  
 
-	# Expect '[$login]# '
+	# DRAC5 prints version controller version info
+	# only after you've logged in.
+	if ($drac_version eq $DRAC_VERSION_UNKNOWN) {
+		if ($t->waitfor(Match => "/.*\($DRAC_VERSION_5\)/m")) {
+			$drac_version = $DRAC_VERSION_5;
+			$cmd_prompt = "/\\\$ /";
+			$PWR_CMD_SUCCESS = $PWR_CMD_SUCCESS_DRAC5;
+		} else {
+			print "WARNING: unable to detect DRAC version '$_'\n";
+		}
+	}
+
 	$t->waitfor($cmd_prompt) or
-		fail "failed: invalid username or password"; 
+		fail "failed: invalid username or password";
+
+	if ($drac_version eq $DRAC_VERSION_UNKNOWN) {
+		print "WARNING: unsupported DRAC version '$drac_version'\n";
+	}
 
 	$logged_in = 1;
 }
@@ -216,7 +236,9 @@
 	{
 		$cmd = "serveraction -m $modulename  -d 0 $svr_action";
 	}
-	else
+	elsif ($drac_version eq $DRAC_VERSION_5) {
+		$cmd = "racadm serveraction $svr_action";
+	} else
 	{
 		$cmd = "serveraction -d 0 $svr_action";
 	}
@@ -254,7 +276,7 @@
 		}
 		else
 		{
-			next if (/^OK$/);
+			next if ($PWR_CMD_SUCCESS);
 			$err = $_;
 		}
 	}
@@ -268,8 +290,14 @@
 sub get_power_status
 {
 	my $status; 
-	my $cmd = "getmodinfo";
 	my $modname = $modulename;
+	my $cmd;
+
+	if ($drac_version eq $DRAC_VERSION_5) {
+		$cmd = "racadm serveraction powerstatus";
+	} else {
+		$cmd = "getmodinfo";
+	}
 
 	$t->print($cmd);
 
@@ -288,51 +316,59 @@
 
 	fail "failed: unkown dialog exception: '$_'" unless (/^$cmd$/);
 
-	#Expect:
-	#  #<group>     <module>    <presence>  <pwrState>  <health>  <svcTag>
-	#   1  ---->     chassis    Present         ON      Normal    CQXYV61
-	#
-	#  Note: DRAC/MC has many entries in the table whereas DRAC III has only
-	#  a single table entry.
-
-	while (1)
-	{
-		$_ = shift @cmd_out;
-		if (/^#<group>\s*<module>\s*<presence>\s*<pwrState>\s*<health>\s*<svcTag>/)
-		{
-			$found_header = 1;
-			last;
+	if ($drac_version ne $DRAC_VERSION_5) {
+		#Expect:
+		#  #<group>     <module>    <presence>  <pwrState>  <health>  <svcTag>
+		#   1  ---->     chassis    Present         ON      Normal    CQXYV61
+		#
+		#  Note: DRAC/MC has many entries in the table whereas DRAC III has only
+		#  a single table entry.
+
+		while (1)
+		{
+			$_ = shift @cmd_out;
+			if (/^#<group>\s*<module>\s*<presence>\s*<pwrState>\s*<health>\s*<svcTag>/)
+			{
+				$found_header = 1;
+				last;
+			}
 		}
+		fail "failed: invalid 'getmodinfo' header: '$_'" unless $found_header;
 	}
-	fail "failed: invalid 'getmodinfo' header: '$_'" unless $found_header;
-
 
 	foreach (@cmd_out)
 	{ 
 		s/^\s+//g; #strip leading space
 		s/\s+$//g; #strip training space
 
-		my ($group,$arrow,$module,$presence,$pwrstate,$health,
-			$svctag,$junk) = split /\s+/;
+		if ($drac_version eq $DRAC_VERSION_5) {
+			if(m/^Server power status: (\w+)/) {
+				$status = lc($1);
+			}
+		} else {
+			my ($group,$arrow,$module,$presence,$pwrstate,$health,
+				$svctag,$junk) = split /\s+/;
+
+			if ($drac_version eq  $DRAC_VERSION_III_XT || $drac_version eq $DRAC_VERSION_4I || $drac_version eq $DRAC_VERSION_4P)
+			{
+				fail "failed: extraneous output detected from 'getmodinfo'" if $found_module;
+				$found_module = 1;
+				$modname = $module;
+			}
+
+			if ($modname eq $module)
+			{
+				fail "failed: duplicate module names detected" if $status;
+				$found_module = 1;
+
+				fail "failed: module not reported present" unless ($presence =~ /Present/);
+				$status = $pwrstate;
+			}
 
-		if ($drac_version eq  $DRAC_VERSION_III_XT || $drac_version eq $DRAC_VERSION_4I || $drac_version eq $DRAC_VERSION_4P)
-		{
-			fail "failed: extraneous output detected from 'getmodinfo'" if $found_module;
-			$found_module = 1;
-			$modname = $module;
-		}
-
-		if ($modname eq $module)
-		{
-			fail "failed: duplicate module names detected" if $status;
-			$found_module = 1;
-
-			fail "failed: module not reported present" unless ($presence =~ /Present/);
-			$status = $pwrstate;
 		}
 	}
 
-	if ($drac_version eq  $DRAC_VERSION_MC)
+	if ($drac_version eq $DRAC_VERSION_MC)
 	{
 		fail "failed: module '$modulename' not detected" unless $found_module;
 	}




More information about the Cluster-devel mailing list