From ba4c9021051b1844ebf09435ae60ead631e468c4 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:40:46 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E6=AD=A5=E9=AA=A4?=
 =?UTF-8?q?=E8=BF=81=E7=A7=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 sysmig_agent/migration.py | 51 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index fec143a..a3265e9 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -235,3 +235,54 @@ def get_old_osversion():
     return oldosversion
 
 
+
+def mig_system_migration(kernel_version):
+    res = '0'
+    #state = str(get_mig_state())
+    state = 0
+    print('-GET MIG STATE-'+state)
+    if '0' == state:
+        sql_mig_statue('1')
+        ifnot_mig_kernel(kernel_version)
+        # t = Process(target=Sysmig, args=(kernel_version,))
+        # t.start()
+        Sysmig(kernel_version)
+    elif '2' == state:
+        sql_mig_statue('6')
+        mig_kernel(kernel_version)
+        with open(PRE_MIG, 'r') as fp:
+            stros = fp.readlines()
+            oldos = stros[0]
+            fp.close()
+        oldos = oldos.split(':',1)
+        main_conf(oldos[1])
+        if os.path.exists('/var/tmp/uos-migration/data/exp-rst/systeminfo.txt'):
+            run_cmd2file('sh func/Abitranrept.sh')
+            # abi_txt2xls_trans()
+        sql_mig_statue('4')
+    elif '4' == state:
+        sql_mig_statue('5')
+        if os.path.exists('/var/tmp/uos-migration/UOS_migration_log/rpms-verified-after.txt'):
+            res = '0'
+        else:
+            res = '-1'
+    elif '3' == state:
+        sql_mig_statue('5')
+        if os.path.exists('/var/tmp/uos-migration/data/exp-rst/systeminfo.txt'):
+            run_cmd2file('func/Abitranrept.sh')
+            # abi_txt2xls_trans()
+        if os.path.exists('/var/tmp/uos-migration/UOS_migration_log/rpms-list-after.txt'):
+            res = '0'
+        else:
+            res = '-1'
+    elif '5' == state:
+        if '-1' == res :
+            data =' 迁移失败。'
+            keylist = ['ip','res','error']
+            return 3
+        else:
+            data = '迁移成功。'
+        return 2
+    return 1
+
+
-- 
2.20.1

