From 481d09eba9e03bda1d87fc9d21451634d23fff30 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 14:47:54 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9repo=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 index.py           | 13 ++++++++++++-
 views/migration.py | 15 ++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/index.py b/index.py
index f6a171f..9665e29 100644
--- a/index.py
+++ b/index.py
@@ -18,7 +18,6 @@ mods = {
         'check_os_kernel': migration.check_os_kernel,
         'check_migration_progress': migration.check_migration_progress,
         'check_progress': migration.check_progress,
-        'check_repo': migration.check_repo,
         'check_repo_kernel': migration.check_repo_kernel,
         'check_user': migration.check_user,
         'close_tool': migration.close_tool,
@@ -32,6 +31,7 @@ mods = {
         'check_info': migration.check_info,
         'check_kernel': migration.check_kernel,
         'get_kernel_data': server.get_kernel_data,
+        'check_repo': migration.check_repo,
         }
 
 
@@ -122,6 +122,17 @@ def get_kernel_data():
         return Response(mod, content_type='application/json')
 
 
+@app.route('/check_repo', methods=['GET', 'POST'])
+def check_repo():
+    """
+    检测平台软件仓库
+    :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 d9ac551..a628694 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -123,9 +123,18 @@ def check_user(data):
 
 
 def check_repo(data):
-    services = check_services(data, '/check_repo')
-    if services:
-        return services
+    """
+    检测平台软件仓库
+    :param data:
+    :return:
+    """
+    sql = "select agent_ip from agent_info where agent_online_status = 0 and agent_storage >= 10;"
+    agent_ip_list = DBHelper().execute(sql)
+    for i in agent_ip_list:
+        repo_status_sql = "update agent_info set repo_status='2' where agent_ip='%s'" % list(i)[0]
+        DBHelper().execute(repo_status_sql)
+    get_agent_ip(data, sql, '/check_repo')
+    return 'success'
 
 
 def check_os_kernel(data):
-- 
2.20.1

