diff --git a/0028-send-agent-task.patch b/0028-send-agent-task.patch new file mode 100644 index 0000000000000000000000000000000000000000..820de691af00c368c2eceadf1e20ee2b27e5d9c5 --- /dev/null +++ b/0028-send-agent-task.patch @@ -0,0 +1,61 @@ +From add93aadd87a53dc960b1e0d2fdb6ed4cb4e2d30 Mon Sep 17 00:00:00 2001 +From: lixin +Date: Fri, 10 Nov 2023 10:58:42 +0800 +Subject: [PATCH] =?UTF-8?q?agent=E4=BB=BB=E5=8A=A1=E4=B8=8B=E5=8F=91?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + views/migration.py | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/views/migration.py b/views/migration.py +index 7b2f4ed..985a1bf 100644 +--- a/views/migration.py ++++ b/views/migration.py +@@ -8,6 +8,32 @@ from logger import * + from flask import * + from client_requests import * + from sysmig_agent.utils import * ++from interaction import splice_url ++ ++ ++migration_log = Logger('/var/tmp/uos-migration/migration.log', logging.DEBUG, logging.DEBUG) ++ ++def send_task_to_agent(data, url, ip): ++ """ ++ 向agent下发任务 ++ :param data: ++ :param url: ++ :param ip: ++ :return: ++ """ ++ log_info = "post " + url + ":" + str(data) ++ migration_log.info(log_info) ++ info = splice_url(data, url, ip) ++ if info.status_code == 200: ++ migration_log.info(info.text) ++ elif info is None or info.status_code == 404: ++ sql = "update agent_info set agent_online_status=1 where agent_ip ='%s';" % ip ++ DBHelper().execute(sql) ++ migration_log.error("%s:请求失败,agent端没有启动" % ip) ++ elif info.status_code != 404 and info.status_code != 200: ++ sql = "update agent_info set agent_online_status=1 where agent_ip ='%s';" % ip ++ DBHelper().execute(sql) ++ migration_log.error("%s:请求失败,错误状态码为%s" % (ip, info.status_code)) + + + def get_agent_ip(data, sql, url): +@@ -35,6 +61,8 @@ def check_info(data): + :param data: + :return: + """ ++ sql = "select agent_ip from agent_info where agent_online_status = 0;" ++ get_agent_ip(data, sql, '/check_info') + return 'success' + + +-- +2.20.1 + diff --git a/migration-tools.spec b/migration-tools.spec index 409c1b0ae3ded8c5d1aac8091d8ec98936119477..e9f415c200ff2d6344ba134bee542c7abf292dbd 100644 --- a/migration-tools.spec +++ b/migration-tools.spec @@ -1,6 +1,6 @@ Name: migration-tools Version: 1.0.2 -Release: 27 +Release: 28 License: MulanPSL-2.0 Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system Source0: %{name}-%{version}.tar.gz @@ -34,7 +34,7 @@ Patch24: 0024-add-url-processing-function.patch Patch25: 0025-update-migration-status-to-database.patch Patch26: 0026-create-repository-and-disable-local-repofile.patch Patch27: 0027-fix-grub-file-for-system-option.patch - +Patch28: 0028-send-agent-task.patch BuildArch: noarch BuildRequires: systemd @@ -133,6 +133,9 @@ rm -rf /usr/bin/migration-tools %endif %changelog +* Tue Nov 5 2024 xuezhixin - 1.0.2-28 +- 0028-send-agent-task.patch + * Tue Nov 5 2024 xuezhixin - 1.0.2-27 - 0027-fix-grub-file-for-system-option.patch