From 5f2692ab3518f874647306319264420032eef149 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 30 Nov 2017 14:57:57 -0500 Subject: [PATCH 1/3] When there is a problem with the login, do not hide the message on debug mode. BMCReady does not make sense if the admin does not know how to find that state --- xCAT-server/lib/xcat/plugins/openbmc.pm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 4880ffcf6..6d7d6f85f 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -685,7 +685,7 @@ sub process_request { foreach my $node (keys %node_info) { if (!$valid_nodes{$node}) { - xCAT::SvrUtils::sendmsg([1, "BMC did not respond. Verify BMC is in BMCReady state and retry the command."], $callback, $node); + xCAT::SvrUtils::sendmsg([1, "BMC did not respond. Validate BMC configuration and retry the command."], $callback, $node); $wait_node_num--; } else { $login_url = "$http_protocol://$node_info{$node}{bmc}/login"; @@ -1844,10 +1844,7 @@ sub login_logout_request { my $login_response = $brower->request($login_request); if ($login_response->status_line =~ /500 Can't connect to/ or $login_response->status_line =~ /500 read timeout/) { - if ($xcatdebugmode) { - my $debug_info = "LOGIN Failed using curl command"; - process_debug_info($node, $debug_info); - } + xCAT::SvrUtils::sendmsg([1 ,"Login to BMC failed. Status: " . $login_response->status_line . "."], $callback, $node); return 1; } From adee11eee99119d001436e7278e3249106554a3f Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 30 Nov 2017 14:58:54 -0500 Subject: [PATCH 2/3] Change function from login_logout_request to login_request, not doing any logout here --- xCAT-server/lib/xcat/plugins/openbmc.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 6d7d6f85f..7da356ca1 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1519,7 +1519,7 @@ sub fork_process_login { sleep(1); $rst = 1; } elsif ($child == 0) { - exit(login_logout_request($node)); + exit(login_request($node)); } else { $login_pid_node{$child} = $node; } @@ -1820,7 +1820,7 @@ sub process_debug_info { #------------------------------------------------------- -=head3 login_logout_request +=head3 login_request Send login request using curl command Input: @@ -1829,7 +1829,7 @@ sub process_debug_info { =cut #------------------------------------------------------- -sub login_logout_request { +sub login_request { my $node = shift; my $login_url = "$http_protocol://" . $node_info{$node}{bmc} . "/login"; From b934d44e0c0abed75b29ce5578f76cba51fa4e0a Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 30 Nov 2017 15:43:08 -0500 Subject: [PATCH 3/3] Check that RC is 200 to prevent unknown issues, handle the response generically --- xCAT-server/lib/xcat/plugins/openbmc.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 7da356ca1..5db90c191 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -441,6 +441,7 @@ $::RESPONSE_OK = "200 OK"; $::RESPONSE_SERVER_ERROR = "500 Internal Server Error"; $::RESPONSE_SERVICE_UNAVAILABLE = "503 Service Unavailable"; $::RESPONSE_FORBIDDEN = "403 Forbidden"; +$::RESPONSE_NOT_FOUND = "404 Not Found"; $::RESPONSE_METHOD_NOT_ALLOWED = "405 Method Not Allowed"; $::RESPONSE_SERVICE_TIMEOUT = "504 Gateway Timeout"; @@ -1843,7 +1844,9 @@ sub login_request { my $login_request = HTTP::Request->new( 'POST', $login_url, $header, $data ); my $login_response = $brower->request($login_request); - if ($login_response->status_line =~ /500 Can't connect to/ or $login_response->status_line =~ /500 read timeout/) { + # 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); return 1; }