2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 17:23:08 +00:00

Merge pull request #3608 from gurevichmark/openbmc_rflash_delete_image

Implement openbmc image delete function
This commit is contained in:
zet809 2017-08-08 15:17:05 +08:00 committed by GitHub
commit eeb32f8431
4 changed files with 38 additions and 12 deletions

View File

@ -57,7 +57,7 @@ OpenPOWER OpenBMC specific :
============================
\ **rflash**\ \ *noderange*\ [\ *tar_file_path*\ | \ *image_id*\ ] [\ **-c | -**\ **-check**\ ] [\ **-a | -**\ **-activate**\ ] [\ **-l | -**\ **-list**\ ] [\ **-u | -**\ **-upload**\ ]
\ **rflash**\ \ *noderange*\ [\ *tar_file_path*\ | \ *image_id*\ ] [\ **-c | -**\ **-check**\ ] [\ **-a | -**\ **-activate**\ ] [\ **-l | -**\ **-list**\ ] [\ **-u | -**\ **-upload**\ ] [\ **-d | -**\ **-delete**\ ]
@ -220,6 +220,12 @@ The command will update firmware for OpenPOWER OpenBMC when given an OpenPOWER n
\ **-d|-**\ **-delete**\
Delete update image from BMC
\ **-v|-**\ **-version**\
Displays the command's version.

View File

@ -345,7 +345,7 @@ my %usage = (
PPC64LE (using IPMI Management) specific:
rflash <noderange> [-c|--check] [--retry=<count>] [-V] [<hpm_file>|-d=<data_directory>]
PPC64LE (using OpenBMC Management) specific:
rflash <noderange> [-c|--check] [-l|--list] [-a|--activate] [-u|--upload] [<tar_file>|<image_id>]",
rflash <noderange> [-c|--check] [-l|--list] [-a|--activate] [-u|--upload] [-d|--delete] [<tar_file>|<image_id>]",
"mkhwconn" =>
"Usage:
mkhwconn [-h|--help]

View File

@ -28,7 +28,7 @@ B<rflash> I<noderange> [I<hpm_file_path> | B<-d=>I<data_directory>] [B<-c>|B<--c
=head2 OpenPOWER OpenBMC specific :
B<rflash> I<noderange> [I<tar_file_path> | I<image_id>] [B<-c>|B<--check>] [B<-a>|B<--activate>] [B<-l>|B<--list>] [B<-u>|B<--upload>]
B<rflash> I<noderange> [I<tar_file_path> | I<image_id>] [B<-c>|B<--check>] [B<-a>|B<--activate>] [B<-l>|B<--list>] [B<-u>|B<--upload>] [B<-d>|B<--delete>]
=head1 B<Description>
@ -145,6 +145,10 @@ List currently uploaded update images. "(*)" indicates currently active image.
Upload update image. Specified file must be in .tar format.
=item B<-d|--delete>
Delete update image from BMC
=item B<-v|--version>
Displays the command's version.

View File

@ -179,6 +179,14 @@ my %status_info = (
RFLASH_SET_PRIORITY_RESPONSE => {
process => \&rflash_response,
},
RFLASH_DELETE_IMAGE_REQUEST => {
method => "POST",
init_url => "$openbmc_project_url/software",
data => "[]",
},
RFLASH_DELETE_IMAGE_RESPONSE => {
process => \&rflash_response,
},
RINV_REQUEST => {
method => "GET",
@ -874,6 +882,7 @@ sub parse_command_status {
$status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_file/attr/RequestedActivation";
$status_info{RFLASH_SET_PRIORITY_REQUEST}{init_url} .= "/$update_file/attr/Priority";
$status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{init_url} .= "/$update_file";
$status_info{RFLASH_DELETE_IMAGE_REQUEST}{init_url} .= "/$update_file/action/Delete";
}
}
}
@ -888,11 +897,12 @@ sub parse_command_status {
$next_status{RFLASH_LIST_REQUEST} = "RFLASH_LIST_RESPONSE";
}
if ($delete) {
xCAT::SvrUtils::sendmsg("Delete option is not yet supported.", $callback);
return 1;
# Delete uploaded image from BMC
$next_status{LOGIN_RESPONSE} = "RFLASH_DELETE_IMAGE_REQUEST";
$next_status{RFLASH_DELETE_IMAGE_REQUEST} = "RFLASH_DELETE_IMAGE_RESPONSE";
}
if ($upload) {
# Upload specified update file to BMC
# Upload specified update file to BMC
$next_status{LOGIN_RESPONSE} = "RFLASH_FILE_UPLOAD_REQUEST";
$next_status{"RFLASH_FILE_UPLOAD_REQUEST"} = "RFLASH_FILE_UPLOAD_RESPONSE";
}
@ -1013,6 +1023,9 @@ sub gen_send_request {
# Handle boolean values by create the json objects without wrapping with quotes
if ($status_info{ $node_info{$node}{cur_status} }{data} =~ /^1$|^true$|^True$|^0$|^false$|^False$/) {
$content = '{"data":' . $status_info{ $node_info{$node}{cur_status} }{data} . '}';
} elsif ($status_info{ $node_info{$node}{cur_status} }{data} =~ /^\[\]$/) {
# Special handling of empty data list
$content = '{"data":[]}';
} else {
$content = '{"data":"' . $status_info{ $node_info{$node}{cur_status} }{data} . '"}';
}
@ -1799,7 +1812,7 @@ sub rflash_response {
print Dumper(%{$response_info->{data}});
my $update_id;
my $update_activation;
my $update_activation = "Unknown";
my $update_purpose;
my $update_version;
my $update_priority = -1;
@ -1898,9 +1911,8 @@ sub rflash_response {
if ($activation_state =~ /Software.Activation.Activations.Failed/) {
# Activation failed. Report error and exit
xCAT::SvrUtils::sendmsg([1,"Activation of firmware failed"], $callback, $node);
}
if ($activation_state =~ /Software.Activation.Activations.Active/) {
}
elsif ($activation_state =~ /Software.Activation.Activations.Active/) {
if (scalar($priority_state) == 0) {
# Activation state of active and priority of 0 indicates the activation has been completed
xCAT::SvrUtils::sendmsg("Firmware update successfully activated", $callback, $node);
@ -1913,8 +1925,7 @@ sub rflash_response {
$next_status{ $node_info{$node}{cur_status} } = "RFLASH_SET_PRIORITY_REQUEST";
}
}
if ($activation_state =~ /Software.Activation.Activations.Activating/) {
elsif ($activation_state =~ /Software.Activation.Activations.Activating/) {
# Activation still going, sleep for a bit, then print the progress value
sleep(15);
xCAT::SvrUtils::sendmsg("Activating firmware update. $progress_state\%", $callback, $node);
@ -1922,6 +1933,11 @@ sub rflash_response {
# Set next state to come back here to chect the activation status again.
$next_status{ $node_info{$node}{cur_status} } = "RFLASH_UPDATE_CHECK_STATE_REQUEST";
}
}
if ($node_info{$node}{cur_status} eq "RFLASH_DELETE_IMAGE_RESPONSE") {
xCAT::SvrUtils::sendmsg("Firmware update successfully removed", $callback, $node);
}
if ($next_status{ $node_info{$node}{cur_status} }) {