2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-13 01:40:26 +00:00

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 <node> --recover <image>
```
implement #3873
This commit is contained in:
chenglch
2017-09-08 10:08:40 +08:00
parent 94f87ea3ac
commit 64ab7dbd27
4 changed files with 58 additions and 0 deletions

View File

@ -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*\

View File

@ -344,6 +344,7 @@ my %usage = (
rflash <noderange> [--bpa_acdl]
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:
rflash <noderange> {[-c|--check] | [-l|--list]}
rflash <noderange> <tar_file_path> {[-c|--check] | [-a|--activate] | [-u|--upload]}

View File

@ -26,6 +26,8 @@ B<rflash> I<noderange> I<http_directory>
B<rflash> I<noderange> [I<hpm_file_path> | B<-d> I<data_directory>] [B<-c>|B<--check>] [B<--retry=>I<count>] [B<-V>]
B<rflash> I<noderange> B<--recover> I<bmc_file_path>
=head2 OpenPOWER OpenBMC specific :
B<rflash> I<noderange> {[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<count>
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.

View File

@ -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 <noderange> --recover <bmc_file_path>'" ],
$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);