mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 11:42:05 +00:00
OpenBMC upload and activate firmware image file
This commit is contained in:
parent
940a0b6dd4
commit
f69f9ec2bf
@ -59,7 +59,7 @@ OpenPOWER OpenBMC specific :
|
||||
|
||||
\ **rflash**\ \ *noderange*\ {[\ **-c | -**\ **-check**\ ] | [\ **-l | -**\ **-list**\ ]}
|
||||
|
||||
\ **rflash**\ \ *noderange*\ \ *tar_file_path*\ {[\ **-c | -**\ **-check**\ ] | [\ **-u | -**\ **-upload**\ ]}
|
||||
\ **rflash**\ \ *noderange*\ \ *tar_file_path*\ {[\ **-c | -**\ **-check**\ ] | [\ **-a | -**\ **-activate**\ ] | [\ **-u | -**\ **-upload**\ ]}
|
||||
|
||||
\ **rflash**\ \ *noderange*\ \ *image_id*\ {[\ **-a | -**\ **-activate**\ ] | [\ **-d | -**\ **-delete**\ ]}
|
||||
|
||||
@ -208,7 +208,7 @@ The command will update firmware for OpenPOWER OpenBMC when given an OpenPOWER n
|
||||
|
||||
\ **-a|-**\ **-activate**\
|
||||
|
||||
Activate update image. Image id must be specified.
|
||||
Activate update image. Image id or update file must be specified.
|
||||
|
||||
|
||||
|
||||
@ -322,7 +322,17 @@ The command will update firmware for OpenPOWER OpenBMC when given an OpenPOWER n
|
||||
|
||||
.. code-block:: perl
|
||||
|
||||
rflash briggs01 -d=/root/supermicro/OP825
|
||||
rflash briggs01 -d /root/supermicro/OP825
|
||||
|
||||
|
||||
|
||||
|
||||
7. To update the firmware on the OpenBMC machine, specify the firmare update file to upload and activate:
|
||||
|
||||
|
||||
.. code-block:: perl
|
||||
|
||||
rflash p9euh02 -a /tmp/witherspoon.pnor.squashfs.tar
|
||||
|
||||
|
||||
|
||||
|
@ -346,7 +346,7 @@ my %usage = (
|
||||
rflash <noderange> [<hpm_file_path>|-d <data_directory>] [-c|--check] [--retry=<count>] [-V]
|
||||
OpenPOWER OpenBMC specific:
|
||||
rflash <noderange> {[-c|--check] | [-l|--list]}
|
||||
rflash <noderange> <tar_file_path> {[-c|--check] | [-u|--upload]}
|
||||
rflash <noderange> <tar_file_path> {[-c|--check] | [-a|--activate] | [-u|--upload]}
|
||||
rflash <noderange> <image_id> {[-a|--activate] | [-d|--delete]}",
|
||||
"mkhwconn" =>
|
||||
"Usage:
|
||||
|
@ -30,7 +30,7 @@ B<rflash> I<noderange> [I<hpm_file_path> | B<-d> I<data_directory>] [B<-c>|B<--c
|
||||
|
||||
B<rflash> I<noderange> {[B<-c>|B<--check>] | [B<-l>|B<--list>]}
|
||||
|
||||
B<rflash> I<noderange> I<tar_file_path> {[B<-c>|B<--check>] | [B<-u>|B<--upload>]}
|
||||
B<rflash> I<noderange> I<tar_file_path> {[B<-c>|B<--check>] | [B<-a>|B<--activate>] | [B<-u>|B<--upload>]}
|
||||
|
||||
B<rflash> I<noderange> I<image_id> {[B<-a>|B<--activate>] | [B<-d>|B<--delete>]}
|
||||
|
||||
@ -141,7 +141,7 @@ Specify number of times to retry the update if failure is detected. Default valu
|
||||
|
||||
=item B<-a|--activate>
|
||||
|
||||
Activate update image. Image id must be specified.
|
||||
Activate update image. Image id or update file must be specified.
|
||||
|
||||
=item B<-l|--list>
|
||||
|
||||
@ -207,7 +207,12 @@ Print verbose message to rflash log file (/var/log/xcat/rflash/fs3.log) when upd
|
||||
=item 6.
|
||||
To update the firmware on IBM Power S822LC for Big Data machine specify the node name and the file path of the data directory containing pUpdate utility and BMC and/or PNOR update files:
|
||||
|
||||
rflash briggs01 -d=/root/supermicro/OP825
|
||||
rflash briggs01 -d /root/supermicro/OP825
|
||||
|
||||
=item 7.
|
||||
To update the firmware on the OpenBMC machine, specify the firmare update file to upload and activate:
|
||||
|
||||
rflash p9euh02 -a /tmp/witherspoon.pnor.squashfs.tar
|
||||
|
||||
=back
|
||||
|
||||
|
@ -43,6 +43,7 @@ $::POWER_STATE_QUIESCED = "quiesced";
|
||||
$::POWER_STATE_RESET = "reset";
|
||||
$::POWER_STATE_REBOOT = "reboot";
|
||||
$::UPLOAD_FILE = "";
|
||||
$::UPLOAD_FILE_VERSION = "";
|
||||
|
||||
$::NO_ATTRIBUTES_RETURNED = "No attributes returned from the BMC.";
|
||||
|
||||
@ -172,6 +173,13 @@ my %status_info = (
|
||||
RFLASH_UPDATE_CHECK_STATE_RESPONSE => {
|
||||
process => \&rflash_response,
|
||||
},
|
||||
RFLASH_UPDATE_CHECK_ID_REQUEST => {
|
||||
method => "GET",
|
||||
init_url => "$openbmc_project_url/software/enumerate",
|
||||
},
|
||||
RFLASH_UPDATE_CHECK_ID_RESPONSE => {
|
||||
process => \&rflash_response,
|
||||
},
|
||||
RFLASH_SET_PRIORITY_REQUEST => {
|
||||
method => "PUT",
|
||||
init_url => "$openbmc_project_url/software",
|
||||
@ -625,7 +633,7 @@ sub parse_args {
|
||||
}
|
||||
if ($filename_passed) {
|
||||
# Filename was passed, check flags allowed with file
|
||||
if ($option_flag !~ /^-c$|^--check$|^-d$|^--delete$|^-u$|^--upload$/) {
|
||||
if ($option_flag !~ /^-c$|^--check$|^-u$|^--upload$|^-a$|^--activate$/) {
|
||||
return ([ 1, "Invalid option specified when a file is provided: $option_flag" ]);
|
||||
}
|
||||
}
|
||||
@ -845,6 +853,7 @@ sub parse_command_status {
|
||||
my $upload = 0;
|
||||
my $activate = 0;
|
||||
my $update_file;
|
||||
my $upload_and_activate = 0;
|
||||
|
||||
foreach $subcommand (@$subcommands) {
|
||||
if ($subcommand =~ /-c|--check/) {
|
||||
@ -866,6 +875,8 @@ sub parse_command_status {
|
||||
my $grep_cmd = "/usr/bin/grep -a";
|
||||
my $version_tag = '"version=IBM"';
|
||||
my $purpose_tag = '"purpose="';
|
||||
my $purpose_value;
|
||||
my $version_value;
|
||||
if (defined $update_file) {
|
||||
# Filename or file id was specified
|
||||
if ($update_file =~ /.*\.tar$/) {
|
||||
@ -882,17 +893,29 @@ sub parse_command_status {
|
||||
xCAT::SvrUtils::sendmsg([1,"Cannot access $::UPLOAD_FILE"], $callback);
|
||||
return 1;
|
||||
}
|
||||
if ($check_version) {
|
||||
# Display firmware version of the specified .tar file
|
||||
if ($activate) {
|
||||
# Activate flag was specified together with a update file. We want to
|
||||
# upload the file and activate it.
|
||||
$upload_and_activate = 1;
|
||||
$activate = 0;
|
||||
}
|
||||
|
||||
if ($check_version | $upload_and_activate) {
|
||||
# Extract Host version for the update file
|
||||
my $firmware_version_in_file = `$grep_cmd $version_tag $::UPLOAD_FILE`;
|
||||
my $purpose_version_in_file = `$grep_cmd $purpose_tag $::UPLOAD_FILE`;
|
||||
chomp($firmware_version_in_file);
|
||||
chomp($purpose_version_in_file);
|
||||
my ($purpose_string,$purpose_value) = split("=", $purpose_version_in_file);
|
||||
my ($version_string,$version_value) = split("=", $firmware_version_in_file);
|
||||
(my $purpose_string,$purpose_value) = split("=", $purpose_version_in_file);
|
||||
(my $version_string,$version_value) = split("=", $firmware_version_in_file);
|
||||
if ($purpose_value =~ /host/) {
|
||||
$purpose_value = "Host";
|
||||
}
|
||||
$::UPLOAD_FILE_VERSION = $version_value;
|
||||
}
|
||||
|
||||
if ($check_version) {
|
||||
# Display firmware version of the specified .tar file
|
||||
xCAT::SvrUtils::sendmsg("TAR $purpose_value Firmware Product Version\: $version_value", $callback);
|
||||
}
|
||||
}
|
||||
@ -940,6 +963,13 @@ sub parse_command_status {
|
||||
$next_status{"RFLASH_SET_PRIORITY_REQUEST"} = "RFLASH_SET_PRIORITY_RESPONSE";
|
||||
$next_status{"RFLASH_SET_PRIORITY_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST";
|
||||
}
|
||||
if ($upload_and_activate) {
|
||||
# Upload specified update file to BMC
|
||||
$next_status{LOGIN_RESPONSE} = "RFLASH_FILE_UPLOAD_REQUEST";
|
||||
$next_status{"RFLASH_FILE_UPLOAD_REQUEST"} = "RFLASH_FILE_UPLOAD_RESPONSE";
|
||||
$next_status{"RFLASH_FILE_UPLOAD_RESPONSE"} = "RFLASH_UPDATE_CHECK_ID_REQUEST";
|
||||
$next_status{"RFLASH_UPDATE_CHECK_ID_REQUEST"} = "RFLASH_UPDATE_CHECK_ID_RESPONSE";
|
||||
}
|
||||
}
|
||||
|
||||
print Dumper(\%next_status) . "\n";
|
||||
@ -1958,7 +1988,7 @@ sub rflash_response {
|
||||
}
|
||||
else {
|
||||
# Activation state of active and priority of non 0 - need to just set priority to 0 to activate
|
||||
print "Update is already active, just need to set priority to 0";
|
||||
print "Update is already active, just need to set priority to 0\n";
|
||||
$next_status{ $node_info{$node}{cur_status} } = "RFLASH_SET_PRIORITY_REQUEST";
|
||||
}
|
||||
}
|
||||
@ -1973,6 +2003,42 @@ sub rflash_response {
|
||||
|
||||
}
|
||||
|
||||
if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_CHECK_ID_RESPONSE") {
|
||||
my $activation_state;
|
||||
my $progress_state;
|
||||
my $priority_state;
|
||||
|
||||
# Look through all the software entries and find the id of the one that matches
|
||||
# the version of the uploaded file. Once found, set up request/response hash entries
|
||||
# to activate that image.
|
||||
foreach my $key_url (keys %{$response_info->{data}}) {
|
||||
my %content = %{ ${ $response_info->{data} }{$key_url} };
|
||||
|
||||
$update_id = (split(/\//, $key_url))[ -1 ];
|
||||
if (defined($content{Version}) and $content{Version}) {
|
||||
$update_version = $content{Version};
|
||||
}
|
||||
if ($update_version eq $::UPLOAD_FILE_VERSION) {
|
||||
# Found a match of uploaded file version with the image in software/enumerate
|
||||
|
||||
# Set the image id for the activation request
|
||||
$status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_id/attr/RequestedActivation";
|
||||
$status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{init_url} .= "/$update_id";
|
||||
$status_info{RFLASH_SET_PRIORITY_REQUEST}{init_url} .= "/$update_id/attr/Priority";
|
||||
|
||||
# Set next steps to activate the image
|
||||
$next_status{ $node_info{$node}{cur_status} } = "RFLASH_UPDATE_ACTIVATE_REQUEST";
|
||||
$next_status{"RFLASH_UPDATE_ACTIVATE_REQUEST"} = "RFLASH_UPDATE_ACTIVATE_RESPONSE";
|
||||
$next_status{"RFLASH_UPDATE_ACTIVATE_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST";
|
||||
$next_status{"RFLASH_UPDATE_CHECK_STATE_REQUEST"} = "RFLASH_UPDATE_CHECK_STATE_RESPONSE";
|
||||
|
||||
$next_status{"RFLASH_SET_PRIORITY_REQUEST"} = "RFLASH_SET_PRIORITY_RESPONSE";
|
||||
$next_status{"RFLASH_SET_PRIORITY_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($node_info{$node}{cur_status} eq "RFLASH_DELETE_IMAGE_RESPONSE") {
|
||||
xCAT::SvrUtils::sendmsg("Firmware update successfully removed", $callback, $node);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user