From d6a2ba2bf03fce3b5b1b8ae1ed2cac4f1a315635 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 17 Oct 2017 14:52:20 -0400 Subject: [PATCH 1/3] Add code to support parsing the IDs that are returned by the functional endpoint, which marks the firmware IDs that are REALLY active on the server. --- xCAT-server/lib/xcat/plugins/openbmc.pm | 31 +++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index cd127bc6d..346010984 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -2077,6 +2077,23 @@ sub rflash_response { my $update_priority = -1; if ($node_info{$node}{cur_status} eq "RFLASH_LIST_RESPONSE") { + # + # Get the functional IDs to accurately mark the active running FW + # + my %functional; + if (${ $response_info->{data} }{'/xyz/openbmc_project/software/functional'} ) { + my %func_data = %{ ${ $response_info->{data} }{'/xyz/openbmc_project/software/functional'} }; + foreach my $fw_idx (keys $func_data{endpoints}) { + my $fw_id = (split(/\//, $func_data{endpoints}[$fw_idx]))[-1]; + $functional{$fw_id} = 1; + } + } + + if (!%functional) { + # Inform users that the older firmware levels does not correctly reflect Active version + xCAT::SvrUtils::sendmsg("WARNING, The active firmware does not allow correct detecting of running firmware.", $callback, $node); + } + # Display "list" option header and data xCAT::SvrUtils::sendmsg("ID Purpose State Version", $callback, $node); xCAT::SvrUtils::sendmsg("-" x 55, $callback, $node); @@ -2101,9 +2118,19 @@ sub rflash_response { if (defined($content{Priority})) { $update_priority = (split(/\./, $content{Priority}))[ -1 ]; } - # Priority attribute of 0 indicates the "really" active update image - if ($update_priority == 0) { + if (exists($functional{$update_id}) ) { + # + # If the firmware ID exists in the hash, this indicates the really active running FW + # $update_activation = $update_activation . "(*)"; + } elsif ($update_priority == 0) { + # Priority attribute of 0 indicates the firmware to be activated on next boot + my $indicator = "(+)"; + if (!%functional) { + # cannot detect, so mark firmware as Active + $indicator = "(*)"; + } + $update_activation = $update_activation . $indicator; $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); From 8ac06ef33513119e0efabc757ab42806a34f83b4 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 17 Oct 2017 15:07:41 -0400 Subject: [PATCH 2/3] To reuse the code to obtain functional software IDs, move the code to extract IDs into a function to be used by rinv response. --- xCAT-server/lib/xcat/plugins/openbmc.pm | 51 +++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 346010984..b2d9e2b0e 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1076,6 +1076,37 @@ sub parse_command_status { return; } +#------------------------------------------------------- +# +#=head3 get_functional_software_ids +# +# Checks if the FW response data contains "functional" which +# indicates the actual software version currently running on +# the Server. +# +# Returns: reference to hash +# +# =cut +# +#------------------------------------------------------- +sub get_functional_software_ids { + my $response = shift; + my %functional; + + # + # Get the functional IDs to accurately mark the active running FW + # + if (${ $response->{data} }{'/xyz/openbmc_project/software/functional'} ) { + my %func_data = %{ ${ $response->{data} }{'/xyz/openbmc_project/software/functional'} }; + foreach my $fw_idx (keys $func_data{endpoints}) { + my $fw_id = (split(/\//, $func_data{endpoints}[$fw_idx]))[-1]; + $functional{$fw_id} = 1; + } + } + + return \%functional; +} + #------------------------------------------------------- =head3 parse_node_info @@ -2077,21 +2108,11 @@ sub rflash_response { my $update_priority = -1; if ($node_info{$node}{cur_status} eq "RFLASH_LIST_RESPONSE") { - # # Get the functional IDs to accurately mark the active running FW - # - my %functional; - if (${ $response_info->{data} }{'/xyz/openbmc_project/software/functional'} ) { - my %func_data = %{ ${ $response_info->{data} }{'/xyz/openbmc_project/software/functional'} }; - foreach my $fw_idx (keys $func_data{endpoints}) { - my $fw_id = (split(/\//, $func_data{endpoints}[$fw_idx]))[-1]; - $functional{$fw_id} = 1; - } - } - - if (!%functional) { + my $functional = get_functional_software_ids($response_info); + if (!%{$functional}) { # Inform users that the older firmware levels does not correctly reflect Active version - xCAT::SvrUtils::sendmsg("WARNING, The active firmware does not allow correct detecting of running firmware.", $callback, $node); + xCAT::SvrUtils::sendmsg("WARNING, The current firmware version is unable to detect running firmware version.", $callback, $node); } # Display "list" option header and data @@ -2118,7 +2139,7 @@ sub rflash_response { if (defined($content{Priority})) { $update_priority = (split(/\./, $content{Priority}))[ -1 ]; } - if (exists($functional{$update_id}) ) { + if (exists($functional->{$update_id}) ) { # # If the firmware ID exists in the hash, this indicates the really active running FW # @@ -2126,7 +2147,7 @@ sub rflash_response { } elsif ($update_priority == 0) { # Priority attribute of 0 indicates the firmware to be activated on next boot my $indicator = "(+)"; - if (!%functional) { + if (!%{$functional}) { # cannot detect, so mark firmware as Active $indicator = "(*)"; } From c5f55c3a1ebd263b984038d8665283e116432e70 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 17 Oct 2017 15:56:46 -0400 Subject: [PATCH 3/3] Add support for displaying the really active running firmware on the rinv output (non verbose) --- xCAT-server/lib/xcat/plugins/openbmc.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index b2d9e2b0e..5463a95f2 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1532,6 +1532,9 @@ sub rinv_response { my $content_info; my @sorted_output; + # Get the functional IDs to accurately mark the active running FW + my $functional = get_functional_software_ids($response_info); + foreach my $key_url (keys %{$response_info->{data}}) { my %content = %{ ${ $response_info->{data} }{$key_url} }; @@ -1549,16 +1552,20 @@ sub rinv_response { # # For 'rinv firm', only print Active software, unless verbose is specified # - if (($activation_value =~ "Active" and $priority_value == 0) or $::VERBOSE) { + if ( (%{$functional} and exists($functional->{$sw_id}) ) or + (!%{$functional} and $activation_value =~ "Active" and $priority_value == 0) or + $::VERBOSE ) { # # The space below between "Firmware Product Version:" and $content{Version} is intentional # to cause the sorting of this line before any additional info lines # $content_info = "$purpose_value Firmware Product: $content{Version} ($activation_value)"; - if ($priority_value == 0) { - # For now, indicate priority 0 software levels with an '*' - $content_info .= "*"; + my $indicator = "*"; + if ($priority_value == 0 and %{$functional} and !exists($functional->{$sw_id})) { + # indicate that a reboot is needed if priority = 0 and it's not in the functional list + $indicator = "+"; } + $content_info .= $indicator; push (@sorted_output, $content_info); if (defined($content{ExtendedVersion}) and $content{ExtendedVersion} ne "") { @@ -2112,7 +2119,7 @@ sub rflash_response { my $functional = get_functional_software_ids($response_info); if (!%{$functional}) { # Inform users that the older firmware levels does not correctly reflect Active version - xCAT::SvrUtils::sendmsg("WARNING, The current firmware version is unable to detect running firmware version.", $callback, $node); + xCAT::SvrUtils::sendmsg("WARNING, The current firmware is unable to detect running firmware version.", $callback, $node); } # Display "list" option header and data