diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index bb5506850..62ff7aa7e 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -97,7 +97,7 @@ unless (-d $::XCAT_LOG_DUMP_DIR) { mkpath($::XCAT_LOG_DUMP_DIR); } -# Common logging messages: +# Common logging messages: my $usage_errormsg = "Usage error."; my $reventlog_no_id_resolved_errormsg = "Provide a comma separated list of IDs to be resolved. Example: 'resolved=x,y,z'"; @@ -156,8 +156,8 @@ $::SOFTWARE_URL = "$openbmc_project_url/software"; $::LOGGING_URL = "$openbmc_project_url/logging/entry/#ENTRY_ID#/attr/Resolved"; #------------------------------------------------------- -# The hash table to store method and url for request, -# process function for response +# The hash table to store method and url for request, +# process function for response #------------------------------------------------------- my %status_info = ( @@ -177,7 +177,7 @@ my %status_info = ( }, RBEACON_ON_REQUEST => { method => "PUT", - init_url => "$openbmc_project_url/led/groups/enclosure_identify/attr/Asserted", + init_url => "$openbmc_project_url/led/groups/enclosure_identify/attr/Asserted", data => "true", }, RBEACON_ON_RESPONSE => { @@ -359,7 +359,7 @@ my %status_info = ( }, RPOWER_BMC_STATUS_RESPONSE => { process => \&rpower_response, - }, + }, RPOWER_BMC_CHECK_RESPONSE => { process => \&rpower_response, }, @@ -484,8 +484,8 @@ my %status_info = ( RSPCONFIG_CLEAR_GARD_REQUEST => { method => "POST", init_url => "/org/open_power/control/gard/action/Reset", - data => "[]", - }, + data => "[]", + }, RSPCONFIG_CLEAR_GARD_RESPONSE => { process => \&rspconfig_response, }, @@ -546,7 +546,7 @@ my %status_info = ( }, RSPCONFIG_API_CONFIG_ON_REQUEST => { method => "PUT", - init_url => "$openbmc_project_url", + init_url => "$openbmc_project_url", data => "true", }, RSPCONFIG_API_CONFIG_ON_RESPONSE => { @@ -587,7 +587,7 @@ my %status_info = ( }, ); -# Setup configured subcommand. +# Setup configured subcommand. # Currently only rspconfig is supported and only for boolean commands or attribute settings. # # Usage can also be autogenerated for these commands. However, changes to the xCAT::Usage->usage @@ -853,7 +853,7 @@ sub preprocess_request { $reqcopy->{_xcatpreprocessed}->[0] = 1; push @requests, $reqcopy; } - + return \@requests; } @@ -902,7 +902,7 @@ sub retry_check_times { $node_wait{$node} = time() + $wait_time; return; } - + $node_info{$node}{cur_status} = $request_status; $node_wait{$node} = time() + $wait_time; return; @@ -1022,14 +1022,14 @@ sub process_request { my $info_msg = "Invalid OpenBMC Hostname $node_info{$node}{bmc}, can't set to OpenBMC"; xCAT::SvrUtils::sendmsg([1, $info_msg], $callback, $node); $wait_node_num--; - next; + next; } } - + # All options parsed and validated. Now lock upload and activate processing, so that only one # can continue in case multiples are issued for the same node # - if (($next_status{LOGIN_RESPONSE} eq "RFLASH_FILE_UPLOAD_REQUEST") or + if (($next_status{LOGIN_RESPONSE} eq "RFLASH_FILE_UPLOAD_REQUEST") or ($next_status{LOGIN_RESPONSE} eq "RFLASH_UPDATE_ACTIVATE_REQUEST") or ($next_status{LOGIN_RESPONSE} eq "RFLASH_UPDATE_HOST_ACTIVATE_REQUEST")) { @@ -1039,7 +1039,7 @@ sub process_request { xCAT::SvrUtils::sendmsg([ 1, $lock_msg ], $callback, $node); $node_info{$node}{rst} = $lock_msg; $wait_node_num--; - next; + next; } if ($::VERBOSE) { xCAT::SvrUtils::sendmsg("Acquired the lock for upload and activate process", $callback, $node); @@ -1089,7 +1089,7 @@ rmdir \"/tmp/\$userid\" \n"; } } - while (1) { + while (1) { unless ($wait_node_num) { if ($event_mapping and (ref($event_mapping) ne "HASH")) { xCAT::SvrUtils::sendmsg("$event_mapping, install the OpenBMC RAS package to obtain more details logging messages.", $callback); @@ -1110,7 +1110,7 @@ rmdir \"/tmp/\$userid\" \n"; # In that case check the rflash log file for this node and extract error from there unless ($node_info{$node}{rst}) { my $rflash_log_file = xCAT::Utils->full_path($node.".log", $::XCAT_LOG_RFLASH_DIR); - # Extract the upload error from last line in log file + # Extract the upload error from last line in log file my $upload_error = `tail $rflash_log_file -n1 | grep "$::FAILED_UPLOAD_MSG"`; if ($upload_error) { chomp $upload_error; @@ -1190,7 +1190,7 @@ rmdir \"/tmp/\$userid\" \n"; foreach my $d (@del) { delete $node_wait{$d}; } - } + } $callback->({ errorcode => [$check] }) if ($check); return; @@ -1228,20 +1228,20 @@ sub parse_args { return ([ 1, "Only one option is supported at the same time for $command" ]); } elsif (scalar(@ARGV) >= 2 and $command eq "reventlog") { my $option_s; - GetOptions( 's' => \$option_s ); + GetOptions( 's' => \$option_s ); return ([ 1, "The -s option is not supported for OpenBMC." ]) if ($option_s); if ( "resolved" ~~ @ARGV) { return ([ 1, "$usage_errormsg $reventlog_no_id_resolved_errormsg" ]); } return ([ 1, "Only one option is supported at the same time for $command" ]); - + } elsif (scalar(@ARGV) == 0 and $command =~ /rpower|rspconfig|rflash/) { return ([ 1, "No option specified for $command" ]); - } else { + } else { $subcommand = $ARGV[0]; } - if ($command eq "rbeacon") { + if ($command eq "rbeacon") { unless ($subcommand =~ /^on$|^off$|^stat$/) { return ([ 1, "Only 'on', 'off' or 'stat' are supported for OpenBMC managed nodes."]); } @@ -1266,12 +1266,12 @@ sub parse_args { if ($subcommand =~ /^(\w+)=(.*)/) { my $key = $1; my $value = $2; - if (not $value) { + if (not $value) { return ([ 1, "$usage_errormsg $reventlog_no_id_resolved_errormsg" ]); } my $nodes_num = @$noderange; - if (@$noderange > 1) { + if (@$noderange > 1) { return ([ 1, "Resolving faults over a xCAT noderange is not recommended." ]); } @@ -1385,13 +1385,13 @@ sub parse_args { # Only files ending on .tar are allowed if ($opt =~ /.*\.tar$/i) { $filename_passed = 1; - push (@flash_arguments, $opt); + push (@flash_arguments, $opt); next; } # Check if hex number for the updateid is passed elsif ($opt =~ /^[[:xdigit:]]+$/i) { $updateid_passed = 1; - push (@flash_arguments, $opt); + push (@flash_arguments, $opt); next; } # check if option starting with - was passed @@ -1424,16 +1424,16 @@ sub parse_args { # show options parsed in bypass mode print "DEBUG filename=$filename_passed, updateid=$updateid_passed, options=$option_flag, tar_file_path=@tarball_path, invalid=$invalid_options rflash_arguments=@flash_arguments\n"; - if ($option_flag =~ tr{ }{ } > 0) { + if ($option_flag =~ tr{ }{ } > 0) { unless ($verbose or $option_flag =~/^-d --no-host-reboot$/) { return ([ 1, "Multiple options are not supported. Options specified: $option_flag"]); } } - + if (scalar @flash_arguments > 1) { - if (($option_flag =~ /^-a$|^--activate$|^--delete$/) or ($filename_passed and $option_flag !~ /^-d$/)) { - # Handles: - # - Multiple options not supported to activate/delete at the same time + if (($option_flag =~ /^-a$|^--activate$|^--delete$/) or ($filename_passed and $option_flag !~ /^-d$/)) { + # Handles: + # - Multiple options not supported to activate/delete at the same time # - Filename passed in and option is not -d for directory return ([1, "More than one firmware specified is not supported."]); } elsif ($option_flag =~ /^-d$/) { @@ -1477,13 +1477,13 @@ sub parse_args { return ([ 1, "Invalid firmware specified with $option_flag" ]); } else { return ([ 1, "Invalid option specified" ]); - } + } } else { # 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 with $option_flag: $invalid_options" ]); } - } + } } } else { return ([ 1, "Command is not supported." ]); @@ -1515,7 +1515,7 @@ sub parse_command_status { $next_status{LOGIN_REQUEST} = "LOGIN_RESPONSE"; - if ($command eq "rbeacon") { + if ($command eq "rbeacon") { $subcommand = $$subcommands[0]; if ($subcommand eq "on") { @@ -1576,9 +1576,9 @@ sub parse_command_status { $next_status{RINV_FIRM_RESPONSE}{NO_PENDING} = "RPOWER_BMCREBOOT_REQUEST"; $next_status{RPOWER_BMCREBOOT_REQUEST} = "RPOWER_RESET_RESPONSE"; $status_info{RPOWER_RESET_RESPONSE}{argv} = "$subcommand"; - $status_info{RINV_FIRM_RESPONSE}{check} = 1; + $status_info{RINV_FIRM_RESPONSE}{check} = 1; } - } + } if ($command eq "rinv") { if (defined($$subcommands[0])) { @@ -1619,7 +1619,7 @@ sub parse_command_status { if (defined($::OPENBMC_FW) && ($::OPENBMC_FW < 1738)) { # # In 1738, the endpount URL changed. In order to support the older URL as a work around, allow for a environment - # variable to change this value. + # variable to change this value. # $::RSETBOOT_URL_PATH = "boot_source"; $status_info{RSETBOOT_SET_REQUEST}{init_url} = "$openbmc_project_url/control/host0/$::RSETBOOT_URL_PATH/attr/BootSource"; @@ -1743,8 +1743,8 @@ sub parse_command_status { # Setup chain for query subcommand if ($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{type} eq "action_attribute") { $next_status{LOGIN_RESPONSE} = "RSPCONFIG_API_CONFIG_ACTION_ATTR_QUERY_REQUEST"; - $status_info{RSPCONFIG_API_CONFIG_ACTION_ATTR_QUERY_REQUEST}{init_url} = - $status_info{RSPCONFIG_API_CONFIG_ACTION_ATTR_QUERY_REQUEST}{init_url} . + $status_info{RSPCONFIG_API_CONFIG_ACTION_ATTR_QUERY_REQUEST}{init_url} = + $status_info{RSPCONFIG_API_CONFIG_ACTION_ATTR_QUERY_REQUEST}{init_url} . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{url} . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{query_url}; $next_status{RSPCONFIG_API_CONFIG_ACTION_ATTR_QUERY_REQUEST} = "RSPCONFIG_API_CONFIG_QUERY_RESPONSE"; @@ -1836,11 +1836,11 @@ sub parse_command_status { } else { $next_status{LOGIN_RESPONSE} = "RSPCONFIG_DUMP_DOWNLOAD_REQUEST"; $next_status{RSPCONFIG_DUMP_DOWNLOAD_REQUEST} = "RSPCONFIG_DUMP_DOWNLOAD_RESPONSE"; - $status_info{RSPCONFIG_DUMP_DOWNLOAD_REQUEST}{init_url} =~ s/#ID#/$$subcommands[2]/g; + $status_info{RSPCONFIG_DUMP_DOWNLOAD_REQUEST}{init_url} =~ s/#ID#/$$subcommands[2]/g; $status_info{RSPCONFIG_DUMP_DOWNLOAD_REQUEST}{argv} = $$subcommands[2]; } } else { - # this section handles the dump support where no options are given and xCAT will + # this section handles the dump support where no options are given and xCAT will # # handle the creation, waiting, and download of the dump across a given noderange # Verify directory for download is there unless (-d $::XCAT_LOG_DUMP_DIR) { @@ -1999,7 +1999,7 @@ sub parse_command_status { $tarfile_path =xCAT::Utils->full_path($update_file, $::cwd); } } - # Filename or file id was specified + # Filename or file id was specified if ($update_file =~ /.*\.tar$/) { # Filename ending on .tar was specified if (File::Spec->file_name_is_absolute($update_file)) { @@ -2027,11 +2027,11 @@ sub parse_command_status { 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 (-x $sha512sum_cmd && -x $tr_cmd) { # Save hash id this firmware version should resolve to: @@ -2095,7 +2095,7 @@ sub parse_command_status { if ($streamline) { $::UPLOAD_ACTIVATE_STREAM = 1; if ($nohost_reboot) { - $::RFLASH_STREAM_NO_HOST_REBOOT = 1; + $::RFLASH_STREAM_NO_HOST_REBOOT = 1; $nohost_reboot = 0; } $streamline = 0; @@ -2213,7 +2213,7 @@ sub parse_command_status { $next_status{RPOWER_CHECK_ON_REQUEST} = "RPOWER_CHECK_ON_RESPONSE"; $next_status{RPOWER_CHECK_ON_RESPONSE}{OFF} = "RPOWER_ON_REQUEST"; } - } + } } return; } @@ -2251,9 +2251,9 @@ sub fork_process_login { # #=head3 get_functional_software_ids # -# Checks if the FW response data contains "functional" which -# indicates the actual software version currently running on -# the Server. +# Checks if the FW response data contains "functional" which +# indicates the actual software version currently running on +# the Server. # # Returns: reference to hash # @@ -2267,7 +2267,7 @@ sub get_functional_software_ids { # # Get the functional IDs to accurately mark the active running FW # - if (${ $response->{data} }{'/xyz/openbmc_project/software/functional'} ) { + if (${ $response->{data} }{'/xyz/openbmc_project/software/functional'} ) { my %func_data = %{ ${ $response->{data} }{'/xyz/openbmc_project/software/functional'} }; foreach ( @{$func_data{endpoints}} ) { my $fw_id = (split '/', $_)[-1]; @@ -2358,7 +2358,7 @@ sub parse_node_info { Generate request's information If the node has method itself, use it as request's method. If not, use method %status_info defined. - If the node has cur_url, check whether also has sub_urls. + If the node has cur_url, check whether also has sub_urls. If has, request's url is join cur_url and one in sub_urls(use one at once to check which is needed). If not, use method %status_info defined. use xCAT::OPENBMC->send_request send request @@ -2434,7 +2434,7 @@ sub gen_send_request { =head3 deal_with_response - Check response's status_line and + Check response's status_line and Input: $handle_id: Async return ID with response $response: Async return response @@ -2462,13 +2462,13 @@ sub deal_with_response { $error = "BMC NotReady"; xCAT::SvrUtils::sendmsg($error, $callback, $node); $wait_node_num--; - return; + return; } if ($node_info{$node}{cur_status} eq "RPOWER_BMC_STATUS_RESPONSE" and defined $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} and $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} =~ /bmcstate$/) { retry_check_times($node, "RPOWER_BMC_STATUS_REQUEST", "bmc_conn_check_times", $::BMC_CHECK_INTERVAL, $response->status_line); return; } - + if ($response->status_line eq $::RESPONSE_SERVICE_UNAVAILABLE) { $error = $::RESPONSE_SERVICE_UNAVAILABLE; } elsif ($response->status_line eq $::RESPONSE_METHOD_NOT_ALLOWED) { @@ -2477,13 +2477,13 @@ sub deal_with_response { } else { # Special processing for file upload. At this point we do not know how to # form a proper file upload request. It always fails with "Method not allowed" error. - # If that happens, just assume it worked. + # If that happens, just assume it worked. # TODO remove this block when proper request can be generated - $status_info{ $node_info{$node}{cur_status} }->{process}->($node, $response); + $status_info{ $node_info{$node}{cur_status} }->{process}->($node, $response); return; } } elsif ($response->status_line eq $::RESPONSE_SERVICE_TIMEOUT) { - if ($node_info{$node}{cur_status} eq "RPOWER_RESET_RESPONSE" and defined $status_info{RPOWER_RESET_RESPONSE}{argv} and $status_info{RPOWER_RESET_RESPONSE}{argv} =~ /bmcreboot$/) { + if ($node_info{$node}{cur_status} eq "RPOWER_RESET_RESPONSE" and defined $status_info{RPOWER_RESET_RESPONSE}{argv} and $status_info{RPOWER_RESET_RESPONSE}{argv} =~ /bmcreboot$/) { my $infomsg = "BMC $::POWER_STATE_REBOOT"; xCAT::SvrUtils::sendmsg($infomsg, $callback, $node); if ($::UPLOAD_ACTIVATE_STREAM) { @@ -2492,15 +2492,15 @@ sub deal_with_response { }else{ $wait_node_num--; return; - } + } } $error = $::RESPONSE_SERVICE_TIMEOUT; } else { my $response_info = decode_json $response->content; - # Handle 500 + # Handle 500 if ($response->status_line eq $::RESPONSE_SERVER_ERROR) { $error = "[" . $response->code . "] " . $response_info->{'data'}->{'exception'}; - # Handle 403 + # Handle 403 } elsif ($response->status_line eq $::RESPONSE_FORBIDDEN) { # # For any invalid data that we can detect, provide a better response message @@ -2523,20 +2523,20 @@ sub deal_with_response { } else{ $error = "$::RESPONSE_FORBIDDEN - Requested endpoint does not exist or may indicate function is not yet supported by OpenBMC firmware."; } - # Handle 404 + # Handle 404 } elsif ($response->status_line eq $::RESPONSE_NOT_FOUND) { # # For any invalid data that we can detect, provide a better response message # - if ($node_info{$node}{cur_status} eq "RFLASH_DELETE_IMAGE_RESPONSE") { + if ($node_info{$node}{cur_status} eq "RFLASH_DELETE_IMAGE_RESPONSE") { $error = "Invalid ID provided to delete. Use the -l option to view valid firmware IDs."; - } elsif (($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_QUERY_RESPONSE") || - ($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_ATTR_RESPONSE")) { + } elsif (($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_QUERY_RESPONSE") || + ($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_ATTR_RESPONSE")) { $error = "$::RESPONSE_NOT_FOUND - Requested endpoint does not exist or may indicate function is not supported on this OpenBMC firmware."; } else { $error = "[" . $response->code . "] " . $response_info->{'data'}->{'description'}; } - + } else { $error = "[" . $response->code . "] " . $response_info->{'data'}->{'description'}; } @@ -2586,7 +2586,7 @@ sub process_debug_info { } xCAT::SvrUtils::sendmsg("$flag_debug $debug_msg", $callback, $ts_node); - xCAT::MsgUtils->trace(0, "D", "$flag_debug $node $debug_msg"); + xCAT::MsgUtils->trace(0, "D", "$flag_debug $node $debug_msg"); } #------------------------------------------------------- @@ -2615,7 +2615,7 @@ sub login_request { my $login_response = $brower->request($login_request); # Check the return code - if ($login_response->code eq 500 or $login_response->code eq 404) { + if ($login_response->code eq 500 or $login_response->code eq 404) { # handle only 404 and 504 in this code, defer to deal_with_response for the rest xCAT::SvrUtils::sendmsg([1 ,"[" . $login_response->code . "] Login to BMC failed: " . $login_response->status_line . "."], $callback, $node); return 1; @@ -2669,7 +2669,7 @@ sub rpower_response { my $response_info = decode_json $response->content; - + if ($node_info{$node}{cur_status} eq "RPOWER_ON_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { if ($status_info{RPOWER_ON_RESPONSE}{argv}) { @@ -2961,12 +2961,12 @@ sub rinv_response { # # For 'rinv firm', only print Active software, unless verbose is specified # - if ( (%{$functional} and exists($functional->{$sw_id}) ) or - (!%{$functional} and $activation_value =~ "Active" and $priority_value == 0) or + 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 + # to cause the sorting of this line before any additional info lines # $content_info = "$purpose_value Firmware Product: $content{Version} ($activation_value)"; my $indicator = ""; @@ -2977,12 +2977,12 @@ sub rinv_response { $indicator = "*"; } $content_info .= $indicator; - push (@sorted_output, $content_info); - - if (defined($content{ExtendedVersion}) and $content{ExtendedVersion} ne "") { + push (@sorted_output, $content_info); + + if (defined($content{ExtendedVersion}) and $content{ExtendedVersion} ne "") { # ExtendedVersion is going to be a comma separated list of additional software my @versions = split(',', $content{ExtendedVersion}); - foreach my $ver (@versions) { + foreach my $ver (@versions) { $content_info = "$purpose_value Firmware Product: -- additional info: $ver"; push (@sorted_output, $content_info); } @@ -2994,7 +2994,7 @@ sub rinv_response { if (! defined $content{Present}) { # If the Present field is not part of the attribute, then it's most likely a callout # Do not print as part of the inventory response - next; + next; } # SPECIAL CASE: If 'serial' or 'model' is specified, only return the system level information @@ -3024,7 +3024,7 @@ sub rinv_response { @sorted_output = () if ($status_info{RINV_FIRM_RESPONSE}{check}); # If sorted array has any contents, sort it naturally and print it if (scalar @sorted_output > 0) { - # sort alpha, then numeric + # sort alpha, then numeric foreach (sort natural_sort_cmp @sorted_output) { # # The firmware output requires the ID to be part of the string to sort correctly. @@ -3105,7 +3105,7 @@ sub rsetboot_response { my $node = shift; my $response = shift; - my $response_info = decode_json $response->content; + my $response_info = decode_json $response->content; if ($node_info{$node}{cur_status} eq "RSETBOOT_STATUS_RESPONSE") { my $one_time_enabled; @@ -3170,7 +3170,7 @@ sub rbeacon_response { if ($response_info->{'message'} eq $::RESPONSE_OK) { xCAT::SvrUtils::sendmsg("$::BEACON_STATE_ON", $callback, $node); } - } + } if ($node_info{$node}{cur_status} eq "RBEACON_OFF_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { @@ -3240,7 +3240,7 @@ sub reventlog_response { if ($node_info{$node}{cur_url}) { $next_status{"REVENTLOG_RESOLVED_RESPONSE"} = "REVENTLOG_RESOLVED_REQUEST"; } else { - # Break out of this loop if there are no more IDs to resolve + # Break out of this loop if there are no more IDs to resolve $wait_node_num--; return; } @@ -3264,14 +3264,14 @@ sub reventlog_response { push @{ $status_info{REVENTLOG_RESOLVED_RESPONSE}{remain_entries} }, @entries; } else { - # Return if there are no entries with callout data + # Return if there are no entries with callout data xCAT::SvrUtils::sendmsg("There are no event log entries contributing to LED fault", $callback, $node); $wait_node_num--; return; } } else { my $entry_string = $status_info{REVENTLOG_RESPONSE}{argv}; - my $content_info; + my $content_info; my %output = (); my $entry_num = 0; $entry_string = "all" if ($entry_string eq "0"); @@ -3446,12 +3446,12 @@ sub rspconfig_response { } my ($path, $adapter_id) = (split(/\/ipv4\//, $key_url)); - + if ($adapter_id) { - if ( (defined($content{Origin}) and $content{Origin} =~ /LinkLocal/) or + if ( (defined($content{Origin}) and $content{Origin} =~ /LinkLocal/) or (defined($content{Address}) and $content{Address} =~ /^169.254/) ) { # OpenBMC driver has a interim bug where ZeroConfigIP comes up as DHCP instead of LinkLocal. - # To protect xCAT while the drivers change, check the 169.254 IP also + # To protect xCAT while the drivers change, check the 169.254 IP also if ($xcatdebugmode) { my $debugmsg = "Found LocalLink " . $content{Address} . " for interface " . $key_url . " Ignoring..."; process_debug_info($node, $debugmsg); @@ -3509,13 +3509,13 @@ sub rspconfig_response { if (scalar (keys %nicinfo) == 0) { my $error = "No valid BMC network information"; xCAT::SvrUtils::sendmsg([1, "$error"], $callback, $node); - $node_info{$node}{cur_status} = ""; + $node_info{$node}{cur_status} = ""; } else { my @address = (); my @ipsrc = (); my @netmask = (); my @gateway = (); - my @vlan = (); + my @vlan = (); my @ntpservers = (); my $real_ntp_server = 0; my @nics = keys %nicinfo; @@ -3562,25 +3562,25 @@ sub rspconfig_response { next; } if ($opt eq "ip") { - push @output, @address; + push @output, @address; } elsif ($opt eq "ipsrc") { push @output, @ipsrc; } elsif ($opt eq "netmask") { push @output, @netmask; } elsif ($opt eq "gateway") { - push @output, @gateway; + push @output, @gateway; } elsif ($opt eq "vlan") { push @output, @vlan; } } - + xCAT::SvrUtils::sendmsg("$_", $callback, $node) foreach (@output); if ($multiple_error and $mul_out) { xCAT::SvrUtils::sendmsg([1, "$multiple_error"], $callback, $node); $wait_node_num--; return; } - + if ($grep_string eq "all") { # If all current values equal the input, just print out message my @checks = split("-", $status_info{RSPCONFIG_CHECK_RESPONSE}{argv}); @@ -3625,7 +3625,7 @@ sub rspconfig_response { } } } - + my $origin_type; if ($node_info{$node}{cur_status} eq "RSPCONFIG_CHECK_RESPONSE") { my @checks = split("-", $status_info{RSPCONFIG_CHECK_RESPONSE}{argv}); @@ -3736,7 +3736,7 @@ sub rspconfig_response { } } else { $wait_node_num--; - } + } } #------------------------------------------------------- @@ -3781,9 +3781,9 @@ sub rspconfig_api_config_response { } elsif ($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_ATTR_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("BMC Setting ". - $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . - "... " . + xCAT::SvrUtils::sendmsg("BMC Setting ". + $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . + "... " . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{instruct_msg}, $callback, $node); } else { @@ -3803,7 +3803,7 @@ sub rspconfig_api_config_response { } } } else { - # "data" is not a hash, field contains the value + # "data" is not a hash, field contains the value $value = $response_info->{data}; } if (($value eq "0") || ($value eq "1")) { @@ -3820,7 +3820,7 @@ sub rspconfig_api_config_response { if ($value) { xCAT::SvrUtils::sendmsg($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . " : $last_component", $callback, $node); my $found = grep(/$value/, @valid_values); - if ($found eq 0) { + if ($found eq 0) { # Received data value not expected xCAT::SvrUtils::sendmsg("WARNING: Unexpected value set: $value", $callback, $node); xCAT::SvrUtils::sendmsg("WARNING: Valid values: " . join(",", @valid_values), $callback, $node); @@ -3962,7 +3962,7 @@ sub rspconfig_dump_response { my $id; if (defined $content{Elapsed}) { $id = $key_url; - $id =~ s/.*\///g; + $id =~ s/.*\///g; if ($node_info{$node}{cur_status} eq "RSPCONFIG_DUMP_CHECK_RESPONSE") { if ($id eq $node_info{$node}{dump_id}) { @@ -3976,8 +3976,8 @@ sub rspconfig_dump_response { $mon += 1; $year += 1900; my $UTC_time = sprintf ("%02d/%02d/%04d %02d:%02d:%02d", $mon, $mday, $year, $hour, $min, $sec); - $dump_info{$id} = "[$id] Generated: $UTC_time, Size: $content{Size}"; - + $dump_info{$id} = "[$id] Generated: $UTC_time, Size: $content{Size}"; + if ($::RSPCONFIG_DUMP_DOWNLOAD_ALL_REQUESTED) { # Save dump info for later, when dump download all $node_info{$node}{dump_info}{$id} = "[$id] Generated: $UTC_time, Size: $content{Size}"; @@ -3986,7 +3986,7 @@ sub rspconfig_dump_response { } xCAT::SvrUtils::sendmsg("$::NO_ATTRIBUTES_RETURNED", $callback, $node) if (!%dump_info and $node_info{$node}{cur_status} eq "RSPCONFIG_DUMP_LIST_RESPONSE"); - # If processing the "download all" request, do not print anything now. + # If processing the "download all" request, do not print anything now. # Download function dump_download_process() will be # printing the output for each downloaded dump unless ($::RSPCONFIG_DUMP_DOWNLOAD_ALL_REQUESTED) { @@ -4000,7 +4000,7 @@ sub rspconfig_dump_response { $node_info{$node}{dump_wait_attemp} = $::RSPCONFIG_DUMP_MAX_RETRY; } if ( $node_info{$node}{dump_wait_attemp} > 0) { - $node_info{$node}{dump_wait_attemp} --; + $node_info{$node}{dump_wait_attemp} --; retry_after($node, "RSPCONFIG_DUMP_LIST_REQUEST", $::RSPCONFIG_DUMP_INTERVAL); unless ($node_info{$node}{dump_wait_attemp} % int(8)) { # display message every 8 iterations of the interval xCAT::SvrUtils::sendmsg("Still waiting for dump $node_info{$node}{dump_id} to be generated...", $callback, $node); @@ -4012,7 +4012,7 @@ sub rspconfig_dump_response { return; } } - } + } if ($node_info{$node}{cur_status} eq "RSPCONFIG_DUMP_DOWNLOAD_ALL_RESPONSE") { &dump_download_all_process($node); } @@ -4047,7 +4047,7 @@ sub rspconfig_dump_response { $wait_node_num--; return; } - } + } } if ($node_info{$node}{cur_status} eq "RSPCONFIG_DUMP_CLEAR_RESPONSE") { @@ -4058,7 +4058,7 @@ sub rspconfig_dump_response { my $error_msg = "Could not clear BMC diagnostics successfully (". $response_info->{'message'} . ")"; xCAT::MsgUtils->message("W", { data => ["$node: $error_msg"] }, $callback) if ($next_status{ $node_info{$node}{cur_status} }); } - } + } if ($next_status{ $node_info{$node}{cur_status} }) { $node_info{$node}{cur_status} = $next_status{ $node_info{$node}{cur_status} }; @@ -4197,7 +4197,7 @@ sub rvitals_response { my $grep_string; if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { $grep_string = $status_info{RVITALS_LEDS_RESPONSE}{argv}; - } else { + } else { $grep_string = $status_info{RVITALS_RESPONSE}{argv}; } my $src; @@ -4210,7 +4210,7 @@ sub rvitals_response { my %content = %{ ${ $response_info->{data} }{$key_url} }; my $label = (split(/\//, $key_url))[ -1 ]; - # replace underscore with space, uppercase the first letter + # replace underscore with space, uppercase the first letter $label =~ s/_/ /g; $label =~ s/\b(\w)/\U$1/g; @@ -4221,16 +4221,16 @@ sub rvitals_response { $calc_value = (split(/\./, $content{State}))[-1]; $content_info = $label . ": " . $calc_value ; - if ($key_url =~ "fan0") { $leds{fan0} = $calc_value; } - if ($key_url =~ "fan1") { $leds{fan1} = $calc_value; } - if ($key_url =~ "fan2") { $leds{fan2} = $calc_value; } - if ($key_url =~ "fan3") { $leds{fan3} = $calc_value; } - if ($key_url =~ "front_id") { $leds{front_id} = $calc_value; } - if ($key_url =~ "front_fault") { $leds{front_fault} = $calc_value; } - if ($key_url =~ "front_power") { $leds{front_power} = $calc_value; } - if ($key_url =~ "rear_id") { $leds{rear_id} = $calc_value; } - if ($key_url =~ "rear_fault") { $leds{rear_fault} = $calc_value; } - if ($key_url =~ "rear_power") { $leds{rear_power} = $calc_value; } + if ($key_url =~ "fan0") { $leds{fan0} = $calc_value; } + if ($key_url =~ "fan1") { $leds{fan1} = $calc_value; } + if ($key_url =~ "fan2") { $leds{fan2} = $calc_value; } + if ($key_url =~ "fan3") { $leds{fan3} = $calc_value; } + if ($key_url =~ "front_id") { $leds{front_id} = $calc_value; } + if ($key_url =~ "front_fault") { $leds{front_fault} = $calc_value; } + if ($key_url =~ "front_power") { $leds{front_power} = $calc_value; } + if ($key_url =~ "rear_id") { $leds{rear_id} = $calc_value; } + if ($key_url =~ "rear_fault") { $leds{rear_fault} = $calc_value; } + if ($key_url =~ "rear_power") { $leds{rear_power} = $calc_value; } } else { # print out Sensor info @@ -4238,43 +4238,43 @@ sub rvitals_response { # Skip over attributes that are not asked to be printed # if ($grep_string =~ "temp") { - unless ( $content{Unit} =~ "DegreesC") { next; } - } + unless ( $content{Unit} =~ "DegreesC") { next; } + } if ($grep_string =~ "voltage") { - unless ( $content{Unit} =~ "Volts") { next; } - } + unless ( $content{Unit} =~ "Volts") { next; } + } if ($grep_string =~ "wattage") { - unless ( $content{Unit} =~ "Watts") { next; } - } + unless ( $content{Unit} =~ "Watts") { next; } + } if ($grep_string =~ "fanspeed") { - unless ( $content{Unit} =~ "RPMS") { next; } - } + unless ( $content{Unit} =~ "RPMS") { next; } + } if ($grep_string =~ "power") { - unless ( $content{Unit} =~ "Amperes" || $content{Unit} =~ "Joules" || $content{Unit} =~ "Watts" ) { next; } - } + unless ( $content{Unit} =~ "Amperes" || $content{Unit} =~ "Joules" || $content{Unit} =~ "Watts" ) { next; } + } if ($grep_string =~ "altitude") { unless ( $content{Unit} =~ "Meters" ) { next; } - } + } # # Calculate the adjusted value based on the scale attribute - # + # $calc_value = $content{Value}; if (!defined($calc_value)) { - # Handle the bug where the keyword in the API is lower case value + # Handle the bug where the keyword in the API is lower case value $calc_value = $content{value}; } - if (defined $content{Scale} and $content{Scale} != 0) { + if (defined $content{Scale} and $content{Scale} != 0) { $calc_value = ($content{Value} * (10 ** $content{Scale})); - } + } $content_info = $label . ": " . $calc_value; - if (defined($content{Unit})) { + if (defined($content{Unit})) { $content_info = $content_info . " " . $sensor_units{ $content{Unit} }; } push (@sorted_output, $content_info); #Save output in array - } + } } if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { @@ -4404,7 +4404,7 @@ sub rflash_response { # $update_activation = $update_activation . "(*)"; } elsif ($update_priority == 0) { - # Priority attribute of 0 indicates the firmware to be activated on next boot + # Priority attribute of 0 indicates the firmware to be activated on next boot my $indicator = "(+)"; if (!%{$functional}) { # cannot detect, so mark firmware as Active @@ -4490,7 +4490,7 @@ sub rflash_response { # Special processing for file upload # # Unable to form a proper file upload request to the BMC, it fails with: 405 Method Not Allowed - # For now, always upload using curl commands. + # For now, always upload using curl commands. # # TODO: Remove this block when proper request can be generated # @@ -4545,7 +4545,7 @@ sub rflash_response { if ($version ne $::UPLOAD_FILE_VERSION and $version ne $::UPLOAD_PNOR_VERSION) { next; } - # Get values of some attributes to determine activation status + # Get values of some attributes to determine activation status $activation_state{$version} = $content{Activation}; $progress_state{$version} = $content{Progress}; $priority_state{$version} = $content{Priority}; @@ -4586,11 +4586,11 @@ sub rflash_response { } elsif ($activation_state{$firm_version} =~ /Software.Activation.Activations.Active/) { if (scalar($priority_state{$firm_version}) == 0) { $version_num ++; - my $flash_success_msg = "$node: $firm_msg activation successful."; + my $flash_success_msg = "$node: $firm_msg activation successful."; push @{ $rsp->{data} },$flash_success_msg; # Activation state of active and priority of 0 indicates the activation has been completed - if ( $length == $version_num ) { - xCAT::MsgUtils->message("I", $rsp, $callback) if ($rsp); + if ( $length == $version_num ) { + xCAT::MsgUtils->message("I", $rsp, $callback) if ($rsp); print RFLASH_LOG_FILE_HANDLE "$flash_success_msg\n"; $node_info{$node}{rst} = "$flash_success_msg"; if (!$::UPLOAD_ACTIVATE_STREAM) { @@ -4606,7 +4606,7 @@ sub rflash_response { print "$firm_version update is already active, just need to set priority to 0\n"; if ($::UPLOAD_ACTIVATE_STREAM) { $status_info{RFLASH_SET_PRIORITY_REQUEST}{init_url} = - $::SOFTWARE_URL . "/$update_ids{$firm_version}/attr/Priority"; + $::SOFTWARE_URL . "/$update_ids{$firm_version}/attr/Priority"; } $next_status{ $node_info{$node}{cur_status} } = "RFLASH_SET_PRIORITY_REQUEST"; } @@ -4659,7 +4659,7 @@ sub rflash_response { $found_match = 1; # Found a match of uploaded file version with the image in software/enumerate - # If we have a saved expected hash ID, compare it to the one just found + # If we have a saved expected hash ID, compare it to the one just found if ($::UPLOAD_FILE_HASH_ID && ($::UPLOAD_FILE_HASH_ID ne $update_id)) { xCAT::SvrUtils::sendmsg([1,"Firmware uploaded but activation cancelled due to hash ID mismatch. $update_id does not match expected $::UPLOAD_FILE_HASH_ID. Verify BMC firmware is at the latest level."], $callback, $node); $wait_node_num--; @@ -4774,9 +4774,9 @@ sub rflash_upload { my $curl_error = "$::FAILED_UPLOAD_MSG. Did not receive response from OpenBMC after running command '$curl_login_cmd'"; xCAT::SvrUtils::sendmsg([1, "$curl_error"], $callback, $node); print RFLASH_LOG_FILE_HANDLE "$curl_error\n"; - $node_info{$node}{rst} = "$curl_error"; + $node_info{$node}{rst} = "$curl_error"; return 1; - } + } eval { $h = from_json($curl_login_result) }; # convert command output to hash if ($@) { my $curl_error = "$::FAILED_UPLOAD_MSG. Received wrong format response for command '$curl_login_cmd': $curl_login_result"; @@ -4812,7 +4812,7 @@ sub rflash_upload { if ($xcatdebugmode) { my $debugmsg = "RFLASH_FILE_UPLOAD_RESPONSE: CMD: $upload_cmd"; process_debug_info($node, $debugmsg); - } + } my $curl_upload_result = `$upload_cmd`; if (!$curl_upload_result) { my $curl_error = "$::FAILED_UPLOAD_MSG. Did not receive response from OpenBMC after running command '$upload_cmd'";