From 40d5cb8b4956b7a40ce04c9e54acbecdca196691 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 13:37:59 +0800
Subject: [PATCH] =?UTF-8?q?=E5=86=85=E6=A0=B8=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 index.py           | 12 ++++++++++++
 views/migration.py | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/index.py b/index.py
index edd4440..f0bf10d 100644
--- a/index.py
+++ b/index.py
@@ -30,6 +30,7 @@ mods = {
         'sql_task': server.modify_task_stream,
         'delete_host_info': server.delete_host_info,
         'check_info': migration.check_info,
+        'check_kernel': migration.check_kernel,
         }
 
 
@@ -98,6 +99,17 @@ def check_info():
         return Response(mod, content_type='application/json')
 
 
+@app.route('/check_kernel', methods=['GET', 'POST'])
+def check_kernel():
+    """
+    下发检测agent内核版本和软件仓库内核版本
+    :return:
+    """
+    mod = check_methods()
+    if mod:
+        return Response(mod, content_type='application/json')
+
+
 @app.route('/', methods=['GET', 'POST'])
 def MT_index():
     """
diff --git a/views/migration.py b/views/migration.py
index 985a1bf..d9ac551 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -53,6 +53,7 @@ def get_agent_ip(data, sql, url):
             task_id = DBHelper().execute(get_task_id_sql).fetchall()
             data['task_id'] = task_id[0][0]
             json_data = json.dumps(data)
+            send_task_to_agent(json_data, url, list(i)[0])
 
 
 def check_info(data):
@@ -66,6 +67,17 @@ def check_info(data):
     return 'success'
 
 
+def check_kernel(data):
+    """
+    检测agent内核版本和软件仓库内核版本
+    :param data:
+    :return:
+    """
+    sql = "select agent_ip from agent_info where agent_online_status=0 and agent_storage>=10 and repo_status=0;"
+    get_agent_ip(data, sql, '/check_kernel')
+    return 'success'
+
+
 def check_services(data, url):
     info = post_client_data(data, url)
     if info is None or info.status_code != 200:
-- 
2.20.1

