2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-13 01:40:26 +00:00

Merge pull request #4396 from xuweibj/I4394

Print out error message if receive nothing when uploading firmware file
This commit is contained in:
Mark Gurevich
2017-12-12 13:36:16 -05:00
committed by GitHub

View File

@ -3307,7 +3307,16 @@ sub dump_download_process {
my $curl_dwld_cmd = "curl -J -b $cjar_id -k -H 'Content-Type: application/octet-stream' -X GET $request_url/$down_url -o $file_name";
my $curl_login_result = `$curl_login_cmd -s`;
my $h = from_json($curl_login_result);
my $h;
if (!$curl_login_result) {
xCAT::SvrUtils::sendmsg([1, "Did not receive response from OpenBMC after running command '$curl_login_cmd'"], $callback, $node);
return 1;
}
eval { $h = from_json($curl_login_result) };
if ($@) {
xCAT::SvrUtils::sendmsg([1, "Received wrong format response for command '$curl_login_cmd': $curl_login_result)"], $callback, $node);
return 1;
}
if ($h->{message} eq $::RESPONSE_OK) {
xCAT::SvrUtils::sendmsg("Dump $dump_id generated. Downloading to $file_name", $callback, $node);
my $curl_dwld_result = `$curl_dwld_cmd -s`;
@ -3789,40 +3798,57 @@ sub rflash_upload {
# Try to login
my $curl_login_result = `$curl_login_cmd -s`;
my $h = from_json($curl_login_result); # convert command output to hash
my $h;
if (!$curl_login_result) {
xCAT::SvrUtils::sendmsg([1, "Did not receive response from OpenBMC after running command '$curl_login_cmd'"], $callback, $node);
return 1;
}
eval { $h = from_json($curl_login_result) }; # convert command output to hash
if ($@) {
xCAT::SvrUtils::sendmsg([1, "Received wrong format response for command '$curl_login_cmd': $curl_login_result"], $callback, $node);
return 1;
}
if ($h->{message} eq $::RESPONSE_OK) {
foreach my $upload_cmd(@curl_upload_cmds){
while((my $file,my $version)=each(%fw_tar_files)){
my $uploading_msg = "Uploading $file ...";
# Login successfull, upload the file
if ($::VERBOSE) {
xCAT::SvrUtils::sendmsg("$uploading_msg", $callback, $node);
}
print RFLASH_LOG_FILE_HANDLE "$uploading_msg\n";
foreach my $upload_cmd(@curl_upload_cmds){
while((my $file,my $version)=each(%fw_tar_files)){
my $uploading_msg = "Uploading $file ...";
# Login successfull, upload the file
if ($::VERBOSE) {
xCAT::SvrUtils::sendmsg("$uploading_msg", $callback, $node);
}
print RFLASH_LOG_FILE_HANDLE "$uploading_msg\n";
if ($xcatdebugmode) {
my $debugmsg = "RFLASH_FILE_UPLOAD_RESPONSE: CMD: $upload_cmd";
process_debug_info($node, $debugmsg);
}
my $curl_upload_result = `$upload_cmd`;
$h = from_json($curl_upload_result); # convert command output to hash
if ($h->{message} eq $::RESPONSE_OK) {
# Upload successful, display message
my $upload_success_msg = "Firmware upload successful. Use -l option to list.";
unless ($::UPLOAD_AND_ACTIVATE or $::UPLOAD_ACTIVATE_STREAM) {
xCAT::SvrUtils::sendmsg("$upload_success_msg", $callback, $node);
}
print RFLASH_LOG_FILE_HANDLE "$upload_success_msg\n";
# Try to logoff, no need to check result, as there is nothing else to do if failure
} else {
my $upload_fail_msg = "Failed to upload update file $file :" . $h->{message} . " - " . $h->{data}->{description};
xCAT::SvrUtils::sendmsg("$upload_fail_msg", $callback, $node);
print RFLASH_LOG_FILE_HANDLE "$upload_fail_msg\n";
close (RFLASH_LOG_FILE_HANDLE);
$node_info{$node}{rst} = "$upload_fail_msg";
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) {
xCAT::SvrUtils::sendmsg([1, "Did not receive response from OpenBMC after running command '$upload_cmd'"], $callback, $node);
return 1;
}
eval { $h = from_json($curl_upload_result) }; # convert command output to hash
if ($@) {
xCAT::SvrUtils::sendmsg([1, "Received wrong format response from command '$upload_cmd': $curl_upload_result"], $callback, $node);
return 1;
}
}
}
if ($h->{message} eq $::RESPONSE_OK) {
# Upload successful, display message
my $upload_success_msg = "Firmware upload successful. Use -l option to list.";
unless ($::UPLOAD_AND_ACTIVATE or $::UPLOAD_ACTIVATE_STREAM) {
xCAT::SvrUtils::sendmsg("$upload_success_msg", $callback, $node);
}
print RFLASH_LOG_FILE_HANDLE "$upload_success_msg\n";
# Try to logoff, no need to check result, as there is nothing else to do if failure
} else {
my $upload_fail_msg = "Failed to upload update file $file :" . $h->{message} . " - " . $h->{data}->{description};
xCAT::SvrUtils::sendmsg("$upload_fail_msg", $callback, $node);
print RFLASH_LOG_FILE_HANDLE "$upload_fail_msg\n";
close (RFLASH_LOG_FILE_HANDLE);
$node_info{$node}{rst} = "$upload_fail_msg";
return 1;
}
}
}
# Try to logoff, no need to check result, as there is nothing else to do if failure
my $curl_logout_result = `$curl_logout_cmd -s`;