From 3d4c5f1d8dbc9595c38ff5313743245017851114 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 13:55:42 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0centos7=E5=92=8Ccentos8?=
 =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=85=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 sysmig_agent/centos82uos.py |  2 +-
 sysmig_agent/migration.py   | 39 +++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/sysmig_agent/centos82uos.py b/sysmig_agent/centos82uos.py
index 0a715b0..cc54eba 100755
--- a/sysmig_agent/centos82uos.py
+++ b/sysmig_agent/centos82uos.py
@@ -10,7 +10,7 @@ import shutil
 import argparse
 import platform
 import logging
-
+from sysmig_agent.share import *
 from utils import *
 
 reposdir=''
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index c635041..76b3b8e 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -64,3 +64,42 @@ def mig_check_migration_progress():
     data = percent * (lines / rpms)
     data = format(data, '.1f')
     return data
+
+
+
+def up_to_date_sql_migrate():
+    data = mig_check_migration_progress()
+    sql_show_tables()
+    sql = "UPDATE agent_task SET task_progress = {} ,task_Updatetime = NOW() WHERE agent_ip = '{}';".format(data, get_local_ip())
+    try:
+        ret = DBHelper().execute(sql)
+    except:
+        pass
+    return 0
+
+
+def Sysmig(kernel_version):
+    os_version_ret = platform.dist()
+    version = os_version_ret[1].split('.',-1)
+    AGENT_OS = os_version_ret[0]+version[0]
+    data = state =0
+    if re.fullmatch('8',version[0]):
+        cmd = 'python3 func/centos82uos.py'
+        run_cmd2file(cmd)
+        # t = Process(target=run_cmd2file, args=(cmd,))
+        # t.start()
+    elif re.search('centos7',AGENT_OS):
+        ex_kernel = 'sh func/centos72uos.sh -e "kernel-devel* kernel-headers* kernel-tools* kernel* bpftool perf python-perf kernel-abi* kernel-modules kernel-core kmod-kvdo"'
+        if kernel_version == '0':
+            run_cmd2file(ex_kernel)
+            sql_mig_statue('3')
+        elif kernel_version == '3.10.0':
+            run_cmd2file(ex_kernel)
+            cmd_k = 'sh func/kernel.sh -k 3.10.0'
+            run_cmd2file(cmd_k)
+            sql_mig_statue('3')
+        else:
+            cmd = 'sh func/centos72uos.sh'
+            run_cmd2file(cmd)
+            sql_mig_statue('3')
+
-- 
2.20.1

