From 64ab7dbd2772cf9a67dff150f9c8c6c8670dec37 Mon Sep 17 00:00:00 2001 From: chenglch Date: Fri, 8 Sep 2017 10:08:40 +0800 Subject: [PATCH] Add rflash recovery support for Supermicro based firmware This commit add recover option for rflash command to upload bmc image with tftp when the BMC is in Brick Protection state. Example: ``` rflash --recover ``` implement #3873 --- .../admin-guides/references/man1/rflash.1.rst | 8 ++++ perl-xCAT/xCAT/Usage.pm | 1 + xCAT-client/pods/man1/rflash.1.pod | 8 ++++ xCAT-server/lib/xcat/plugins/ipmi.pm | 41 +++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/docs/source/guides/admin-guides/references/man1/rflash.1.rst b/docs/source/guides/admin-guides/references/man1/rflash.1.rst index 928102d6e..12833968e 100644 --- a/docs/source/guides/admin-guides/references/man1/rflash.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rflash.1.rst @@ -52,6 +52,8 @@ OpenPOWER BMC specific (using IPMI): \ **rflash**\ \ *noderange*\ [\ *hpm_file_path*\ | \ **-d**\ \ *data_directory*\ ] [\ **-c | -**\ **-check**\ ] [\ **-**\ **-retry=**\ \ *count*\ ] [\ **-V**\ ] +\ **rflash**\ \ *noderange*\ \ **-**\ **-recover**\ \ *bmc_file_path*\ + OpenPOWER OpenBMC specific : ============================ @@ -196,8 +198,14 @@ The command will update firmware for OpenPOWER OpenBMC when given an OpenPOWER n \ **-**\ **-recover**\ + PPC (with HMC) and PPC (without HMC, using Direct FSP Management) specific: + Used to recover the flash image in the permanent side of the chip to the temporary side for both managed systems and power subsystems. + OpenPOWER BMC specific (using IPMI): + + Used for IBM Power S822LC for Big Data systems only. Used to recover the BMC with a BMC image downloaded from FixCentral. + \ **-**\ **-retry=**\ \ *count*\ diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index fb19d3802..3392e2668 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -344,6 +344,7 @@ my %usage = ( rflash [--bpa_acdl] OpenPOWER BMC specific (using IPMI): rflash [|-d ] [-c|--check] [--retry=] [-V] + rflash --recover OpenPOWER OpenBMC specific: rflash {[-c|--check] | [-l|--list]} rflash {[-c|--check] | [-a|--activate] | [-u|--upload]} diff --git a/xCAT-client/pods/man1/rflash.1.pod b/xCAT-client/pods/man1/rflash.1.pod index cc544efbb..ee2b29da1 100644 --- a/xCAT-client/pods/man1/rflash.1.pod +++ b/xCAT-client/pods/man1/rflash.1.pod @@ -26,6 +26,8 @@ B I I B I [I | B<-d> I] [B<-c>|B<--check>] [B<--retry=>I] [B<-V>] +B I B<--recover> I + =head2 OpenPOWER OpenBMC specific : B I {[B<-c>|B<--check>] | [B<-l>|B<--list>]} @@ -133,8 +135,14 @@ Used to commit the flash image in the temporary side of the chip to the permanen =item B<--recover> +PPC (with HMC) and PPC (without HMC, using Direct FSP Management) specific: + Used to recover the flash image in the permanent side of the chip to the temporary side for both managed systems and power subsystems. +OpenPOWER BMC specific (using IPMI): + +Used for IBM Power S822LC for Big Data systems only. Used to recover the BMC with a BMC image downloaded from FixCentral. + =item B<--retry=>I Specify number of times to retry the update if failure is detected. Default value is 2. Value of 0 can be used to indicate no retries. diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 2e9f4f582..923aad072 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -20,6 +20,7 @@ use xCAT_monitoring::monitorctrl; use xCAT::SPD qw/decode_spd/; use xCAT::IPMI; use xCAT::PasswordUtils; +use File::Basename; my %needbladeinv; use POSIX qw(ceil floor); @@ -2494,6 +2495,46 @@ sub do_rflash_process { $callback, $node, %allerrornodes); exit(1); } + my $recover_image; + if (grep(/^(--recover)$/, @{ $extra })) { + if (@{ $extra } != 2) { + xCAT::SvrUtils::sendmsg([ 1, "The command format for recovery is invalid. Only support 'rflash --recover '" ], + $callback, $node); + exit(1); + } + my @argv = @{ $extra }; + if ($argv[0] eq "--recover") { + $recover_image = $argv[1]; + } elsif ($argv[1] eq "--recover") { + $recover_image = $argv[0]; + } + } + if (defined($recover_image)) { + if ($recover_image !~ /^\//) { + $recover_image = xCAT::Utils->full_path($recover_image, $::cwd); + } + unless(-x "/usr/bin/tftp") { + $callback->({ error => "Could not find executable file /usr/bin/tftp, please setup tftp client.", + errorcode => 1 }); + exit(1); + } + my $bmcip = $_[0]; + my $cmd = "/usr/bin/tftp $bmcip -m binary -c put $recover_image ".basename($recover_image); + my $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + $callback->({ error => "Running tftp command \'$cmd\' failed. Error Code: $::RUNCMD_RC. Output: $output.", + errorcode => 1 }); + exit(1); + } + # Sometimes tftp command retrun error message but without nonzero error code + if($output) { + $callback->({ error => "Running tftp command \'$cmd\' failed. Output: $output", + errorcode => 1 }); + exit(1); + } + $callback->({ data => "$node: Successfully updated recovery image. BMC is restarting and will not be reachable for 5-10 minutes."}); + exit(0); + } donode($node, @_); while (xCAT::IPMI->waitforrsp()) { yield } xCAT::Utils->release_lock($lock, $NON_BLOCK);