From eaf05c0588e595d2f635c6bae867db5f15c3b034 Mon Sep 17 00:00:00 2001
From: rearcher <123781007@qq.com>
Date: Sun, 24 Dec 2023 21:01:19 +0800
Subject: [PATCH] fix log error

---
 zeus/host_manager/view.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/zeus/host_manager/view.py b/zeus/host_manager/view.py
index 30d05a3..d13868c 100644
--- a/zeus/host_manager/view.py
+++ b/zeus/host_manager/view.py
@@ -139,6 +139,10 @@ class GetHostStatus(BaseResponse):
         """
         status_code, host_infos = callback.get_host_ssh_info(params)
 
+        result_list = []
+        if len(host_infos) == 0:
+            return self.response(code=status_code, data=result_list)
+
         multi_thread_handler = MultiThreadHandler(lambda p: self.get_host_status(p), host_infos, None)
         multi_thread_handler.create_thread()
         result_list = multi_thread_handler.get_result()
@@ -457,13 +461,16 @@ def verify_ssh_login_info(ssh_login_info: ClientConnectArgs) -> str:
         )
         client.close()
     except socket.error as error:
-        LOGGER.error(error)
+        LOGGER.info(f"Failed to connect to host %s: %s", ssh_login_info.host_ip, error)
         return state.SSH_CONNECTION_ERROR
     except SSHException as error:
-        LOGGER.error(error)
+        LOGGER.info(f"Failed to connect to host %s: %s", ssh_login_info.host_ip, error)
+        return state.SSH_AUTHENTICATION_ERROR
+    except IndexError:
+        LOGGER.error(f"Failed to connect to host %s because the pkey of the host are missing", ssh_login_info.host_ip)
         return state.SSH_AUTHENTICATION_ERROR
     except Exception as error:
-        LOGGER.error(error)
+        LOGGER.error(f"Failed to connect to host %s: %s", ssh_login_info.host_ip, error)
         return state.SSH_CONNECTION_ERROR
 
     return state.SUCCEED
-- 
Gitee

