From 5bf6e1dc83fe579a4a9d12a4e70ae8d9ece32552 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Sat, 2 Dec 2017 22:49:45 -0500 Subject: [PATCH] Improve the message on the HTTP response --- xCAT-server/lib/xcat/plugins/openbmc.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 093ff906e..75f1d00d5 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1752,8 +1752,10 @@ sub deal_with_response { $error = $::RESPONSE_SERVICE_TIMEOUT; } else { my $response_info = decode_json $response->content; + # Handle 500 if ($response->status_line eq $::RESPONSE_SERVER_ERROR) { - $error = $response_info->{'data'}->{'exception'}; + $error = "[" . $response->code . "] " . $response_info->{'data'}->{'exception'}; + # Handle 403 } elsif ($response->status_line eq $::RESPONSE_FORBIDDEN) { # # For any invalid data that we can detect, provide a better response message @@ -1764,21 +1766,21 @@ sub deal_with_response { } elsif ($node_info{$node}{cur_status} eq "RSETBOOT_ENABLE_RESPONSE" ) { # If 403 is received setting boot method, API endpoint changed in 1738 FW, inform the user of work around. $error = "Invalid endpoint used to set boot method. If running firmware < ibm-v1.99.10-0-r7, 'export XCAT_OPENBMC_FIRMWARE=1736' and retry."; - } else { $error = "$::RESPONSE_FORBIDDEN - Requested endpoint does not exists and may indicate function is not yet supported by OpenBMC firmware."; } - } elsif ($response_info->{'data'}->{'description'} =~ /path or object not found: (.+)/) { + # 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") { $error = "Invalid ID provided to delete. Use the -l option to view valid firmware IDs."; } else { - $error = "Path or object not found: $1"; + $error = "[" . $response->code . "] Path or object not found: $1"; } } else { - $error = $response_info->{'data'}->{'description'}; + $error = "[" . $response->code . "] " . $response_info->{'data'}->{'description'}; } } xCAT::SvrUtils::sendmsg([1, $error], $callback, $node); @@ -1852,7 +1854,7 @@ sub login_request { # Check the return code if ($login_response->code != 200) { # handle the errors generically - xCAT::SvrUtils::sendmsg([1 ,"Login to BMC failed. Status: " . $login_response->status_line . "."], $callback, $node); + xCAT::SvrUtils::sendmsg([1 ,"[" . $login_response->code . "] Login to BMC failed: " . $login_response->status_line . "."], $callback, $node); return 1; }