From f18044a8c2e6708ebce6da685096e7db78b78afd Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 21 Jun 2017 11:35:42 -0400 Subject: [PATCH 1/7] Initial implementation of rflash --activate --- xCAT-server/lib/xcat/plugins/openbmc.pm | 53 +++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index d3503e4ea..cf8563a16 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -156,6 +156,14 @@ my %status_info = ( RFLASH_FILE_UPLOAD_RESPONSE => { process => \&rflash_response, }, + RFLASH_UPDATE_ACTIVATE_REQUEST => { + method => "PUT", + init_url => "$openbmc_project_url/software", + data => "xyz.openbmc_project.Software.Activation.RequestedActivations.Active", + }, + RFLASH_UPDATE_ACTIVATE_RESPONSE => { + process => \&rflash_response, + }, RINV_REQUEST => { method => "GET", @@ -564,10 +572,19 @@ sub parse_args { # $check = unsupported($callback); if (ref($check) eq "ARRAY") { return $check; } my $filename_passed = 0; + my $updateid_passed = 0; foreach my $opt (@$extrargs) { + print "Examening $opt \n"; # Only files ending on .tar are allowed if ($opt =~ /.*\.tar$/i) { $filename_passed = 1; + print "Opt matches filename ending on .tar \n"; + next; + } + # Check if hex number for the updateid is passed + if ($opt =~ /^[[:xdigit:]]+$/i) { + $updateid_passed = 1; + print "Opt matches hex fileid \n"; next; } if ($filename_passed) { @@ -577,9 +594,17 @@ sub parse_args { } } else { - # Filename was not passed, check flags allowed without file - if ($opt !~ /^-c$|^--check$|^-l$|^--list/) { - return ([ 1, "Invalid option specified: $opt" ]); + if ($updateid_passed) { + # Updateid was passed, check flags allowed with update id + if ($opt !~ /^^-d$|^--delete$|^-a$|^--activate$/) { + return ([ 1, "Invalid option specified when an update id is provided: $opt" ]); + } + } + else { + # Neither Filename nor updateid was not passed, check flags allowed without file or updateid + if ($opt !~ /^-c$|^--check$|^-l$|^--list/) { + return ([ 1, "Invalid option specified: $opt" ]); + } } } } @@ -772,9 +797,11 @@ sub parse_command_status { if ($command eq "rflash") { my $check_version = 0; +<<<<<<< HEAD my $list = 0; my $delete = 0; my $upload = 0; + my $activate = 0; if ($$subcommands[-1] =~ /c|check/) { $check_version = 1; @@ -788,6 +815,9 @@ sub parse_command_status { } elsif ($$subcommands[-1] =~ /u|upload/) { $upload = 1; pop(@$subcommands); + } elsif ($$subcommands[-1] =~ /a|activate/) { + $activate = 1; + pop(@$subcommands); } my $update_file = $$subcommands[0]; @@ -822,7 +852,11 @@ sub parse_command_status { } } else { - # TODO Process file id passed in + # Check if hex number for the updateid is passed + if ($update_file =~ /^[[:xdigit:]]+$/i) { + # Update init_url to include the id of the update to activate + $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_file/attr/RequestedActivation"; + } } } if ($check_version) { @@ -844,6 +878,14 @@ sub parse_command_status { $next_status{LOGIN_RESPONSE} = "RFLASH_FILE_UPLOAD_REQUEST"; $next_status{"RFLASH_FILE_UPLOAD_REQUEST"} = "RFLASH_FILE_UPLOAD_RESPONSE"; } + if ($activate) { + # MG + print "Current value of activate request $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} \n"; + $next_status{LOGIN_RESPONSE} = "RFLASH_UPDATE_ACTIVATE_REQUEST"; + $next_status{"RFLASH_UPDATE_ACTIVATE_REQUEST"} = "RFLASH_UPDATE_ACTIVATE_RESPONSE"; + #xCAT::SvrUtils::sendmsg("Activate option is not yet supported.", $callback); + #return 1; + } } print Dumper(\%next_status) . "\n"; @@ -1797,6 +1839,9 @@ sub rflash_response { } } } + if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_ACTIVATE_RESPONSE") { + print "Update activatiion response\n"; + } if ($next_status{ $node_info{$node}{cur_status} }) { $node_info{$node}{cur_status} = $next_status{ $node_info{$node}{cur_status} }; From a5856dc0cf7987a84ea8c5eff7797eaf2fa2d747 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 26 Jun 2017 14:15:26 -0400 Subject: [PATCH 2/7] rflash activate initial pass --- xCAT-server/lib/xcat/plugins/openbmc.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index cf8563a16..1aee7d803 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1,5 +1,6 @@ #!/usr/bin/perl ## IBM(c) 2017 EPL license http://www.eclipse.org/legal/epl-v10.html +#MG June 26 package xCAT_plugin::openbmc; @@ -164,6 +165,14 @@ my %status_info = ( RFLASH_UPDATE_ACTIVATE_RESPONSE => { process => \&rflash_response, }, + RFLASH_UPDATE_PRIORITY_REQUEST => { + method => "PUT", + init_url => "$openbmc_project_url/software", + data => "xyz.openbmc_project.Software.Activation.RequestedPriority.0", + }, + RFLASH_UPDATE_PRIORITY_RESPONSE => { + process => \&rflash_response, + }, RINV_REQUEST => { method => "GET", @@ -856,6 +865,7 @@ sub parse_command_status { if ($update_file =~ /^[[:xdigit:]]+$/i) { # Update init_url to include the id of the update to activate $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_file/attr/RequestedActivation"; + $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_file/attr/RequestedActivation"; } } } @@ -883,6 +893,8 @@ sub parse_command_status { print "Current value of activate request $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} \n"; $next_status{LOGIN_RESPONSE} = "RFLASH_UPDATE_ACTIVATE_REQUEST"; $next_status{"RFLASH_UPDATE_ACTIVATE_REQUEST"} = "RFLASH_UPDATE_ACTIVATE_RESPONSE"; + $next_status{"RFLASH_UPDATE_ACTIVATE_RESPOSNE"} = "RFLASH_UPDATE_PRIORITY_REQUEST"; + $next_status{"RFLASH_UPDATE_PRIORITY_REQUEST"} = "RFLASH_UPDATE_PRIORITY_RESPONSE"; #xCAT::SvrUtils::sendmsg("Activate option is not yet supported.", $callback); #return 1; } @@ -1840,7 +1852,10 @@ sub rflash_response { } } if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_ACTIVATE_RESPONSE") { - print "Update activatiion response\n"; + print "Update activation response\n"; + } + if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_PRIORITY_RESPONSE") { + print "Update priority response\n"; } if ($next_status{ $node_info{$node}{cur_status} }) { From 0fdeb8279aeed5e9dafe15ff5cf6078dc6103296 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 25 Jul 2017 15:27:23 -0400 Subject: [PATCH 3/7] Activate firmware update and track progress --- xCAT-server/lib/xcat/plugins/openbmc.pm | 52 ++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 1aee7d803..be59875fd 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -165,6 +165,13 @@ my %status_info = ( RFLASH_UPDATE_ACTIVATE_RESPONSE => { process => \&rflash_response, }, + RFLASH_UPDATE_CHECK_STATE_REQUEST => { + method => "GET", + init_url => "$openbmc_project_url/software", + }, + RFLASH_UPDATE_CHECK_STATE_RESPONSE => { + process => \&rflash_response, + }, RFLASH_UPDATE_PRIORITY_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/software", @@ -864,8 +871,10 @@ sub parse_command_status { # Check if hex number for the updateid is passed if ($update_file =~ /^[[:xdigit:]]+$/i) { # Update init_url to include the id of the update to activate + # MG $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_file/attr/RequestedActivation"; - $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_file/attr/RequestedActivation"; + # Update init_url to include the id of the update to check state + $status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{init_url} .= "/$update_file"; } } } @@ -893,8 +902,8 @@ sub parse_command_status { print "Current value of activate request $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} \n"; $next_status{LOGIN_RESPONSE} = "RFLASH_UPDATE_ACTIVATE_REQUEST"; $next_status{"RFLASH_UPDATE_ACTIVATE_REQUEST"} = "RFLASH_UPDATE_ACTIVATE_RESPONSE"; - $next_status{"RFLASH_UPDATE_ACTIVATE_RESPOSNE"} = "RFLASH_UPDATE_PRIORITY_REQUEST"; - $next_status{"RFLASH_UPDATE_PRIORITY_REQUEST"} = "RFLASH_UPDATE_PRIORITY_RESPONSE"; + $next_status{"RFLASH_UPDATE_ACTIVATE_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST"; + $next_status{"RFLASH_UPDATE_CHECK_STATE_REQUEST"} = "RFLASH_UPDATE_CHECK_STATE_RESPONSE"; #xCAT::SvrUtils::sendmsg("Activate option is not yet supported.", $callback); #return 1; } @@ -1852,10 +1861,41 @@ sub rflash_response { } } if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_ACTIVATE_RESPONSE") { - print "Update activation response\n"; + # We get here after the activation of the image file. No processing. Just a landing spot } - if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_PRIORITY_RESPONSE") { - print "Update priority response\n"; + if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_CHECK_STATE_RESPONSE") { + my $activation_state; + my $progress_state; + my $priority_state; + foreach my $key_url (keys %{$response_info->{data}}) { + my $content = ${ $response_info->{data} }{$key_url}; + # Get values of some attributes to determine activation status + if ($key_url eq "Activation") { + $activation_state = ${ $response_info->{data} }{$key_url}; + } + if ($key_url eq "Progress") { + $progress_state = ${ $response_info->{data} }{$key_url}; + } + if ($key_url eq "Priority") { + $priority_state = ${ $response_info->{data} }{$key_url}; + } + } + + if ($activation_state eq "xyz.openbmc_project.Software.Activation.Activations.Active" && $priority_state eq "0") { + # Activation state of active and priority of 0 indicates the avtivation has been completed + xCAT::SvrUtils::sendmsg("Firmware update successfully activated", $callback, $node); + $wait_node_num--; + return; + } + + if ($activation_state eq "xyz.openbmc_project.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); + + # 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 ($next_status{ $node_info{$node}{cur_status} }) { From 58e4523258236bdc41713b9413bf1c4d71699806 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 27 Jul 2017 15:17:05 -0400 Subject: [PATCH 4/7] openbmc Host firmware update activation --- xCAT-server/lib/xcat/plugins/openbmc.pm | 67 ++++++++++++++++--------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index be59875fd..ab171aac2 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1,6 +1,5 @@ #!/usr/bin/perl ## IBM(c) 2017 EPL license http://www.eclipse.org/legal/epl-v10.html -#MG June 26 package xCAT_plugin::openbmc; @@ -172,12 +171,12 @@ my %status_info = ( RFLASH_UPDATE_CHECK_STATE_RESPONSE => { process => \&rflash_response, }, - RFLASH_UPDATE_PRIORITY_REQUEST => { + RFLASH_SET_PRIORITY_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/software", - data => "xyz.openbmc_project.Software.Activation.RequestedPriority.0", + data => "false", # Priority state of 0 sets image to active }, - RFLASH_UPDATE_PRIORITY_RESPONSE => { + RFLASH_SET_PRIORITY_RESPONSE => { process => \&rflash_response, }, @@ -583,10 +582,6 @@ sub parse_args { return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "rflash") { - # - # disable function until fully tested - # - $check = unsupported($callback); if (ref($check) eq "ARRAY") { return $check; } my $filename_passed = 0; my $updateid_passed = 0; foreach my $opt (@$extrargs) { @@ -870,10 +865,9 @@ sub parse_command_status { else { # Check if hex number for the updateid is passed if ($update_file =~ /^[[:xdigit:]]+$/i) { - # Update init_url to include the id of the update to activate - # MG - $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_file/attr/RequestedActivation"; - # Update init_url to include the id of the update to check state + # Update init_url to include the id of the update + $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"; } } @@ -898,14 +892,17 @@ sub parse_command_status { $next_status{"RFLASH_FILE_UPLOAD_REQUEST"} = "RFLASH_FILE_UPLOAD_RESPONSE"; } if ($activate) { - # MG - print "Current value of activate request $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} \n"; + # Activation of an update was requested. + # First we query the update image for its Activation state. If image is in "Ready" we + # need to set "RequestedActivation" attribute to "Active". If image is in "Active" we + # need to set "Priority" to 0. $next_status{LOGIN_RESPONSE} = "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"; - #xCAT::SvrUtils::sendmsg("Activate option is not yet supported.", $callback); - #return 1; + + $next_status{"RFLASH_SET_PRIORITY_REQUEST"} = "RFLASH_SET_PRIORITY_RESPONSE"; + $next_status{"RFLASH_SET_PRIORITY_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST"; } } @@ -1800,10 +1797,11 @@ sub rflash_response { my $update_activation; my $update_purpose; my $update_version; + my $update_priority = -1; if ($node_info{$node}{cur_status} eq "RFLASH_LIST_RESPONSE") { # Display "list" option header and data - xCAT::SvrUtils::sendmsg("ID Purpose State Version", $callback, $node); + xCAT::SvrUtils::sendmsg("ID Purpose State Version", $callback, $node); xCAT::SvrUtils::sendmsg("-" x 55, $callback, $node); foreach my $key_url (keys %{$response_info->{data}}) { @@ -1819,7 +1817,15 @@ sub rflash_response { if (defined($content{Purpose}) and $content{Purpose}) { $update_purpose = (split(/\./, $content{Purpose}))[ -1 ]; } - xCAT::SvrUtils::sendmsg(sprintf("%-8s %-7s %-8s %s", $update_id, $update_purpose, $update_activation, $update_version), $callback, $node); + if (defined($content{Priority})) { + $update_priority = (split(/\./, $content{Priority}))[ -1 ]; + } + # Priority attribute of 0 indicates the "really" active update image + if ($update_priority == 0) { + $update_activation = $update_activation . "(*)"; + $update_priority = -1; # Reset update priority for next loop iteration + } + xCAT::SvrUtils::sendmsg(sprintf("%-8s %-7s %-10s %s", $update_id, $update_purpose, $update_activation, $update_version), $callback, $node); } xCAT::SvrUtils::sendmsg("", $callback, $node); #Separate output in case more than 1 endpoint } @@ -1861,7 +1867,10 @@ sub rflash_response { } } if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_ACTIVATE_RESPONSE") { - # We get here after the activation of the image file. No processing. Just a landing spot + xCAT::SvrUtils::sendmsg("rflash started, please wait...", $callback, $node); + } + if ($node_info{$node}{cur_status} eq "RFLASH_SET_PRIORITY_RESPONSE") { + print "Update priority has been set"; } if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_CHECK_STATE_RESPONSE") { my $activation_state; @@ -1881,14 +1890,22 @@ sub rflash_response { } } - if ($activation_state eq "xyz.openbmc_project.Software.Activation.Activations.Active" && $priority_state eq "0") { - # Activation state of active and priority of 0 indicates the avtivation has been completed - xCAT::SvrUtils::sendmsg("Firmware update successfully activated", $callback, $node); - $wait_node_num--; - return; + if ($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); + $wait_node_num--; + return; + } + 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"; + $next_status{ $node_info{$node}{cur_status} } = "RFLASH_SET_PRIORITY_REQUEST"; + } } - if ($activation_state eq "xyz.openbmc_project.Software.Activation.Activations.Activating") { + #if ($activation_state eq "xyz.openbmc_project.Software.Activation.Activations.Activating") { + if ($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); From 711f1549db08e318df02abf8885e9e7c155ab328 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 27 Jul 2017 15:27:36 -0400 Subject: [PATCH 5/7] OpenBMC host firmware activation 2 --- xCAT-server/lib/xcat/plugins/openbmc.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index ab171aac2..153792d88 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -808,7 +808,6 @@ sub parse_command_status { if ($command eq "rflash") { my $check_version = 0; -<<<<<<< HEAD my $list = 0; my $delete = 0; my $upload = 0; From 1d9909e074e936acd6f8b378d2a3165f3d5d4800 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 1 Aug 2017 12:01:21 -0400 Subject: [PATCH 6/7] Updates from review --- .../admin-guides/references/man1/rflash.1.rst | 43 +++++++++-- perl-xCAT/xCAT/Usage.pm | 6 +- xCAT-client/pods/man1/rflash.1.pod | 27 ++++++- xCAT-server/lib/xcat/plugins/openbmc.pm | 74 +++++++++---------- 4 files changed, 103 insertions(+), 47 deletions(-) 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 4c69921d0..5f688c7ac 100644 --- a/docs/source/guides/admin-guides/references/man1/rflash.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rflash.1.rst @@ -46,13 +46,20 @@ NeXtScale FPC specific: \ **rflash**\ \ *noderange*\ \ *http_directory*\ -OpenPOWER BMC specific: -======================= +OpenPOWER BMC specific (using IPMI): +==================================== \ **rflash**\ \ *noderange*\ [\ *hpm_file_path*\ | \ **-d=**\ \ *data_directory*\ ] [\ **-c | -**\ **-check**\ ] [\ **-**\ **-retry=**\ \ *count*\ ] [\ **-V**\ ] +OpenPOWER OpenBMC specific : +============================ + + +\ **rflash**\ \ *noderange*\ [\ *tar_file_path*\ | \ *image_id*\ ] [\ **-c | -**\ **-check**\ ] [\ **-a | -**\ **-activate**\ ] [\ **-l | -**\ **-list**\ ] [\ **-u | -**\ **-upload**\ ] + + ******************* \ **Description**\ @@ -118,14 +125,22 @@ NeXtScale FPC specific: The command will update firmware for NeXtScale FPC when given an FPC node and the http information needed to access the firmware. The http information required includes both the MN IP address as well as the directory containing the firmware. It is recommended that the firmware be downloaded and placed in the /install directory structure as the xCAT MN /install directory is configured with the correct permissions for http. Refer to the doc to get more details: XCAT_NeXtScale_Clusters -OpenPOWER specific: -=================== +OpenPOWER specific (using IPMI): +================================ The command will update firmware for OpenPOWER BMC when given an OpenPOWER node and either the hpm formatted file path or path to a data directory. \ **Note:**\ When using \ **rflash**\ in hierarchical environment, the hpm file or data directory must be accessible from Service Nodes. +OpenPOWER OpenBMC specific: +=========================== + + +The command will update firmware for OpenPOWER OpenBMC when given an OpenPOWER node and either an update .tar file or an uploaded image id. +\ **Note:**\ When using \ **rflash**\ in hierarchical environment, the .tar file must be accessible from Service Nodes. + + *************** \ **Options**\ @@ -141,7 +156,7 @@ The command will update firmware for OpenPOWER BMC when given an OpenPOWER node \ **-c|-**\ **-check**\ - Check the firmware version of BMC and HPM file. + Check the firmware version of BMC and an update file. @@ -187,6 +202,24 @@ The command will update firmware for OpenPOWER BMC when given an OpenPOWER node +\ **-a|-**\ **-activate**\ + + Activate update image. Image id must be specified. + + + +\ **-l|-**\ **-list**\ + + List currently uploaded update images. "(\*)" indicates currently active image. + + + +\ **-u|-**\ **-upload**\ + + Upload update image. Specified file must be in .tar format. + + + \ **-v|-**\ **-version**\ Displays the command's version. diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 82ac2eff8..6df950099 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -342,8 +342,10 @@ my %usage = ( rflash -p [--activate {disruptive|deferred}] [-d ] rflash [--commit | --recover] [-V|--verbose] rflash [--bpa_acdl] - PPC64LE (using BMC Management) specific: - rflash [-c | --check] [--retry=] [-V] [|-d=]", + PPC64LE (using IPMI Management) specific: + rflash [-c|--check] [--retry=] [-V] [|-d=] + PPC64LE (using OpenBMC Management) specific: + rflash [-c|--check] [-l|--list] [-a|--activate] [-u|--upload] [|]", "mkhwconn" => "Usage: mkhwconn [-h|--help] diff --git a/xCAT-client/pods/man1/rflash.1.pod b/xCAT-client/pods/man1/rflash.1.pod index 9f0cf29f4..283b35381 100644 --- a/xCAT-client/pods/man1/rflash.1.pod +++ b/xCAT-client/pods/man1/rflash.1.pod @@ -22,10 +22,14 @@ B I {B<--commit>|B<--recover>} B I I -=head2 OpenPOWER BMC specific: +=head2 OpenPOWER BMC specific (using IPMI): B I [I | B<-d=>I] [B<-c>|B<--check>] [B<--retry=>I] [B<-V>] +=head2 OpenPOWER OpenBMC specific : + +B I [I | I] [B<-c>|B<--check>] [B<-a>|B<--activate>] [B<-l>|B<--list>] [B<-u>|B<--upload>] + =head1 B The B command initiates Firmware updates on supported xCAT nodes. Licensed Internal Code (also known as microcode) updates are performed on supported HMC-attached POWER5 and POWER6 pSeries nodes, and POWER7 systems using Direct FSP management. @@ -79,11 +83,16 @@ For more details about the Firmware Update using Direct FSP/BPA Management, refe The command will update firmware for NeXtScale FPC when given an FPC node and the http information needed to access the firmware. The http information required includes both the MN IP address as well as the directory containing the firmware. It is recommended that the firmware be downloaded and placed in the /install directory structure as the xCAT MN /install directory is configured with the correct permissions for http. Refer to the doc to get more details: XCAT_NeXtScale_Clusters -=head2 OpenPOWER specific: +=head2 OpenPOWER specific (using IPMI): The command will update firmware for OpenPOWER BMC when given an OpenPOWER node and either the hpm formatted file path or path to a data directory. B When using B in hierarchical environment, the hpm file or data directory must be accessible from Service Nodes. +=head2 OpenPOWER OpenBMC specific: + +The command will update firmware for OpenPOWER OpenBMC when given an OpenPOWER node and either an update .tar file or an uploaded image id. +B When using B in hierarchical environment, the .tar file must be accessible from Service Nodes. + =head1 B =over 7 @@ -94,7 +103,7 @@ Writes the command's usage statement to standard output. =item B<-c|--check> -Check the firmware version of BMC and HPM file. +Check the firmware version of BMC and an update file. =item B<-p> I @@ -124,6 +133,18 @@ Used to recover the flash image in the permanent side of the chip to the tempora 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. +=item B<-a|--activate> + +Activate update image. Image id must be specified. + +=item B<-l|--list> + +List currently uploaded update images. "(*)" indicates currently active image. + +=item B<-u|--upload> + +Upload update image. Specified file must be in .tar format. + =item B<-v|--version> Displays the command's version. diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 153792d88..f818b678a 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -584,40 +584,42 @@ sub parse_args { } elsif ($command eq "rflash") { my $filename_passed = 0; my $updateid_passed = 0; + my $option_flag; foreach my $opt (@$extrargs) { - print "Examening $opt \n"; # Only files ending on .tar are allowed if ($opt =~ /.*\.tar$/i) { $filename_passed = 1; - print "Opt matches filename ending on .tar \n"; next; } # Check if hex number for the updateid is passed if ($opt =~ /^[[:xdigit:]]+$/i) { $updateid_passed = 1; - print "Opt matches hex fileid \n"; next; } - if ($filename_passed) { - # Filename was passed, check flags allowed with file - if ($opt !~ /^-c$|^--check$|^-d$|^--delete$|^-u$|^--upload$/) { - return ([ 1, "Invalid option specified when a file is provided: $opt" ]); + # check if option starting with - was passed + if ($opt =~ /^-/) { + $option_flag = $opt; + } + } + if ($filename_passed) { + # Filename was passed, check flags allowed with file + if ($option_flag !~ /^-c$|^--check$|^-d$|^--delete$|^-u$|^--upload$/) { + return ([ 1, "Invalid option specified when a file is provided: $option_flag" ]); + } + } + else { + if ($updateid_passed) { + # Updateid was passed, check flags allowed with update id + if ($option_flag !~ /^^-d$|^--delete$|^-a$|^--activate$/) { + return ([ 1, "Invalid option specified when an update id is provided: $option_flag" ]); } } else { - if ($updateid_passed) { - # Updateid was passed, check flags allowed with update id - if ($opt !~ /^^-d$|^--delete$|^-a$|^--activate$/) { - return ([ 1, "Invalid option specified when an update id is provided: $opt" ]); - } - } - else { - # Neither Filename nor updateid was not passed, check flags allowed without file or updateid - if ($opt !~ /^-c$|^--check$|^-l$|^--list/) { - return ([ 1, "Invalid option specified: $opt" ]); - } - } - } + # Neither Filename nor updateid was not passed, check flags allowed without file or updateid + if ($option_flag !~ /^-c$|^--check$|^-l$|^--list/) { + return ([ 1, "Invalid option specified: $option_flag" ]); + } + } } } else { return ([ 1, "Command is not supported." ]); @@ -812,25 +814,24 @@ sub parse_command_status { my $delete = 0; my $upload = 0; my $activate = 0; + my $update_file; - if ($$subcommands[-1] =~ /c|check/) { - $check_version = 1; - pop(@$subcommands); - } elsif ($$subcommands[-1] =~ /l|list/) { - $list = 1; - pop(@$subcommands); - } elsif ($$subcommands[-1] =~ /d|delete/) { - $delete = 1; - pop(@$subcommands); - } elsif ($$subcommands[-1] =~ /u|upload/) { - $upload = 1; - pop(@$subcommands); - } elsif ($$subcommands[-1] =~ /a|activate/) { - $activate = 1; - pop(@$subcommands); + foreach $subcommand (@$subcommands) { + if ($subcommand =~ /-c|--check/) { + $check_version = 1; + } elsif ($subcommand =~ /-l|--list/) { + $list = 1; + } elsif ($subcommand =~ /-d|--delete/) { + $delete = 1; + } elsif ($subcommand =~ /-u|--upload/) { + $upload = 1; + } elsif ($subcommand =~ /-a|--activate/) { + $activate = 1; + } else { + $update_file = $subcommand; + } } - my $update_file = $$subcommands[0]; my $filename = undef; my $file_id = undef; my $grep_cmd = "/usr/bin/grep -a"; @@ -1903,7 +1904,6 @@ sub rflash_response { } } - #if ($activation_state eq "xyz.openbmc_project.Software.Activation.Activations.Activating") { if ($activation_state =~ /Software.Activation.Activations.Activating/) { # Activation still going, sleep for a bit, then print the progress value sleep(15); From 92a927e214287ce61cfd244afe85f7150cc29f75 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 2 Aug 2017 15:00:10 -0400 Subject: [PATCH 7/7] disable rflash command for normal user and check error state --- xCAT-server/lib/xcat/plugins/openbmc.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index f818b678a..c97cfc7b8 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -582,6 +582,11 @@ sub parse_args { return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "rflash") { + # + # disable function until fully supported by openbmc + # Currently waiting for issue https://github.com/openbmc/openbmc/issues/2074 to be fixed + # + $check = unsupported($callback); if (ref($check) eq "ARRAY") { return $check; } my $filename_passed = 0; my $updateid_passed = 0; my $option_flag; @@ -1890,6 +1895,11 @@ 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/) { if (scalar($priority_state) == 0) { # Activation state of active and priority of 0 indicates the activation has been completed