From b934d44e0c0abed75b29ce5578f76cba51fa4e0a Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 30 Nov 2017 15:43:08 -0500 Subject: [PATCH] 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; }