161 lines
4.2 KiB
Diff
161 lines
4.2 KiB
Diff
From 8cd79eb6eea6032de7ba93b9be82cb0891b2ea63 Mon Sep 17 00:00:00 2001
|
|
From: xuezhixin <xuezhixin@uniontech.com>
|
|
Date: Fri, 10 Nov 2023 13:35:58 +0800
|
|
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0migration.py=EF=BC=8C?=
|
|
=?UTF-8?q?=E4=BD=9C=E4=B8=BA=E8=BF=81=E7=A7=BB=E7=9B=B8=E5=85=B3=E5=8A=9F?=
|
|
=?UTF-8?q?=E8=83=BD=E4=BD=BF=E7=94=A8?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
---
|
|
sysmig_agent/check.py | 37 ----------------------
|
|
sysmig_agent/migration.py | 66 +++++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 66 insertions(+), 37 deletions(-)
|
|
create mode 100644 sysmig_agent/migration.py
|
|
|
|
diff --git a/sysmig_agent/check.py b/sysmig_agent/check.py
|
|
index 3d4d3e9..141a734 100644
|
|
--- a/sysmig_agent/check.py
|
|
+++ b/sysmig_agent/check.py
|
|
@@ -18,12 +18,6 @@ from sysmig_agent.Abitxt2xls import *
|
|
|
|
os.chdir('/usr/lib/migration-tools-agent')
|
|
|
|
-def migInit_porgress():
|
|
- uelc_rpm = os.popen('rpm -qa|wc -l').readlines()
|
|
- with open('/var/tmp/uos-migration/.rpms','w+') as fp:
|
|
- fp.write(uelc_rpm[0])
|
|
- fp.close()
|
|
-
|
|
|
|
def init_dir():
|
|
if not os.path.isdir(PRE_MIG_DIR):
|
|
@@ -517,13 +511,6 @@ def mig_kernel(kernel_version):
|
|
return 1
|
|
|
|
|
|
-def migprogress():
|
|
- with open(RPMS,'r+') as fpro:
|
|
- data = fpro.read()
|
|
- fpro.close()
|
|
- return int(data)
|
|
-
|
|
-
|
|
def migration_details(data_j):
|
|
uos_sysmig_conf = json.loads(getSysMigConf())
|
|
AGENT_IP = json.loads(uos_sysmig_conf).get('agentip').strip()[1:-1]
|
|
@@ -539,18 +526,6 @@ def migration_details(data_j):
|
|
return list_to_json(keylist,valuelist)
|
|
|
|
|
|
-def readline_log():
|
|
- path = '/var/tmp/uos-migration/UOS_migration_log/mig_log.txt'
|
|
- if not os.path.exists(path):
|
|
- return 0
|
|
- else:
|
|
- ln = 0
|
|
- with open(path,'r') as rf:
|
|
- for line in rf:
|
|
- ln = ln + 1
|
|
- rf.close()
|
|
- return ln
|
|
-
|
|
##迁移进度
|
|
def rpmsProgress():
|
|
percent = 99
|
|
@@ -561,18 +536,6 @@ def rpmsProgress():
|
|
return rpms_progress
|
|
|
|
|
|
-def mig_check_migration_progress():
|
|
- percent = 98
|
|
- rpms = migprogress()
|
|
- lines = readline_log()
|
|
- lines = lines//4
|
|
- if lines >= rpms:
|
|
- lines = rpms
|
|
- data = percent*(lines/rpms)
|
|
- data = format(data, '.1f')
|
|
- messageProgress(data)
|
|
-
|
|
-
|
|
def check_migration_progress(data_j):
|
|
uos_sysmig_conf = json.loads(getSysMigConf())
|
|
AGENT_IP = json.loads(uos_sysmig_conf).get('agentip').strip()[1:-1]
|
|
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
|
|
new file mode 100644
|
|
index 0000000..c635041
|
|
--- /dev/null
|
|
+++ b/sysmig_agent/migration.py
|
|
@@ -0,0 +1,66 @@
|
|
+# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
|
+# SPDX-License-Identifier: MulanPubL-2.0-or-later
|
|
+
|
|
+from sysmig_agent.centos82uos import *
|
|
+
|
|
+#sys.path.append("..")
|
|
+from connect_sql import DBHelper
|
|
+
|
|
+RPMS = '/var/tmp/uos-migration/.rpms'
|
|
+
|
|
+# migrations function
|
|
+
|
|
+# migrations progress
|
|
+# 迁移进度
|
|
+
|
|
+def mig_whether_success():
|
|
+ # rpms = int(migprogress())
|
|
+ cmdrpm = 'rpm -qa | wc -l'
|
|
+ cmduelc = 'rpm -qa | grep oe1|wc -l'
|
|
+ rpms = int(os.popen(cmdrpm).readlines()[0])
|
|
+ ret = int(os.popen(cmduelc).readlines()[0])
|
|
+ res = (ret / rpms)*100
|
|
+ res = format(res, '.0f')
|
|
+ return int(res)
|
|
+
|
|
+
|
|
+def migprogress():
|
|
+ with open(RPMS, 'r+') as fpro:
|
|
+ data = fpro.read()
|
|
+ fpro.close()
|
|
+ return int(data)
|
|
+
|
|
+
|
|
+def readline_log():
|
|
+ path = '/var/tmp/uos-migration/UOS_migration_log/mig_log.txt'
|
|
+ if not os.path.exists(path):
|
|
+ return None
|
|
+ else:
|
|
+ ln = 0
|
|
+ with open(path, 'r') as rf:
|
|
+ for line in rf:
|
|
+ ln = ln + 1
|
|
+ rf.close()
|
|
+ return ln
|
|
+
|
|
+
|
|
+def migInit_porgress():
|
|
+ uelc_rpm = os.popen('rpm -qa|wc -l').readlines()
|
|
+ with open('/var/tmp/uos-migration/.rpms', 'w+') as fp:
|
|
+ fp.write(uelc_rpm[0])
|
|
+ fp.close()
|
|
+
|
|
+
|
|
+# check_migration_progress
|
|
+def mig_check_migration_progress():
|
|
+ percent = 98
|
|
+ rpms = migprogress()
|
|
+ lines = readline_log()
|
|
+ if not lines:
|
|
+ return 0
|
|
+ lines = lines // 6
|
|
+ if lines >= rpms:
|
|
+ lines = rpms
|
|
+ data = percent * (lines / rpms)
|
|
+ data = format(data, '.1f')
|
|
+ return data
|
|
--
|
|
2.20.1
|
|
|