From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 10 May 2007 19:42:26 -0000 Subject: [Cluster-devel] cluster/fence/agents drac/fence_drac.pl ilo/fe ... Message-ID: <20070510194226.24671.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Branch: RHEL5 Changes by: rmccabe at sourceware.org 2007-05-10 19:42:24 Modified files: fence/agents/drac: fence_drac.pl fence/agents/ilo: fence_ilo.pl Log message: RHEL5 fence_drac and fence_ilo are out of sync with RHEL50 (and HEAD). sync them up. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/drac/fence_drac.pl.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8&r2=1.8.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/ilo/fence_ilo.pl.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5&r2=1.5.2.1 --- cluster/fence/agents/drac/fence_drac.pl 2006/09/06 15:34:03 1.8 +++ cluster/fence/agents/drac/fence_drac.pl 2007/05/10 19:42:24 1.8.2.1 @@ -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: - # # - # 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 (/^#\s*\s*\s*\s*\s*/) - { - $found_header = 1; - last; + if ($drac_version ne $DRAC_VERSION_5) { + #Expect: + # # + # 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 (/^#\s*\s*\s*\s*\s*/) + { + $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; } --- cluster/fence/agents/ilo/fence_ilo.pl 2006/08/16 19:11:49 1.5 +++ cluster/fence/agents/ilo/fence_ilo.pl 2007/05/10 19:42:24 1.5.2.1 @@ -262,6 +262,13 @@ foreach my $line (@response) { + if ($line =~ /MANAGEMENT_PROCESSOR\s*=\s*\"(.*)\"/) { + if ($1 eq "iLO2") { + $ilo_vers = 2; + print "power_status: reporting iLO2\n" if ($verbose); + } + } + if ($line =~ /MESSAGE='(.*)'/) { my $msg = $1; @@ -326,10 +333,20 @@ sendsock $socket, "\n"; sendsock $socket, "\n"; + if ($ilo_vers == 2) { + # iLO2 with RIBCL v2.22 behaves differently from + # iLO with RIBCL v2.22. For the former, HOLD_PWR_BTN is + # used to both power the machine on and off; when the power + # is off, PRESS_PWR_BUTTON has no effect. For the latter, + # HOLD_PWR_BUTTON is used to power the machine off, and + # PRESS_PWR_BUTTON is used to power the machine on; + # when the power is off, HOLD_PWR_BUTTON has no effect. + sendsock $socket, "\n"; + } # As of firmware version 1.71 (RIBCL 2.21) The SET_HOST_POWER command # is no longer available. HOLD_PWR_BTN and PRESS_PWR_BTN are used # instead now :( - if ($ribcl_vers < 2.21 ) + elsif ($ribcl_vers < 2.21) { sendsock $socket, "\n"; } @@ -384,6 +401,9 @@ sendsock $socket, "\n"; } sendsock $socket, "\n"; + if ($ribcl_vers >= 2) { + sendsock $socket, "\n"; + } sendsock $socket, "\n"; sendsock $socket, "\n"; sendsock $socket, "\n"; @@ -469,6 +489,7 @@ $action = "reboot"; $ribcl_vers = undef; # undef = autodetect +$ilo_vers = 1; if (@ARGV > 0) { getopts("a:hl:n:o:p:r:qvV") || fail_usage ;