From 05c4f0df087afa8b95ba5f365a55cee52cdd8d56 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 14:08:34 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=86=85=E6=A0=B8=E6=95=B0?=
 =?UTF-8?q?=E6=8D=AE=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 views/server.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/views/server.py b/views/server.py
index e7570b8..71cbb8e 100644
--- a/views/server.py
+++ b/views/server.py
@@ -181,5 +181,34 @@ def delete_host_info(data):
         DBHelper().execute(sql)
 
     res = {'data': 'success'}
+    json_res = json.dumps(res)
+    return json_res
+
+
+def get_kernel_data(data):
+    """
+    获取系统内核和仓库内核版本
+    :return:
+    """
+    get_kernel_version_sql = 'select agent_ip,agent_kernel,agent_repo_kernel from agent_info where ' \
+                             'agent_online_status=0 and repo_status=0 and agent_storage>=10 and ' \
+                             'agent_migration_os is null;'
+    data = DBHelper().execute(get_kernel_version_sql).fetchall()
+    res = {}
+    info_list = []
+    info_dict_keys_list = ['agent_ip', 'agent_kernel', 'agent_repo_kernel']
+    if len(data) != 0:
+        for i in data:
+            if i[1] and i[2]:
+                kernel_arr = ('不迁移内核' + ',' + i[2]).split(',')
+                kernel_list = list(i)
+                kernel_list[2] = kernel_arr
+            else:
+                kernel_list = [list(i)[0], '', '']
+            info_list.append(dict(zip(info_dict_keys_list, kernel_list)))
+
+    res['info'] = info_list
+    res['num'] = len(info_list)
+
     json_res = json.dumps(res)
     return json_res
\ No newline at end of file
-- 
2.20.1

