migration-tools/0021-get-agent-ip-interface.patch

46 lines
1.5 KiB
Diff
Raw Normal View History

2024-11-05 10:13:38 +08:00
From 371237696acb7ea7c34191cd629f3dd8d9cff8df Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 10:32:24 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96agent=20ip=E5=9C=B0=E5=9D=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
views/migration.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/views/migration.py b/views/migration.py
index b359d36..7b2f4ed 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -10,6 +10,25 @@ from client_requests import *
from sysmig_agent.utils import *
+def get_agent_ip(data, sql, url):
+ """
+ 获取agent_ip地址
+ :return:
+ """
+ agent_info = DBHelper().execute(sql).fetchall()
+ data = json.loads(data)
+ for i in agent_info:
+ task_status_sql = "select task_status from agent_task where agent_ip='%s'" % list(i)[0]
+ task_status = DBHelper().execute(task_status_sql).fetchall()[0][0]
+ if task_status == 0 or task_status == 2:
+ update_sql = "update agent_task set task_progress=0,task_status=1 where agent_ip='%s'" % list(i)[0]
+ DBHelper().execute(update_sql)
+ get_task_id_sql = "select task_id from cur_task where agent_ip='%s'" % list(i)[0]
+ task_id = DBHelper().execute(get_task_id_sql).fetchall()
+ data['task_id'] = task_id[0][0]
+ json_data = json.dumps(data)
+
+
def check_info(data):
"""
检测系统版本和空间大小
--
2.20.1