[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rmccabe sourceware org	2006-11-27 16:45:39

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

Log message:
	Add DRAC5 and DRAC4/I support
	Related: #211836, #211918

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

--- cluster/fence/agents/drac/fence_drac.pl	2006/09/06 15:34:03	1.8
+++ cluster/fence/agents/drac/fence_drac.pl	2006/11/27 16:45:38	1.9
@@ -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;
@@ -32,7 +35,7 @@
 s/.*\///;
 my $pname = $_;
 
-my $telnet_timeout = 5;      # Seconds to wait for matching telent response
+my $telnet_timeout = 10;      # Seconds to wait for matching telent response
 my $power_timeout = 20;      # time to wait in seconds for power state changes
 $action = 'reboot';          # Default fence action.  
 
@@ -41,10 +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_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
@@ -128,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
@@ -147,7 +155,6 @@
 	}
 	else
 	{
-		print "WARNING: unable to detect DRAC version '$_'\n";
 		$drac_version = $DRAC_VERSION_UNKNOWN;
 	}
   }
@@ -168,14 +175,18 @@
 		$cmd_prompt = "/\\[$login\\]# /" 
 			unless defined $cmd_prompt;
 	}
+  elsif ($drac_version =~ /$DRAC_VERSION_4P/)
+  {
+        $cmd_prompt = "/\\[$login\\]# /"
+          unless defined $cmd_prompt;
+  } 
 	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
@@ -188,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;
 }
@@ -210,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";
 	}
@@ -248,7 +276,7 @@
 		}
 		else
 		{
-			next if (/^OK$/);
+			next if ($PWR_CMD_SUCCESS);
 			$err = $_;
 		}
 	}
@@ -262,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);
 
@@ -282,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)
-		{
-			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;
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]