From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/fence/agents/drac fence_drac.pl
Date: 27 Nov 2006 16:45:39 -0000 [thread overview]
Message-ID: <20061127164539.18242.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rmccabe at 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;
}
next reply other threads:[~2006-11-27 16:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-27 16:45 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-11-27 16:47 [Cluster-devel] cluster/fence/agents/drac fence_drac.pl rmccabe
2006-11-27 16:40 rmccabe
2006-10-20 16:21 jparsons
2006-09-06 15:34 jparsons
2006-09-06 15:32 jparsons
2006-08-16 19:16 jparsons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061127164539.18242.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.