add system migration task

This commit is contained in:
xuezhixin 2024-11-11 15:37:01 +08:00
parent 56214bf059
commit a771fb4492
2 changed files with 102 additions and 2 deletions

View File

@ -0,0 +1,97 @@
From 5429befc45c4aff1517ee2346c16da3c2aafd8a4 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 16:00:22 +0800
Subject: [PATCH] =?UTF-8?q?agent=E7=9A=84=E7=B3=BB=E7=BB=9F=E8=BF=81?=
=?UTF-8?q?=E7=A7=BB=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/fork.py | 73 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/sysmig_agent/fork.py b/sysmig_agent/fork.py
index daea65f..615b3d5 100644
--- a/sysmig_agent/fork.py
+++ b/sysmig_agent/fork.py
@@ -61,3 +61,76 @@ def timed_task_abi(task_id):
print('Exit The Job!')
+# 系统迁移 定时任务更新进度
+def timed_task_migrate(task_id, kernel_version):
+ time_task_m = BackgroundScheduler(timezone='Asia/Shanghai')
+ p = time_task_m.add_job(up_to_date_sql_migrate, 'interval', seconds=3)
+ migInit_porgress()
+ time_task_m.start()
+ try:
+ while 8 > int(str(get_mig_state(task_id))[1]):
+ state = str(get_mig_state(task_id))[1]
+ if str(get_mig_state(task_id))[0] == '1':
+ ##
+ ## error , too many request systen migration
+ time_task_m.shutdown()
+ return 'error'
+ old_os_name = get_old_osname()
+ if '0' == state:
+ sql_mig_statue('10')
+ if ifnot_mig_kernel(kernel_version):
+ sql_mig_statue('18')
+ t = Process(target=centos8_main, args=(old_os_name, task_id,))
+ t.start()
+ t.join()
+ elif '2' == state:
+ sql_mig_statue('12')
+ ## skip broken
+ skip = 0
+ t = Process(target=mig_distro_sync, args=(skip, task_id,))
+ t.start()
+ t.join()
+ elif '3' == state:
+ # Breakpoint
+ sql_mig_statue('05')
+ elif '4' == state:
+ sql_mig_statue('14')
+ mig_kernel(kernel_version)
+ main_conf(old_os_name)
+ # Migration report
+ try:
+ migrate_behind_abi_chk()
+ except:
+ # Generate analysis report error
+ pass
+ sql_mig_statue('05')
+ elif '5' == state:
+ sql_mig_statue('15')
+ # Migration state weight : 90
+ res = mig_whether_success()
+
+ # new system regen sql
+ get_new_osversion()
+ # tar.gz type
+ targz_mig_dir_log()
+ targz_mig_dir_report()
+ sql_abi_progress(100)
+ if 80 > int(res):
+ sql_task_statue('3', task_id)
+ sql_mig_statue('08')
+ return 1
+ # data = ' 迁移失败。'
+ else:
+ sql_task_statue('2', task_id)
+ sql_mig_statue('09')
+ time_task_m.shutdown()
+ return 0
+ # data = '迁移成功。'
+ time.sleep(3) # 其他任务是独立的线程执行
+ time_task_m.shutdown()
+ return 0
+ except (KeyboardInterrupt, SystemExit):
+ # Not strictly necessary if daemonic mode is enabled but should be done if possible
+ time_task_m.shutdown()
+ sql_task_statue('3', task_id)
+
--
2.20.1

View File

@ -1,6 +1,6 @@
Name: migration-tools
Version: 1.0.3
Release: 7
Release: 8
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
@ -14,7 +14,7 @@ Patch004: 0004-complete-information-report-after-abi-detection.patch
Patch005: 0005-abi-detection-through-multi-threads.patch
Patch006: 0006-add-message-query-to-update-abi-process.patch
Patch007: 0007-start-task-to-check-migration.patch
Patch008: 0008-add-system-migration-task.patch
BuildArch: noarch
@ -114,6 +114,9 @@ rm -rf /usr/bin/migration-tools
%endif
%changelog
* Mon Nov 11 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.3-8
- 0008-add-system-migration-task.patch
* Mon Nov 11 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.3-7
- 0007-start-task-to-check-migration.patch