!138 update to 1.0.3

From: @xuezhizone 
Reviewed-by: @xingwei-liu 
Signed-off-by: @xingwei-liu
This commit is contained in:
openeuler-ci-bot 2024-11-11 02:55:44 +00:00 committed by Gitee
commit ab585d093b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
86 changed files with 5 additions and 6681 deletions

View File

@ -1,119 +0,0 @@
From 8dbd8088e6895367eb09f3a01389a6ebe3ce9feb Mon Sep 17 00:00:00 2001
From: FanSheng Meng <mengfansheng@uniontech.com>
Date: Mon, 16 Oct 2023 14:07:46 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81=E6=A0=BC?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../centos7/openeuler/centos72openeuler.py | 6 ++----
views/migration.py | 11 +++++++----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py b/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
index 05a444c..7ccdb44 100644
--- a/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
+++ b/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py
@@ -28,7 +28,6 @@ def run_subprocess(cmd):
print(output) # Print the output to console
return output, process.returncode
except subprocess.CalledProcessError as e:
- #print(f"Command '{e.cmd}' failed with return code {e.returncode}.")
print(e.stderr) # Print the error output to console
return e.stderr, e.returncode
@@ -87,6 +86,7 @@ def add_boot_option():
except Exception as e:
print(e)
+
def swap_release(release):
tmp_dir = '/var/tmp'
rpme_release = 'rpm -qf /etc/os-release | xargs -i rpm -e --nodeps {}'
@@ -163,6 +163,7 @@ def system_sync():
return False
return True
+
def main():
if not check_pkg("yum-utils"):
print("please install yum-utils")
@@ -187,7 +188,6 @@ def main():
with open(repofile, 'w') as f:
f.write(openeuler_repo)
-
openEuler_release = 'openEuler-release'
if not check_pkg(openEuler_release):
print("swaping release")
@@ -240,7 +240,6 @@ def main():
print("Removing confilct package yum...")
system_sync()
-
# boot cui
print("set boot target to cui")
cmd = 'systemctl set-default multi-user.target'
@@ -263,6 +262,5 @@ def main():
os.system("reboot")
-
if __name__ == '__main__':
main()
diff --git a/views/migration.py b/views/migration.py
index 1312d33..477627b 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -1,12 +1,11 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: MulanPubL-2.0-or-later
-
-from flask import *
import os
-
+from flask import *
from client_requests import *
from func.utils import *
+
def check_services(data, url):
info = post_client_data(data, url)
if info is None or info.status_code != 200:
@@ -27,26 +26,30 @@ def check_os(data):
if services:
return services
+
def check_storage(data):
services = check_services(data, '/check_storage')
if services:
return services
+
def close_tool(data):
os.system('kill -9 `ps -ef | grep "start_webview.py" | grep -v grep | awk \'{print $2}\'`')
data = {"ip": "0.0.0.0"}
data_json = json.dumps(data)
return data_json
+
def check_user(data):
services = check_services(data, '/check_user')
if services:
json_data = json.loads(data)
- with open('/usr/lib/migration-tools-server/.passwd.txt','w',encoding='utf-8') as f:
+ with open('/usr/lib/migration-tools-server/.passwd.txt', 'w', encoding='utf-8') as f:
text = json_data['passwd']
f.write(text)
return services
+
def check_repo(data):
services = check_services(data, '/check_repo')
if services:
--
2.20.1

View File

@ -1,223 +0,0 @@
From 2954e8c9e13cacb09bdd668e38adce53162c6e3a Mon Sep 17 00:00:00 2001
From: FanSheng Meng <mengfansheng@uniontech.com>
Date: Mon, 16 Oct 2023 14:30:12 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81=E6=A0=BC?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
func/Abitxt2xls.py | 103 +++++++-----------
.../centos7/uos/centos72uos.sh | 1 -
2 files changed, 40 insertions(+), 64 deletions(-)
diff --git a/func/Abitxt2xls.py b/func/Abitxt2xls.py
index 77c4ebd..d80ad4c 100644
--- a/func/Abitxt2xls.py
+++ b/func/Abitxt2xls.py
@@ -1,32 +1,24 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: MulanPubL-2.0-or-later
-
# coding=utf-8
-'''''
-main function主要实现把txt中的每行数据写入到excel中
-'''
-#################
import datetime
import json
import socket
import xlwt
-
from func.share import *
-#检测报告导出绝对路径
-report_path_bef="/var/tmp/uos-migration/UOS_analysis_report/"
-report_path_ago='/var/tmp/uos-migration/UOS_migration_log/'
-
+report_path_bef = "/var/tmp/uos-migration/UOS_analysis_report/"
+report_path_ago = '/var/tmp/uos-migration/UOS_migration_log/'
txtFileName = '/var/tmp/uos-migration/data/exp-rst/abi-compat-pkg.txt'
txtFileName1 = '/var/tmp/uos-migration/data/exp-rst/abi-incompat-pkg.txt'
SysInfoFile = '/var/tmp/uos-migration/data/exp-rst/systeminfo.txt'
SysInfoFile_after = '/var/tmp/uos-migration/data/exp-rst/trans-end-sysinfo.txt'
-PkgCompFile1= '/var/tmp/uos-migration/data/exp-rst/pkginfo_1.txt'
-PkgCompFile2= '/var/tmp/uos-migration/data/exp-rst/pkginfo_2.txt'
-PkgCompFile3= '/var/tmp/uos-migration/data/exp-rst/pkginfo_3.txt'
-PkgCompFile4= '/var/tmp/uos-migration/data/exp-rst/pkginfo_4.txt'
-PkgCompFile1_after= '/var/tmp/uos-migration/data/exp-rst/pkginfo_1_trans.txt'
+PkgCompFile1 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_1.txt'
+PkgCompFile2 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_2.txt'
+PkgCompFile3 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_3.txt'
+PkgCompFile4 = '/var/tmp/uos-migration/data/exp-rst/pkginfo_4.txt'
+PkgCompFile1_after = '/var/tmp/uos-migration/data/exp-rst/pkginfo_1_trans.txt'
def get_host_ip():
@@ -39,117 +31,102 @@ def get_host_ip():
return ip
-def accord_line_write(txtLineFile, sheet_line, line_num, colu_num):
+def accord_line_write(txt_line_file, sheet_line, line_num, column_num):
# 通过列的形式写入文件
- with open(txtLineFile,'r') as line_f:
+ with open(txt_line_file, 'r') as line_f:
x = line_num
- y = colu_num
+ y = column_num
sys_lines = line_f.readlines()
for line in sys_lines:
for value in line.strip().split("|"):
- sheet_line.write(x,y,value)
+ sheet_line.write(x, y, value)
y += 1
x += 1
y = 0
line_f.close()
-def accord_colu_write(txtColuFile,sheet_colu, line_num, colu_num):
+def accord_column_write(txt_column_file, sheet_column, line_num, column_num):
# 通过行的形式写入文件
- with open(txtColuFile,'r') as colu_f:
+ with open(txt_column_file, 'r') as column_f:
x = line_num
- y = colu_num
- sys_colus = colu_f.readlines()
- for line in sys_colus:
+ y = column_num
+ sys_columns = column_f.readlines()
+ for line in sys_columns:
for value in line.strip().split("|"):
- sheet_colu.write(x,y,value)
+ sheet_column.write(x, y, value)
x += 1
- colu_f.close()
+ column_f.close()
+
def system_info(check_file):
- #新建一个sheet
sheet_sysinfo = check_file.add_sheet("系统基本信息")
accord_line_write(SysInfoFile, sheet_sysinfo, 0, 0)
-#sheet1-系统基本信息
+# sheet1-系统基本信息
def system_info_after(sys):
- #新建一个sheet
sheet_sysinfo = sys.add_sheet("系统基本信息")
accord_line_write(SysInfoFile_after, sheet_sysinfo, 0, 0)
-#sheet2-软件包对比
+# sheet2-软件包对比
def pkg_comp(pkg):
- #新建一个sheet
sheet_pkgcomp = pkg.add_sheet("软件包对比")
accord_line_write(PkgCompFile1, sheet_pkgcomp, 0, 0)
- accord_colu_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
- accord_colu_write(PkgCompFile4, sheet_pkgcomp, 3, 1)
+ accord_column_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
+ accord_column_write(PkgCompFile4, sheet_pkgcomp, 3, 1)
-#sheet2-软件包对比
+# sheet2-软件包对比
def pkg_comp_after(pkg):
- #新建一个sheet
sheet_pkgcomp = pkg.add_sheet("软件包对比")
accord_line_write(PkgCompFile1_after, sheet_pkgcomp, 0, 0)
- accord_colu_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
- accord_colu_write(PkgCompFile3, sheet_pkgcomp, 3, 1)
- accord_colu_write(PkgCompFile4, sheet_pkgcomp, 3, 2)
+ accord_column_write(PkgCompFile2, sheet_pkgcomp, 3, 0)
+ accord_column_write(PkgCompFile3, sheet_pkgcomp, 3, 1)
+ accord_column_write(PkgCompFile4, sheet_pkgcomp, 3, 2)
-#sheet4-ABI兼容
+# sheet4-ABI兼容
def abi_incomp_info(file_incomp):
- #新建一个sheet
sheet_comp = file_incomp.add_sheet("ABI兼容")
accord_line_write(txtFileName, sheet_comp, 0, 0)
-#sheet5-ABI不兼容
+
+# sheet5-ABI不兼容
def abi_comp_pkg(file_comp):
- #新建一个sheet
sheet_incomp = file_comp.add_sheet("ABI不兼容")
-
accord_line_write(txtFileName1, sheet_incomp, 0, 0)
+
def abi_txt2xls():
- #兼容性检查报告名规则UOS_migration_log_10.0.2.3_cy.server_202110192140.xls
- hostip = get_host_ip()
+ # 兼容性检查报告名规则UOS_migration_log_10.0.2.3_cy.server_202110192140.xls
+ host_ip = get_host_ip()
hostname = socket.gethostname()
- excelFileName = "UOS_migration_log_"+hostip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
-
- report_name_check=report_path_bef+excelFileName
+ excel_file_name = "UOS_migration_log_"+host_ip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
+ report_name_check = report_path_bef + excel_file_name
if os.path.exists(report_name_check):
os.remove(report_name_check)
-
- #新建一个excel文件
- check_file = xlwt.Workbook(encoding='utf-8',style_compression=0)
-
+ check_file = xlwt.Workbook(encoding='utf-8', style_compression=0)
system_info(check_file)
pkg_comp(check_file)
abi_incomp_info(check_file)
abi_comp_pkg(check_file)
-
check_file.save(report_name_check)
def abi_txt2xls_after_mig():
-
- hostip = get_host_ip()
+ host_ip = get_host_ip()
hostname = socket.gethostname()
- excelFileName_after = "UOS_migration_log_"+hostip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
-
- report_name_after=report_path_ago+excelFileName_after
+ excel_file_name_after = "UOS_migration_log_"+host_ip+"_"+hostname+"_"+datetime.datetime.now().strftime('%Y%m%d%H%M')+".xls"
+ report_name_after = report_path_ago+excel_file_name_after
if os.path.exists(report_name_after):
os.remove(report_name_after)
-
- #新建一个excel文件
- after_mig_xls = xlwt.Workbook(encoding='utf-8',style_compression=0)
-
+ after_mig_xls = xlwt.Workbook(encoding='utf-8', style_compression=0)
system_info_after(after_mig_xls)
pkg_comp_after(after_mig_xls)
abi_incomp_info(after_mig_xls)
abi_comp_pkg(after_mig_xls)
-
after_mig_xls.save(report_name_after)
diff --git a/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh b/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh
index 7248b14..18a9ddf 100755
--- a/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh
+++ b/ut-Migration-tools-0.1/centos7/uos/centos72uos.sh
@@ -1,6 +1,5 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-
# SPDX-License-Identifier: MulanPubL-2.0-or-later
set -x
--
2.20.1

View File

@ -1,131 +0,0 @@
From 54d64a8d9f3593e97ffee25484c25a9891cd70f2 Mon Sep 17 00:00:00 2001
From: FanSheng Meng <mengfansheng@uniontech.com>
Date: Mon, 16 Oct 2023 15:59:16 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
func/Abisystmcompchk.sh | 31 +------------------------------
1 file changed, 1 insertion(+), 30 deletions(-)
diff --git a/func/Abisystmcompchk.sh b/func/Abisystmcompchk.sh
index e6b828e..15938fc 100755
--- a/func/Abisystmcompchk.sh
+++ b/func/Abisystmcompchk.sh
@@ -1,11 +1,4 @@
#!/bin/bash
-# 项目名称: abi结果自动化分析实现
-# 所属系统: UOS
-# 文件名称: Abisystemcompcheck
-# 功 能: 基于系统兼容性检查报告的自动化分析
-# : 输出系统兼容百分比,非兼容包原因列表,兼容包列表等。
-# 作 者: lihaipeng
-
########################变量定义#################################
LOCAL_DIR=/var/tmp/uos-migration/data
@@ -227,8 +220,7 @@ get_abi_comp_rest()
NUM1=0
#兼容性开关,0-兼容1-不兼容
COMP_FLAG=0
- #cat ./$abi_diff_file.tmp | while read line
- while read line
+ while read line
do
if [[ $line == *$DATA_LINE_1* ]];then
NUM2=$(( $NUM1 % 5 ))
@@ -262,7 +254,6 @@ get_abi_comp_rest()
then
abi_var_comp_2="${abi_diff_file%.*}|$line|兼容"
else
- #echo "$abi_diff_file|$line|不规范,清确认!" >> $EXP_DIR/$ABI_DIFF_PKG_ERR
abi_var_incomp_2="$NAME|$COMP_TYPE|$data_line|$line"
echo $abi_var_incomp_2 >> $EXP_DIR/$ABI_INCOMPAT_PKG
#此时abi编译以来库文件或者二进制包不兼容那么该rpm包不兼容
@@ -280,7 +271,6 @@ get_abi_comp_rest()
#abi检查结果中rpm包以来的库文件或者二进制文件兼容
abi_var_comp_3="${abi_diff_file%.*}|$line|兼容"
else
- #echo "$abi_diff_file|$line|不规范,清确认!" >> $EXP_DIR/$ABI_DIFF_PKG_ERR
abi_var_incomp_3="$NAME|$COMP_TYPE|$data_line|$line|"
echo $abi_var_incomp_3 >> $EXP_DIR/$ABI_INCOMPAT_PKG
#此时abi编译以来库文件或者二进制包不兼容那么该rpm包不兼容
@@ -333,11 +323,6 @@ get_abi_comp_rest()
ABI_INCOMP_NUM_TMP=`cat $EXP_DIR/$ABI_INCOMPAT_PKG | awk -F "|" '{print $1}' | sort | uniq | wc -l`
ABI_INCOMP_NUM=`expr $ABI_INCOMP_NUM_TMP - 2`
sed -i 's/INCOMP_PKG_NUM/'$ABI_INCOMP_NUM'/g' $EXP_DIR/$ABI_INCOMPAT_PKG
-
- #cp -f $EXP_DIR/$ABI_COMPAT_PKG $EXP_DIR/$PKG_COMP_LIST_03
- #sed -i '/包名/d' $EXP_DIR/$PKG_COMP_LIST_03
-
-
echo "兼容包列表:$EXP_DIR/$ABI_COMPAT_PKG"
echo "非兼容包列表:$EXP_DIR/$ABI_INCOMPAT_PKG"
echo "------------------------- 获取abi兼容、非兼容包列表结束 -------------------------"
@@ -346,7 +331,6 @@ get_abi_comp_rest()
#4. 获取系统基本信息
get_system_info()
{
- #echo "====================Start enter get_system_info=============="
#数据清理
rm -f $EXP_DIR/$SYSTEM_INFO
@@ -381,15 +365,12 @@ get_system_info()
cur_sysinfo=${cur_sysinfo_2:1:$cur_sysinfo_len}
system_info_2_line2=${SYSTEM_INFO_2_LINE2//CUR_VERSION/$cur_sysinfo}
- #system_info_2_line2=${system_info_2_line2_tmp//TRA_VERSION/$trans_sysinfo}
echo $system_info_2_line2 >> $EXP_DIR/$SYSTEM_INFO
#获取内核版本
cur_kernel_info=`uname -r`
- #trans_kernel_info="******"
system_info_3_line3=${SYSTEM_INFO_3_LINE3//CUR_KERNEL_VERSION/$cur_kernel_info}
- #system_info_3_line3=${system_info_3_line3_tmp//TRA_KERNEL_VERSION/$trans_kernel_info}
echo $system_info_3_line3 >> $EXP_DIR/$SYSTEM_INFO
echo " " >> $EXP_DIR/$SYSTEM_INFO
@@ -409,19 +390,12 @@ get_system_info()
abi_comp_pkg_num_tmp=`cat $EXP_DIR/$ABI_COMPAT_PKG | wc -l`
cur_pkg_num=`expr $abi_comp_pkg_num_tmp - 1`
- #cur_pkg_sum=`rpm -qa | wc -l`
- #trans_pkg_sum=`rpm -qa | wc -l`
system_info_9_line9=${SYSTEM_INFO_9_LINE9//REPLACE_PKG_NUM/$cur_pkg_num}
- #system_info_9_line9=${system_info_9_line9_tmp//INSTALL_PKG_NUM/$trans_pkg_sum}
echo $system_info_9_line9 >> $EXP_DIR/$SYSTEM_INFO
echo " " >> $EXP_DIR/$SYSTEM_INFO
echo $SYSTEM_INFO_11_LINE11 >> $EXP_DIR/$SYSTEM_INFO
-
- #abi_comp_pkg_num_tmp=`cat $EXP_DIR/$ABI_COMPAT_PKG | wc -l`
- #abi_comp_pkg_num=`expr $abi_comp_pkg_num_tmp - 1`
- #system_info_12_line12=${SYSTEM_INFO_12_LINE12//COMP_NUM/$abi_comp_pkg_num}
system_info_12_line12=${SYSTEM_INFO_12_LINE12//COMP_NUM/$cur_pkg_num}
echo $system_info_12_line12 >> $EXP_DIR/$SYSTEM_INFO
@@ -450,7 +424,6 @@ pkg_comp_rst()
rm -f $EXP_DIR/$PKG_COMP_LIST_01
pkg_sum_num=`cat $EXP_DIR/$UOS_PKG_RPMS_LIST | wc -l`
- #pkg_num_inst=`cat $EXP_DIR/$UOS_PKG_RPMS_LIST | grep uelc20 | wc -l`
pkg_num_inst_tmp=`cat $EXP_DIR/$ABI_COMPAT_PKG | wc -l`
pkg_num_inst=`expr $pkg_num_inst_tmp - 1`
@@ -476,8 +449,6 @@ pkg_comp_rst()
pkginfo_3_line3=${pkginfo_3_line3_tmp//UOS_VERSION/$trans_sysinfo_1}
echo $pkginfo_3_line3 >> $EXP_DIR/$PKG_COMP_LIST_01
- #cat $EXP_DIR/$UOS_PKG_RPMS_LIST | grep uelc20 > $EXP_DIR/$PKG_COMP_LIST_04
- #echo "==============End enter pkg_comp_rst========="
}
create_file_path
--
2.20.1

View File

@ -1,52 +0,0 @@
From 9d1aaac6870109b79ce77963f4270ba192a60a6f Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 6 Nov 2023 17:37:23 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
connect_sql.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 connect_sql.py
diff --git a/connect_sql.py b/connect_sql.py
new file mode 100644
index 0000000..e24a467
--- /dev/null
+++ b/connect_sql.py
@@ -0,0 +1,30 @@
+import pymysql
+
+class DBHelper:
+ # 构造函数
+ def __init__(self, host=db_host, user=db_user, pwd=db_password, db=db_name):
+ self.host = host
+ self.user = user
+ self.pwd = pwd
+ self.db = db
+ self.connect = None
+ self.cursor = None
+
+ # 连接数据库
+ def connectDatabase(self):
+ try:
+ self.connect = pymysql.connect(host=self.host, user=self.user, password=self.pwd, db=self.db,
+ charset='utf8')
+ except:
+ print('connectDatabase failed')
+ return False
+ self.cursor = self.connect.cursor()
+ return True
+
+ # 关闭数据库
+ def close(self):
+ # 如果数据打开,则关闭;否则没有操作
+ if self.connect and self.cursor:
+ self.cursor.close()
+ self.connect.close()
+ return True
--
2.20.1

View File

@ -1,62 +0,0 @@
From 8dd714b9fe161358f48857fff9a08faac2af6af4 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 6 Nov 2023 17:44:45 +0800
Subject: [PATCH] =?UTF-8?q?=E6=89=A7=E8=A1=8Csql=E8=AF=AD=E5=8F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
connect_sql.py | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/connect_sql.py b/connect_sql.py
index e24a467..b5d0570 100644
--- a/connect_sql.py
+++ b/connect_sql.py
@@ -28,3 +28,42 @@ class DBHelper:
self.cursor.close()
self.connect.close()
return True
+
+ def execute(self, sql):
+ """
+ 传入查询 修改 删除sql语句
+ :param sql:
+ :return:self.cursor
+ """
+ self.connectDatabase()
+ # 处理显示的数据
+ try:
+ self.cursor.execute(sql)
+ self.connect.commit()
+ except Exception as e:
+ print('%s执行失败%s' % (sql, e))
+ else:
+ self.close()
+ print('%s 执行成功' % sql)
+ data = self.cursor
+ return data
+
+ def insert(self, sql, val):
+ """
+ 传入sql语句
+ :param sql:
+ :return:self.cursor
+ 如果想获取查询数据需要fetchall()
+ """
+ self.connectDatabase()
+ # 处理显示的数据
+ try:
+ self.cursor.executemany(sql, val)
+ self.connect.commit()
+ except Exception as e:
+ print('%s执行失败%s' % (sql, e))
+ else:
+ self.close()
+ print('%s 执行成功' % sql)
+ data = self.cursor
+ return data
--
2.20.1

View File

@ -1,58 +0,0 @@
From 0d0a26ccedd820a583e4579d240542e346e459f3 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Tue, 7 Nov 2023 11:05:17 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
logger.py | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 logger.py
diff --git a/logger.py b/logger.py
new file mode 100644
index 0000000..2bdd144
--- /dev/null
+++ b/logger.py
@@ -0,0 +1,34 @@
+# -*-coding:UTF-8-*-
+
+import logging
+
+class Logger:
+ def __init__(self, path,clevel = logging.DEBUG,Flevel = logging.DEBUG):
+ self.logger = logging.getLogger(path)
+ self.logger.setLevel(logging.DEBUG)
+ fmt = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s', '%Y-%m-%d %H:%M:%S')
+ #设置CMD日志
+ sh = logging.StreamHandler()
+ sh.setFormatter(fmt)
+ sh.setLevel(clevel)
+ #设置文件日志
+ fh = logging.FileHandler(path)
+ fh.setFormatter(fmt)
+ fh.setLevel(Flevel)
+ self.logger.addHandler(sh)
+ self.logger.addHandler(fh)
+
+ def debug(self,message):
+ self.logger.debug(message)
+
+ def info(self,message):
+ self.logger.info(message)
+
+ def war(self,message):
+ self.logger.warning(message)
+
+ def error(self,message):
+ self.logger.error(message)
+
+ def cri(self,message):
+ self.logger.critical(message)
\ No newline at end of file
--
2.20.1

View File

@ -1,70 +0,0 @@
From 8024e49a1416a322625fe36c80621301e2a89d73 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 13:51:43 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E6=9C=BA=E5=AF=BC?=
=?UTF-8?q?=E5=85=A5=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 12 +++++++++++-
views/server.py | 13 +++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 views/server.py
diff --git a/index.py b/index.py
index 6a5fc72..a505915 100644
--- a/index.py
+++ b/index.py
@@ -7,7 +7,7 @@ import os
import sys
import json
from func import share
-from views import migration
+from views import migration, server
from flask import Flask, render_template, url_for, request, redirect, make_response, session, Response
app = Flask(__name__)
@@ -26,8 +26,18 @@ mods = {
'export_migration_reports': migration.export_migration_reports,
'system_migration': migration.system_migration,
'migration_details': migration.migration_details,
+ 'import_host_info': server.import_host_info,
}
+@app.route('/import_host_info', methods=['GET', 'POST'])
+def import_host_info():
+ """
+ 导入主机信息
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
def check_methods():
if request.method == 'POST':
diff --git a/views/server.py b/views/server.py
new file mode 100644
index 0000000..764d5bd
--- /dev/null
+++ b/views/server.py
@@ -0,0 +1,13 @@
+import json
+
+def import_host_info(data):
+ """
+ 导入agent主机信息
+ :param data:
+ :return:
+ """
+ agent_info = json.loads(data).get("data")
+ if not agent_info:
+ data = {"data": "faild"}
+ json_data = json.dumps(data)
+ return json_data
\ No newline at end of file
--
2.20.1

View File

@ -1,97 +0,0 @@
From dbca836df232ed21f05798878dfb1773501fd4c2 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 14:16:49 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=B7=BB=E5=8A=A0ag?=
=?UTF-8?q?ent=5Finfo=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
uos-sysmig.sql | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
views/server.py | 10 +++++++++-
2 files changed, 61 insertions(+), 1 deletion(-)
create mode 100644 uos-sysmig.sql
diff --git a/uos-sysmig.sql b/uos-sysmig.sql
new file mode 100644
index 0000000..eaf8aed
--- /dev/null
+++ b/uos-sysmig.sql
@@ -0,0 +1,52 @@
+-- MySQL dump 10.13 Distrib 8.0.27, for Linux (x86_64)
+--
+-- Host: 10.12.21.200 Database: uos-sysmig
+-- ------------------------------------------------------
+-- Server version 8.0.27
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `agent_info`
+--
+
+DROP TABLE IF EXISTS `agent_info`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `agent_info` (
+ `agent_id` int NOT NULL AUTO_INCREMENT,
+ `agent_ip` varchar(256) NOT NULL,
+ `agent_username` varchar(256) NOT NULL,
+ `agent_passwd` varbinary(256) NOT NULL,
+ `hostname` varchar(256) DEFAULT NULL,
+ `agent_os` varchar(256) DEFAULT NULL,
+ `agent_arch` varchar(45) DEFAULT NULL,
+ `agent_storage` int DEFAULT NULL,
+ `agent_kernel` varchar(45) DEFAULT NULL,
+ `agent_repo_kernel` varchar(256) DEFAULT NULL,
+ `agent_migration_os` varchar(256) DEFAULT NULL,
+ `agent_history_faild_reason` varchar(45) DEFAULT NULL,
+ `agent_online_status` int DEFAULT '0',
+ `repo_status` int DEFAULT NULL,
+ PRIMARY KEY (`agent_id`),
+ KEY `agent_ip` (`agent_ip`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `agent_info`
+--
+
+LOCK TABLES `agent_info` WRITE;
+/*!40000 ALTER TABLE `agent_info` DISABLE KEYS */;
+/*!40000 ALTER TABLE `agent_info` ENABLE KEYS */;
+UNLOCK TABLES;
\ No newline at end of file
diff --git a/views/server.py b/views/server.py
index 764d5bd..65ddba9 100644
--- a/views/server.py
+++ b/views/server.py
@@ -10,4 +10,12 @@ def import_host_info(data):
if not agent_info:
data = {"data": "faild"}
json_data = json.dumps(data)
- return json_data
\ No newline at end of file
+ return json_data
+
+
+ sql = "insert into agent_info(agent_ip, agent_username, agent_passwd) values (%s, %s, AES_ENCRYPT(%s, 'coco'));"
+ for i in agent_info:
+ agent_ip = i.get('agent_ip')
+ agent_username = i.get('agent_hostname')
+ agent_passwd = i.get('agent_password')
+ val = ((agent_ip, agent_username, agent_passwd),)
\ No newline at end of file
--
2.20.1

View File

@ -1,91 +0,0 @@
From 79ffefe397e47be74776b1761785f42049c67fae Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 14:51:51 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=B7=BB=E5=8A=A0ta?=
=?UTF-8?q?sk=5Fstream=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
uos-sysmig.sql | 46 +++++++++++++++++++++++++++++++++++++++++++++-
views/server.py | 4 +++-
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/uos-sysmig.sql b/uos-sysmig.sql
index eaf8aed..d65006d 100644
--- a/uos-sysmig.sql
+++ b/uos-sysmig.sql
@@ -49,4 +49,48 @@ CREATE TABLE `agent_info` (
LOCK TABLES `agent_info` WRITE;
/*!40000 ALTER TABLE `agent_info` DISABLE KEYS */;
/*!40000 ALTER TABLE `agent_info` ENABLE KEYS */;
-UNLOCK TABLES;
\ No newline at end of file
+UNLOCK TABLES;
+
+--
+-- Table structure for table `task_stream`
+--
+
+DROP TABLE IF EXISTS `task_stream`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8 */;
+CREATE TABLE `task_stream` (
+ `task_stream_id` int NOT NULL AUTO_INCREMENT,
+ `agent_ip` varchar(256) DEFAULT NULL,
+ `agent_id` int DEFAULT NULL,
+ `tasks` varchar(256) DEFAULT NULL,
+ `stream_status` varchar(256) DEFAULT NULL,
+ `stream_CreateTime` timestamp NULL DEFAULT NULL,
+ `stream_Updatetime` timestamp NULL DEFAULT NULL,
+ PRIMARY KEY (`task_stream_id`),
+ KEY `task_stream_id` (`task_stream_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `task_stream`
+--
+
+LOCK TABLES `task_stream` WRITE;
+/*!40000 ALTER TABLE `task_stream` DISABLE KEYS */;
+/*!40000 ALTER TABLE `task_stream` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping routines for database 'uossysmig'
+--
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2022-09-06 17:43:02
diff --git a/views/server.py b/views/server.py
index 65ddba9..121993a 100644
--- a/views/server.py
+++ b/views/server.py
@@ -1,4 +1,5 @@
import json
+from connect_sql import DBHelper
def import_host_info(data):
"""
@@ -18,4 +19,5 @@ def import_host_info(data):
agent_ip = i.get('agent_ip')
agent_username = i.get('agent_hostname')
agent_passwd = i.get('agent_password')
- val = ((agent_ip, agent_username, agent_passwd),)
\ No newline at end of file
+ val = ((agent_ip, agent_username, agent_passwd),)
+ DBHelper().insert(sql, val)
\ No newline at end of file
--
2.20.1

View File

@ -1,62 +0,0 @@
From f42944e0769e1514524dfe4ad348ab95dd1503ae Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 15:28:26 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BB=BB=E5=8A=A1=E6=B5=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
views/server.py | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/views/server.py b/views/server.py
index 121993a..d36f013 100644
--- a/views/server.py
+++ b/views/server.py
@@ -1,4 +1,6 @@
import json
+from datetime import datetime
+
from connect_sql import DBHelper
def import_host_info(data):
@@ -20,4 +22,32 @@ def import_host_info(data):
agent_username = i.get('agent_hostname')
agent_passwd = i.get('agent_password')
val = ((agent_ip, agent_username, agent_passwd),)
- DBHelper().insert(sql, val)
\ No newline at end of file
+ DBHelper().insert(sql, val)
+
+
+
+
+def get_agent_id(agent_ip):
+ """
+ 获取agent_id
+ :param agent_ip:
+ :return:
+ """
+ sql = "select agent_id from agent_info where agent_ip='%s'" % agent_ip
+ get_agent_id = DBHelper().execute(sql).fetchall()
+ return get_agent_id[0][0]
+
+
+def create_task_stream(agent_ip):
+ """
+ 创建任务流
+ :return:
+ """
+ create_task_stream_sql = "insert into task_stream(agent_ip,agent_id,stream_status," \
+ "stream_CreateTime,stream_Updatetime) values (%s, %s, %s, %s, %s);"
+
+ stream_status = 'None'
+ agent_id = get_agent_id(agent_ip)
+ time = datetime.now().strftime('%Y-%-m-%d %H:%M:%S')
+ values = ((agent_ip, agent_id, stream_status, time, time),)
+ DBHelper().insert(create_task_stream_sql, values)
\ No newline at end of file
--
2.20.1

File diff suppressed because one or more lines are too long

View File

@ -1,87 +0,0 @@
From c146375a219621e13c187df66c45971a4f50aa6c Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 15:51:39 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0agent=5Ftask=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
uos-sysmig.sql | 33 +++++++++++++++++++++++++++++++++
views/server.py | 17 ++++++++++++++++-
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/uos-sysmig.sql b/uos-sysmig.sql
index 4a33bb0..9f31049 100644
--- a/uos-sysmig.sql
+++ b/uos-sysmig.sql
@@ -80,6 +80,39 @@ LOCK TABLES `task_stream` WRITE;
/*!40000 ALTER TABLE `task_stream` ENABLE KEYS */;
UNLOCK TABLES;
+--
+-- Table structure for table `agent_task`
+--
+
+DROP TABLE IF EXISTS `agent_task`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `agent_task` (
+ `agent_id` int NOT NULL,
+ `agent_ip` varchar(256) DEFAULT NULL,
+ `task_id` int DEFAULT NULL,
+ `task_stream_id` int DEFAULT NULL,
+ `task_code` varchar(256) DEFAULT NULL,
+ `task_type` int DEFAULT NULL,
+ `task_status` int DEFAULT NULL,
+ `task_progress` int DEFAULT NULL,
+ `task_CreateTime` timestamp NULL DEFAULT NULL,
+ `task_Updatetime` timestamp NULL DEFAULT NULL,
+ `task_data` varchar(256) DEFAULT NULL,
+ PRIMARY KEY (`agent_id`),
+ KEY `task_id` (`task_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `agent_task`
+--
+
+LOCK TABLES `agent_task` WRITE;
+/*!40000 ALTER TABLE `agent_task` DISABLE KEYS */;
+/*!40000 ALTER TABLE `agent_task` ENABLE KEYS */;
+UNLOCK TABLES;
+
--
-- Table structure for table `cur_task`
--
diff --git a/views/server.py b/views/server.py
index 49353b4..cf07d2f 100644
--- a/views/server.py
+++ b/views/server.py
@@ -62,4 +62,19 @@ def create_task_stream(agent_ip):
agent_id = get_agent_id(agent_ip)
time = datetime.now().strftime('%Y-%-m-%d %H:%M:%S')
values = ((agent_ip, agent_id, stream_status, time, time),)
- DBHelper().insert(create_task_stream_sql, values)
\ No newline at end of file
+ DBHelper().insert(create_task_stream_sql, values)
+
+ create_cur_task_sql = "insert into cur_task(task_status,stream_CreateTime,stream_Updatetime," \
+ "agent_ip) values (%s, %s, %s, %s);"
+ values = (('None', time, time, agent_ip),)
+ DBHelper().insert(create_cur_task_sql, values)
+
+ get_task_id = "select max(task_id) task_id from cur_task"
+ task_id = DBHelper().execute(get_task_id).fetchone()
+ task_stream_id_sql = "select task_stream_id from task_stream where agent_ip='%s'" % agent_ip
+ task_stream_id = DBHelper().execute(task_stream_id_sql).fetchone()
+ values = ((agent_id, agent_ip, task_id[0], 0, 0, time, time, task_stream_id[0], "00"),)
+ create_agent_task_sql = "insert into agent_task(agent_id,agent_ip,task_id,task_status,task_progress," \
+ "task_CreateTime,task_Updatetime,task_stream_id,task_data) values " \
+ "(%s, %s, %s, %s, %s, %s, %s, %s, %s);"
+ DBHelper().insert(create_agent_task_sql, values)
\ No newline at end of file
--
2.20.1

View File

@ -1,124 +0,0 @@
From 2140a85929564d0104bc364cd4e306f75c7dc77d Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 16:35:55 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=BB=E6=9C=BA=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E5=B1=95=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 13 +++++++++++
views/server.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/index.py b/index.py
index 2cb89aa..0c64990 100644
--- a/index.py
+++ b/index.py
@@ -27,6 +27,7 @@ mods = {
'system_migration': migration.system_migration,
'migration_details': migration.migration_details,
'import_host_info': server.import_host_info,
+ 'host_info_display': server.host_info_display,
}
@app.route('/import_host_info', methods=['GET', 'POST'])
@@ -39,6 +40,18 @@ def import_host_info():
if mod:
return Response(mod, content_type='application/json')
+
+@app.route('/host_info_display', methods=['GET', 'POST'])
+def host_info_display():
+ """
+ 显示主机信息
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
def check_methods():
if request.method == 'POST':
data = request.get_data()
diff --git a/views/server.py b/views/server.py
index cf07d2f..d2ca719 100644
--- a/views/server.py
+++ b/views/server.py
@@ -38,7 +38,6 @@ def import_host_info(data):
return data_json
-
def get_agent_id(agent_ip):
"""
获取agent_id
@@ -77,4 +76,60 @@ def create_task_stream(agent_ip):
create_agent_task_sql = "insert into agent_task(agent_id,agent_ip,task_id,task_status,task_progress," \
"task_CreateTime,task_Updatetime,task_stream_id,task_data) values " \
"(%s, %s, %s, %s, %s, %s, %s, %s, %s);"
- DBHelper().insert(create_agent_task_sql, values)
\ No newline at end of file
+ DBHelper().insert(create_agent_task_sql, values)
+
+
+def pagebreak(data, page, size):
+ """
+ 页面数据分页
+ :param data:
+ :return:
+ """
+ page_start = (page - 1) * size
+ page_end = page * size
+ result = data[page_start:page_end]
+
+ return result
+
+def host_info_display(data):
+ """
+ 显示主机信息
+ agent_ip,hostname,agent_online_status,agent_os,agent_arch,
+ agent_history_faild_reason,task_CreateTime,task_status
+ :return:
+ """
+ page = json.loads(data).get('page')
+ size = json.loads(data).get('size')
+ sql = "select agent_ip,hostname,agent_online_status,agent_os,agent_arch," \
+ "agent_history_faild_reason from agent_info;"
+ data = DBHelper().execute(sql).fetchall()
+ data = list(data)
+ for i in range(0, len(data)):
+ data[i] = list(data[i])
+ agent_task = "select task_CreateTime,task_data from agent_task where agent_ip = '%s';" % data[i][0]
+ get_agent_task = DBHelper().execute(agent_task).fetchall()
+ get_agent_task = list(get_agent_task)
+
+ if not get_agent_task:
+ data[i] += ["", ""]
+ else:
+ task_CreateTime = get_agent_task[0][0].strftime('%Y-%-m-%d %H:%M:%S')
+ task_status = get_agent_task[0][1]
+ data[i].append(task_CreateTime)
+ data[i].append(task_status)
+
+ res = {}
+ res['num'] = len(data)
+ info_list = []
+ info_dict_keys_list = ['agent_ip', 'hostname', 'agent_online_status', 'agent_os', 'agent_arch',
+ 'failure_reasons', 'task_CreateTime', 'task_status']
+ for i in data:
+ info_list.append(dict(zip(info_dict_keys_list, i)))
+
+ page_list = pagebreak(info_list, page, size)
+ res['info'] = page_list
+ res['page'] = page
+ res['size'] = size
+
+ json_res = json.dumps(res)
+ return json_res
\ No newline at end of file
--
2.20.1

View File

@ -1,96 +0,0 @@
From 5866f586616e48dfea53107cf6f8c3364c658951 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 17:08:00 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1=E6=B5=81?=
=?UTF-8?q?=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 13 ++++++++++++-
views/server.py | 31 ++++++++++++++++++++++++++++++-
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/index.py b/index.py
index 0c64990..059431b 100644
--- a/index.py
+++ b/index.py
@@ -4,7 +4,6 @@
# SPDX-License-Identifier: MulanPubL-2.0-or-later
import os
-import sys
import json
from sysmig_agent import share
from views import migration, server
@@ -28,6 +27,7 @@ mods = {
'migration_details': migration.migration_details,
'import_host_info': server.import_host_info,
'host_info_display': server.host_info_display,
+ 'sql_task': server.modify_task_stream,
}
@app.route('/import_host_info', methods=['GET', 'POST'])
@@ -52,6 +52,17 @@ def host_info_display():
return Response(mod, content_type='application/json')
+@app.route('/sql_task', methods=['GET', 'POST'])
+def modify_task_stream():
+ """
+ 修改任务流
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
def check_methods():
if request.method == 'POST':
data = request.get_data()
diff --git a/views/server.py b/views/server.py
index d2ca719..a00e696 100644
--- a/views/server.py
+++ b/views/server.py
@@ -132,4 +132,33 @@ def host_info_display(data):
res['size'] = size
json_res = json.dumps(res)
- return json_res
\ No newline at end of file
+ return json_res
+
+
+def modify_task_stream(data):
+ """
+ 修改任务流状态
+ :return:
+ """
+ task_id = json.loads(data).get('task_id')
+ get_task_status_sql = "select task_status,task_stream_id from agent_task where task_id='%s';" % task_id
+ info = DBHelper().execute(get_task_status_sql).fetchone()
+ task_status = info[0]
+ task_stream_id = info[1]
+ if task_status == 0:
+ task_status = 'None'
+ elif task_status == 1:
+ task_status = 'Doing'
+ elif task_status == 2:
+ task_status = 'Done'
+ else:
+ task_status = 'Cancel'
+ time = datetime.now()
+ modify_task_status_sql = "update cur_task set task_status='%s',stream_Updatetime='%s' " \
+ "where task_id ='%s';" % (task_status, time, task_id)
+ DBHelper().execute(modify_task_status_sql)
+
+ modify_task_stream_sql = "update task_stream set stream_status='%s',stream_Updatetime='%s' " \
+ "where task_stream_id='%s';" % (task_status, time, task_stream_id)
+ DBHelper().execute(modify_task_stream_sql)
+ return 'success'
\ No newline at end of file
--
2.20.1

View File

@ -1,83 +0,0 @@
From 6725378c0a35beed675d7cb73e1f16c712ece59a Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 17:13:41 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E4=B8=BB?=
=?UTF-8?q?=E6=9C=BA=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 13 +++++++++++++
views/server.py | 23 ++++++++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/index.py b/index.py
index 059431b..c51a24c 100644
--- a/index.py
+++ b/index.py
@@ -28,8 +28,10 @@ mods = {
'import_host_info': server.import_host_info,
'host_info_display': server.host_info_display,
'sql_task': server.modify_task_stream,
+ 'delete_host_info': server.delete_host_info,
}
+
@app.route('/import_host_info', methods=['GET', 'POST'])
def import_host_info():
"""
@@ -63,6 +65,17 @@ def modify_task_stream():
return Response(mod, content_type='application/json')
+@app.route('/delete_host_info', methods=['GET', 'POST'])
+def delete_host_info():
+ """
+ 删除迁移主机
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
def check_methods():
if request.method == 'POST':
data = request.get_data()
diff --git a/views/server.py b/views/server.py
index a00e696..e7570b8 100644
--- a/views/server.py
+++ b/views/server.py
@@ -161,4 +161,25 @@ def modify_task_stream(data):
modify_task_stream_sql = "update task_stream set stream_status='%s',stream_Updatetime='%s' " \
"where task_stream_id='%s';" % (task_status, time, task_stream_id)
DBHelper().execute(modify_task_stream_sql)
- return 'success'
\ No newline at end of file
+ return 'success'
+
+
+def delete_host_info(data):
+ """
+ 删除主机信息
+ :return:
+ """
+ data = json.loads(data)
+ for i in data.get('agent_ip'):
+ sql = "delete from agent_info where agent_ip='%s';" % i
+ DBHelper().execute(sql)
+ sql = "delete from agent_task where agent_ip='%s';" % i
+ DBHelper().execute(sql)
+ sql = "delete from task_stream where agent_ip='%s';" % i
+ DBHelper().execute(sql)
+ sql = "delete from cur_task where agent_ip='%s';" % i
+ DBHelper().execute(sql)
+
+ res = {'data': 'success'}
+ json_res = json.dumps(res)
+ return json_res
\ No newline at end of file
--
2.20.1

View File

@ -1,41 +0,0 @@
From 36a4d4629cef2cf5df278fd2ca503b6b84a89751 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:01:24 +0800
Subject: [PATCH] =?UTF-8?q?agent=E8=8E=B7=E5=8F=96=E6=9C=AC=E5=9C=B0IP?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index ec9265b..ea3d63a 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -7,9 +7,20 @@ import platform
import re
import shutil
import subprocess
-
+import socket
from sysmig_agent.utils import list_to_json
+
+def get_local_ip():
+ try:
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.connect(('8.8.8.8', 80))
+ ip = s.getsockname()[0]
+ return ip
+ finally:
+ s.close()
+
+
def getSysMigConf():
confpath = '/etc/migration-tools/migration-tools.conf'
if not os.path.exists(confpath):
--
2.20.1

View File

@ -1,42 +0,0 @@
From a3b140660e4180fdeddc7d2bb8009a78218a9235 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:21:12 +0800
Subject: [PATCH] =?UTF-8?q?agent=E5=A2=9E=E5=8A=A0=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index ea3d63a..aae815c 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -9,7 +9,7 @@ import shutil
import subprocess
import socket
from sysmig_agent.utils import list_to_json
-
+from connect_sql import DBHelper
def get_local_ip():
try:
@@ -20,6 +20,12 @@ def get_local_ip():
finally:
s.close()
+def sql_abi_progress(data):
+ 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
def getSysMigConf():
confpath = '/etc/migration-tools/migration-tools.conf'
--
2.20.1

View File

@ -1,95 +0,0 @@
From 2dacf8188d8bfb223092ac386768b19cf8f4ab64 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 10:23:53 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=AF=BC=E5=85=A5=E4=B8=BB?=
=?UTF-8?q?=E6=9C=BA=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 28 ++++++++++++++++++++--------
views/migration.py | 13 +++++++++++++
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/index.py b/index.py
index c51a24c..edd4440 100644
--- a/index.py
+++ b/index.py
@@ -29,9 +29,20 @@ mods = {
'host_info_display': server.host_info_display,
'sql_task': server.modify_task_stream,
'delete_host_info': server.delete_host_info,
+ 'check_info': migration.check_info,
}
+def check_methods():
+ if request.method == 'POST':
+ data = request.get_data()
+ json_data = json.loads(data)
+ mod = mods.get(json_data['mod'])
+ if mod:
+ response_str = mod(data)
+ return response_str
+
+
@app.route('/import_host_info', methods=['GET', 'POST'])
def import_host_info():
"""
@@ -76,14 +87,15 @@ def delete_host_info():
return Response(mod, content_type='application/json')
-def check_methods():
- if request.method == 'POST':
- data = request.get_data()
- json_data = json.loads(data)
- mod = mods.get(json_data['mod'])
- if mod:
- response_str = mod(data)
- return response_str
+@app.route('/check_info', methods=['GET', 'POST'])
+def check_info():
+ """
+ 检测系统版本和空间大小
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
@app.route('/', methods=['GET', 'POST'])
diff --git a/views/migration.py b/views/migration.py
index f9fe01d..b359d36 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -1,11 +1,24 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: MulanPubL-2.0-or-later
import os
+
+from connect_sql import DBHelper
+from logger import *
+
from flask import *
from client_requests import *
from sysmig_agent.utils import *
+def check_info(data):
+ """
+ 检测系统版本和空间大小
+ :param data:
+ :return:
+ """
+ return 'success'
+
+
def check_services(data, url):
info = post_client_data(data, url)
if info is None or info.status_code != 200:
--
2.20.1

View File

@ -1,43 +0,0 @@
From 0f2c2d8cbda956a27bb0eb3ee1a0dd14a55f8e19 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:27:15 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0abi=E6=A3=80=E6=B5=8B?=
=?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index aae815c..27e8ff8 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -20,6 +20,8 @@ def get_local_ip():
finally:
s.close()
+
+
def sql_abi_progress(data):
sql = "UPDATE agent_task SET task_progress = {} ,task_Updatetime = NOW() WHERE agent_ip = '{}';".format(data, get_local_ip())
try:
@@ -27,6 +29,13 @@ def sql_abi_progress(data):
except:
pass
+
+def abi_file_connect(sql_r):
+ abi_sql = "INSERT INTO agent_ABI_check_result VALUES('"+ get_local_ip()+"'," + sql_r + ',NOW());'
+ s = DBHelper()
+ ret_sql_msg = s.execute(abi_sql)
+
+
def getSysMigConf():
confpath = '/etc/migration-tools/migration-tools.conf'
if not os.path.exists(confpath):
--
2.20.1

View File

@ -1,35 +0,0 @@
From 492a8e59c09991cb8bd1550cf62e849c15e1e517 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:30:03 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1=E8=BF=9B?=
=?UTF-8?q?=E5=BA=A6=E5=92=8C=E8=BF=81=E7=A7=BB=E9=98=B6=E6=AE=B5=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 27e8ff8..0c989a8 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -30,6 +30,13 @@ def sql_abi_progress(data):
pass
+def sql_show_tables():
+ sql = "SELECT task_progress,task_data FROM agent_task WHERE agent_ip = '{}';".format(get_local_ip())
+ ret_sql_msg_info = DBHelper().execute(sql)
+ if ret_sql_msg_info:
+ print(str(ret_sql_msg_info.fetchall()) + '\n')
+
+
def abi_file_connect(sql_r):
abi_sql = "INSERT INTO agent_ABI_check_result VALUES('"+ get_local_ip()+"'," + sql_r + ',NOW());'
s = DBHelper()
--
2.20.1

View File

@ -1,45 +0,0 @@
From 371237696acb7ea7c34191cd629f3dd8d9cff8df Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 10:32:24 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96agent=20ip=E5=9C=B0=E5=9D=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
views/migration.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/views/migration.py b/views/migration.py
index b359d36..7b2f4ed 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -10,6 +10,25 @@ from client_requests import *
from sysmig_agent.utils import *
+def get_agent_ip(data, sql, url):
+ """
+ 获取agent_ip地址
+ :return:
+ """
+ agent_info = DBHelper().execute(sql).fetchall()
+ data = json.loads(data)
+ for i in agent_info:
+ task_status_sql = "select task_status from agent_task where agent_ip='%s'" % list(i)[0]
+ task_status = DBHelper().execute(task_status_sql).fetchall()[0][0]
+ if task_status == 0 or task_status == 2:
+ update_sql = "update agent_task set task_progress=0,task_status=1 where agent_ip='%s'" % list(i)[0]
+ DBHelper().execute(update_sql)
+ get_task_id_sql = "select task_id from cur_task where agent_ip='%s'" % list(i)[0]
+ task_id = DBHelper().execute(get_task_id_sql).fetchall()
+ data['task_id'] = task_id[0][0]
+ json_data = json.dumps(data)
+
+
def check_info(data):
"""
检测系统版本和空间大小
--
2.20.1

View File

@ -1,42 +0,0 @@
From 3a4f5ea15df617babd1f7c39143d01b937bbb417 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:35:43 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E6=9C=BA=E5=9C=A8=E7=BA=BF=E7=8A=B6?=
=?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 0c989a8..abbe452 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -30,6 +30,21 @@ def sql_abi_progress(data):
pass
+def sql_online_statue(statue, task_id):
+ """
+ sqlagent主机的在线状态更新
+ :param statue: 0在线; 1离线
+ :param task_id:agent的json内的task_id
+ :return:
+ """
+ # sql = "UPDATE agent_info SET agent_online_status = {} WHERE agent_ip = {};".format(statue, get_local_ip())
+ sql = "UPDATE agent_info SET agent_online_status = {} WHERE agent_ip = (SELECT agent_ip FROM agent_task WHERE task_id = '{}');".format(
+ statue, task_id)
+ try:
+ ret = DBHelper().execute(sql)
+ except:
+ pass
+
def sql_show_tables():
sql = "SELECT task_progress,task_data FROM agent_task WHERE agent_ip = '{}';".format(get_local_ip())
ret_sql_msg_info = DBHelper().execute(sql)
--
2.20.1

View File

@ -1,38 +0,0 @@
From c92f1168709c3974b33ae04553c58f739909ba99 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:38:27 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=81=E7=A7=BB=E9=98=B6?=
=?UTF-8?q?=E6=AE=B5=E7=9A=84=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index abbe452..5a51266 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -45,6 +45,17 @@ def sql_online_statue(statue, task_id):
except:
pass
+
+def sql_mig_statue(statue):
+ # sql = "UPDATE agent_task SET task_statues = {} , task_Updatetime = NOW() WHERE task_id = '{}';".format(statue, task_id)
+ sql = "UPDATE agent_task SET task_data = '{}' , task_Updatetime = NOW() WHERE agent_ip = '{}';".format(statue,
+ get_local_ip())
+ try:
+ ret = DBHelper().execute(sql)
+ except:
+ pass
+
+
def sql_show_tables():
sql = "SELECT task_progress,task_data FROM agent_task WHERE agent_ip = '{}';".format(get_local_ip())
ret_sql_msg_info = DBHelper().execute(sql)
--
2.20.1

View File

@ -1,48 +0,0 @@
From b627e1aecff4edd096c4ce6cc04486adc04fe89e Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 10:44:12 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0url=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
interaction.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 interaction.py
diff --git a/interaction.py b/interaction.py
new file mode 100644
index 0000000..e4016ab
--- /dev/null
+++ b/interaction.py
@@ -0,0 +1,25 @@
+import requests
+import json
+from sysmig_agent.share import getSysMigConf
+
+headers = {'content-type': 'application/json'}
+
+class Interaction:
+ def __init__(self, url, data):
+ self.url = url
+ self.data = data
+
+ def send_post_requests(self):
+ try:
+ r = requests.post(url=self.url, data=self.data, headers=headers, timeout=10)
+ except:
+ r = None
+ return r
+
+
+def splice_url(data, url, ip):
+ uos_sysmig_conf = json.loads(getSysMigConf(ip))
+ port = json.loads(uos_sysmig_conf).get('agentport').strip()[1:-1]
+ post_url = "http://" + ip + ":" + port + url
+ data = Interaction(post_url, data)
+ return data.send_post_requests()
\ No newline at end of file
--
2.20.1

View File

@ -1,41 +0,0 @@
From 04d1e8e872dab7113d5cc80cd3cdf38e93d4bc30 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:47:31 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=81=E7=A7=BB=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E7=9A=84=E7=8A=B6=E6=80=81=E5=88=B0=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 5a51266..a3b2c2d 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -54,7 +54,18 @@ def sql_mig_statue(statue):
ret = DBHelper().execute(sql)
except:
pass
-
+
+
+def sql_task_statue(statue, task_id = None):
+ if task_id:
+ sql = "UPDATE agent_task SET task_status = {} , task_Updatetime = NOW() WHERE task_id = '{}';".format(statue, task_id)
+ else:
+ sql = "UPDATE agent_task SET task_status = {} , task_Updatetime = NOW() WHERE agent_ip = '{}';".format(statue, get_local_ip())
+ try:
+ ret = DBHelper().execute(sql)
+ except Exception :
+ pass
+
def sql_show_tables():
sql = "SELECT task_progress,task_data FROM agent_task WHERE agent_ip = '{}';".format(get_local_ip())
--
2.20.1

View File

@ -1,55 +0,0 @@
From a5919afd74bff0611aed9f1ebe2064a51c4031e5 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:51:43 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=BF=81=E7=A7=BB=E8=BD=AF?=
=?UTF-8?q?=E4=BB=B6=E6=BA=90=EF=BC=8C=E8=87=AA=E5=8A=A8disable=E6=8E=89?=
=?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=BB=98=E8=AE=A4=E7=9A=84=E8=BD=AF=E4=BB=B6?=
=?UTF-8?q?=E6=BA=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index a3b2c2d..3e7bb30 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -79,6 +79,32 @@ def abi_file_connect(sql_r):
s = DBHelper()
ret_sql_msg = s.execute(abi_sql)
+def local_disabled_release_repo():
+ """
+ 将系统内存在的repository文件置为不可用只保留switch-to-uos.repo
+ :return:
+ """
+ path = '/etc/yum.repos.d'
+ if os.path.exists(path):
+ file_list = os.listdir(path)
+ for file in file_list:
+ fpath = os.path.join(path, file)
+ if os.path.isdir(fpath):
+ continue
+ else:
+ if re.fullmatch('switch-to-uos.repo', file, re.IGNORECASE):
+ continue
+ elif not re.search('repo', file, re.IGNORECASE):
+ continue
+ with open(fpath, 'r') as fdst:
+ allrepo = fdst.read()
+ fdst.close()
+ with open(fpath + '.disabled', 'w+') as fdst:
+ fdst.write(
+ '#This is a yum repository file that was disabled . <Migration to UiniontechOS>\n' + allrepo)
+ fdst.close()
+ os.remove(fpath)
+
def getSysMigConf():
confpath = '/etc/migration-tools/migration-tools.conf'
--
2.20.1

View File

@ -1,111 +0,0 @@
From b47bd5687781d5c82d1cd267c11c690fd01c5317 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:57:31 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=81=E7=A7=BB=E5=90=8E?=
=?UTF-8?q?=E5=BC=95=E5=AF=BC=E9=A1=B9=E8=A6=86=E7=9B=96=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?=E4=B8=8D=E5=85=A8=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 53 ++++++++++++++++++++++++++++++-------------
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 3e7bb30..68fcfa0 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -106,6 +106,8 @@ def local_disabled_release_repo():
os.remove(fpath)
+
+
def getSysMigConf():
confpath = '/etc/migration-tools/migration-tools.conf'
if not os.path.exists(confpath):
@@ -234,45 +236,64 @@ def process_special_pkgs():
def title_conf(oldosname):
- oldosname=oldosname.strip()
+ """
+ Change the boot start option after system migration
+ :param oldosname:old system name
+ :return:
+ """
+ oldosname = oldosname.strip()
+ if oldosname == 'redhat':
+ capital = 'Red Hat'
+ elif oldosname == 'centos':
+ capital = 'CentOS'
path = '/boot/loader/entries'
- #path='/root/a'
+ # path='/root/a'
if os.path.exists(path):
file_list = os.listdir(path)
else:
return None
fl = False
for file in file_list:
- fpath = os.path.join(path,file)
+ fpath = os.path.join(path, file)
if os.path.isdir(fpath):
continue
else:
- with open(fpath,'r') as fp:
+ with open(fpath, 'r') as fp:
strall = fp.read()
fp.close()
- if re.search('uniontech',strall,re.IGNORECASE):
+ if re.search('uniontech', strall, re.IGNORECASE):
fl = True
for file in file_list:
- ustr=None
- fpath = os.path.join(path,file)
+ ustr = None
+ brackets = ""
+ fpath = os.path.join(path, file)
if os.path.isdir(fpath):
continue
else:
- with open(fpath,'r') as fp:
+ with open(fpath, 'r') as fp:
strall = fp.read()
fp.close()
- if re.search(oldosname,strall,re.IGNORECASE):
+ '''
+ if re.search(oldosname, strall, re.IGNORECASE):
if fl:
os.remove(fpath)
continue
else:
- ustr = re.sub(oldosname,"UniontechOS",strall,1,flags=re.IGNORECASE)
- if re.search('8 \(Core\)',strall):
- ustr = re.sub(' 8 ',' 20 ',ustr,1,flags=re.IGNORECASE)
- ustr = re.sub("Core","kongzi",ustr,1,flags=re.IGNORECASE)
- with open(fpath,'w') as ptitle:
- ptitle.write(ustr)
- ptitle.close()
+ print(strall,capital)
+ ustr = re.sub(capital, "UniontechOS", strall, 1, flags=re.IGNORECASE)
+ '''
+ if re.search(capital, strall):
+ line = strall.split('\n', -1)[0]
+ for char in range(len(line)):
+ if line[char] == '(':
+ p = char
+ continue
+ if line[char] == ')':
+ e = char+1
+ brackets = line[p:e]
+ break
+ title = 'title UniontechOS Linux ' + brackets + ' 20 (kongzi)'
+ open(fpath, 'w').write(strall.replace(line, title))
def main_conf(osname):
--
2.20.1

View File

@ -1,61 +0,0 @@
From add93aadd87a53dc960b1e0d2fdb6ed4cb4e2d30 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
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

View File

@ -1,86 +0,0 @@
From dd381efe588297b6f450665d374fcaafab0206e5 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 11:07:17 +0800
Subject: [PATCH] =?UTF-8?q?json=E5=92=8Clist=E6=A0=BC=E5=BC=8F=E4=BA=92?=
=?UTF-8?q?=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 68fcfa0..1a12a7e 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -1,14 +1,17 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: MulanPubL-2.0-or-later
-import logging
import os
-import platform
+import sys
+import json
import re
-import shutil
import subprocess
+import shutil
import socket
-from sysmig_agent.utils import list_to_json
+import platform
+import logging
+
+sys.path.append("..")
from connect_sql import DBHelper
def get_local_ip():
@@ -192,17 +195,19 @@ def get_disk_info(string):
def add_boot_option():
- print("Current system is uefi, add boot option to boot manager.")
- subprocess.run('which efibootmgr > /dev/null 2>&1 || dnf install -y efibootmgr', shell=True)
+ """
+ Current system is uefi, add boot option to boot manager.
+ """
+ subprocess.run('which efibootmgr > /dev/null 2>&1 || yum install -y efibootmgr', shell=True)
disk_name = subprocess.check_output('mount | grep /boot/efi | awk \'{print $1}\'', shell=True)
disk_name = str(disk_name, 'utf-8')
disk_name = disk_name.split('\n')[0]
- dev_name,part_num = get_disk_info(disk_name)
+ dev_name, part_num = get_disk_info(disk_name)
if dev_name == "" or part_num == "":
- print("Parse /boot/efi disk info failed, update boot loader failed.")
+ # "Parse /boot/efi disk info failed, update boot loader failed.
return
- cmd=""
+ cmd = ""
arch = platform.machine()
if arch == "x86_64":
cmd = 'efibootmgr -c -d ' + dev_name + ' -p ' + part_num + ' -l "/EFI/uos/grubx86.efi" -L "Uniontech OS"'
@@ -296,6 +301,18 @@ def title_conf(oldosname):
open(fpath, 'w').write(strall.replace(line, title))
+def json_list_to_json(keylist, valuelist):
+ res = dict(zip(keylist, valuelist))
+ # logdss.info (res)
+ return json.dumps(res)
+
+def list_to_json(keylist, valuelist):
+ res = dict(zip(keylist, valuelist))
+ res = json.dumps(res)
+ # logdss.info (res)
+ return json.dumps(res)
+
+
def main_conf(osname):
logger = logging.getLogger()
logger.setLevel(logging.INFO)
--
2.20.1

View File

@ -1,57 +0,0 @@
From 88d87089720784e3dd57b1f780e5ecc398ed03be Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 11:20:58 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=90=8E=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 1a12a7e..6b8da14 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -368,3 +368,36 @@ def main_conf(osname):
logger.info("Switch complete.UniontechOS recommends rebooting this system.")
return 0
+
+
+def sql_os_newversion(localos):
+ sql = "UPDATE agent_info SET agent_migration_os = '{}' WHERE agent_ip = '{}';".format(localos, get_local_ip())
+ try:
+ ret = DBHelper().execute(sql)
+ except:
+ pass
+
+
+def get_new_osversion():
+ new_os = '统信服务器操作系统V20({})'
+ path = '/etc/os-version'
+ if os.path.exists(path):
+ with open(path,'r') as v:
+ ret = v.readlines()
+ localos=ostype=''
+ for i in range(len(ret)):
+ if not ret[i]:
+ continue
+ if 'MinorVersion' in ret[i]:
+ strminor = str(ret[i])
+ _, localos = strminor.split('=',1)
+ if 'EditionName[zh_CN]' in ret[i]:
+ strminor = str(ret[i])
+ _, ostype = strminor.split('=',1)
+ ostype = re.sub('[^a-zA-Z]+','',ostype)
+ localos = localos.strip().strip('\n') + ostype.strip().strip('\n')
+ localos = new_os.format(localos.strip().strip('\n'))
+ sql_os_newversion(localos)
+
+ else:
+ sql_os_newversion('NULL')
--
2.20.1

View File

@ -1,72 +0,0 @@
From 1d617ae642fc8236c2ec2cb8b0782a7584987771 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 11:27:00 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=A3=80=E6=B5=8B=E5=92=8C?=
=?UTF-8?q?=E9=83=A8=E5=88=86=E5=AE=8F=E6=8F=90=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 6b8da14..57bef1e 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -14,6 +14,43 @@ import logging
sys.path.append("..")
from connect_sql import DBHelper
+defaultencoding = 'utf-8'
+# logdss = Logger('./logdss.log',logging.DEBUG,logging.DEBUG)
+new_os = '统信服务器操作系统V20({})'
+AGENT_DIR = '/var/tmp/uos-migration/'
+PRE_MIG = '/var/tmp/uos-migration/UOS_analysis_report/rpmva-before.txt'
+PRE_MIG_DIR = '/var/tmp/uos-migration/UOS_analysis_report'
+MIGRATION_DIR = '/var/tmp/uos-migration/UOS_migration_log'
+MIGRATION_REPORT_DIR = '/var/tmp/uos-migration/UOS_migration_completed_report'
+
+
+PROGRESS = '/var/tmp/uos-migration/.progress'
+RPMS = '/var/tmp/uos-migration/.rpms'
+MIGRATION_KERNEL = '/var/tmp/uos-migration/kernel'
+MIGRATION_LOG = '/var/tmp/uos-migration/UOS_migration_log/log'
+MIGRATION_DATA_RPMS_DIR = '/var/tmp/uos-migration/data/exp-rst'
+MIGRATION_DATA_RPMS_3_INFO = '/var/tmp/uos-migration/data/exp-rst/pkginfo_3.txt'
+pstate = '/var/tmp/uos-migration/.state'
+
+abi_file = '/var/tmp/uos-migration/data/exp-rst/agent_ABI_check_result.csv'
+#Abi
+local_dir = '/var/tmp/uos-migration/data/'
+exp_rst_dir = local_dir+'exp-rst/'
+
+current_system_unique = exp_rst_dir + 'current-system-unique.csv'
+migration_system_install = exp_rst_dir + 'migration-system-install.csv'
+migration_system_total = exp_rst_dir + 'migration-system-total.csv'
+abi_comp_chk = exp_rst_dir + 'abi-comp-chk.csv'
+abi_incomp_chk = exp_rst_dir + 'abi-incomp-chk.csv'
+exitFlag = 0
+total_rpm_nums = 0
+percentage = ''
+deal_rpm_num = 0
+agent_abi_check_result = exp_rst_dir + 'agent_ABI_check_result.csv'
+suffix_list = ['.mo', '.gz', '.xml', '.conf', '.png', '.page', '.woff', '.ttf', '.pyc', '.typelib', '.pdf', '.ppt', '.txt', '.ico', '.icc', '.tcc', '.gif', '.oga', '.rom', '.jpg', '.dict', '.webm', '.pyc', '.wav', '.ucode', '.ttc', '.gresource', '.otf', '.t1', '.db', '.elc', '.cache', '.fd', '.iso', '.efi', '.mmdb', '.bz2', '.img', '.bin', '.fw', '.cis', '.itb', '.inp', '.sbcf', '.ddc', '.sfi', '.bseq', '.mfa2', '.chk', '.mgc', '.stub', '.dfu', '.dat', '.sys', '.bts', '.dlmem', '.brd', '.hwm', '.pwd', '.pwi', '.exe', '.der', '.p12', '.ogg', '.signed', '.dafsa', '.gpg', '.tri', '.x86_64']
+
+
+
def get_local_ip():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -379,7 +416,6 @@ def sql_os_newversion(localos):
def get_new_osversion():
- new_os = '统信服务器操作系统V20({})'
path = '/etc/os-version'
if os.path.exists(path):
with open(path,'r') as v:
--
2.20.1

View File

@ -1,160 +0,0 @@
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

View File

@ -1,76 +0,0 @@
From 40d5cb8b4956b7a40ce04c9e54acbecdca196691 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 13:37:59 +0800
Subject: [PATCH] =?UTF-8?q?=E5=86=85=E6=A0=B8=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 12 ++++++++++++
views/migration.py | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/index.py b/index.py
index edd4440..f0bf10d 100644
--- a/index.py
+++ b/index.py
@@ -30,6 +30,7 @@ mods = {
'sql_task': server.modify_task_stream,
'delete_host_info': server.delete_host_info,
'check_info': migration.check_info,
+ 'check_kernel': migration.check_kernel,
}
@@ -98,6 +99,17 @@ def check_info():
return Response(mod, content_type='application/json')
+@app.route('/check_kernel', methods=['GET', 'POST'])
+def check_kernel():
+ """
+ 下发检测agent内核版本和软件仓库内核版本
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
diff --git a/views/migration.py b/views/migration.py
index 985a1bf..d9ac551 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -53,6 +53,7 @@ def get_agent_ip(data, sql, url):
task_id = DBHelper().execute(get_task_id_sql).fetchall()
data['task_id'] = task_id[0][0]
json_data = json.dumps(data)
+ send_task_to_agent(json_data, url, list(i)[0])
def check_info(data):
@@ -66,6 +67,17 @@ def check_info(data):
return 'success'
+def check_kernel(data):
+ """
+ 检测agent内核版本和软件仓库内核版本
+ :param data:
+ :return:
+ """
+ sql = "select agent_ip from agent_info where agent_online_status=0 and agent_storage>=10 and repo_status=0;"
+ get_agent_ip(data, sql, '/check_kernel')
+ return 'success'
+
+
def check_services(data, url):
info = post_client_data(data, url)
if info is None or info.status_code != 200:
--
2.20.1

View File

@ -1,77 +0,0 @@
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

View File

@ -1,43 +0,0 @@
From 103d2cfcdbc7096ac0fa2298ee6f4ec6948c3b6a Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 13:59:30 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=BF=87=E7=A8=8B=E5=8F=AF?=
=?UTF-8?q?=E9=80=89=E6=8B=A9=E4=B8=8D=E8=BF=81=E7=A7=BB=E5=86=85=E6=A0=B8?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/migration.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index 76b3b8e..e510680 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -103,3 +103,21 @@ def Sysmig(kernel_version):
run_cmd2file(cmd)
sql_mig_statue('3')
+
+def ifnot_mig_kernel(kernel_version):
+ with open('/etc/yum.conf', 'r') as f:
+ content = f.read()
+ f.close()
+ if re.search(r'^distroverpkg=', content, re.MULTILINE):
+ content = re.sub(r"\n(distroverpkg=)", r"\n#\1", content)
+ if re.search(r'bugtracker_url=', content, re.MULTILINE):
+ content = re.sub(r"\n(bugtracker_url=)", r"\n#\1", content)
+ with open('/etc/yum.conf', 'w') as f:
+ f.write(content)
+ f.close()
+ if kernel_version == '0' or kernel_version == '3.10.0':
+ kernel_patterns = 'exclude= kernel* kernel-tools python3-perf kernel-headers kernel-devel bpftool perf kernel-core kmod-kvdo kpatch glibc-headers \n'
+ with open('/etc/yum.conf', 'a+') as f:
+ f.write(kernel_patterns)
+ f.close()
+
--
2.20.1

View File

@ -1,46 +0,0 @@
From b3450704f0ebc4092848a0764d888898a47cece7 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 14:02:24 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=86=85=E6=A0=B8=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/index.py b/index.py
index f0bf10d..f6a171f 100644
--- a/index.py
+++ b/index.py
@@ -31,6 +31,7 @@ mods = {
'delete_host_info': server.delete_host_info,
'check_info': migration.check_info,
'check_kernel': migration.check_kernel,
+ 'get_kernel_data': server.get_kernel_data,
}
@@ -110,6 +111,17 @@ def check_kernel():
return Response(mod, content_type='application/json')
+@app.route('/get_kernel_data', methods=['GET', 'POST'])
+def get_kernel_data():
+ """
+ 获取系统内核和仓库内核版本
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
--
2.20.1

View File

@ -1,71 +0,0 @@
From e59fe433c7e013d76a26c9e268a4d3d69c2afb43 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:02:37 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0subprocess=E9=80=9A=E8=BF=87?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 47 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 57bef1e..9e7bd35 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -437,3 +437,50 @@ def get_new_osversion():
else:
sql_os_newversion('NULL')
+
+
+def run_subprocess(cmd="", print_cmd=True, print_output=True):
+ """Call the passed command and optionally log the called command (print_cmd=True) and its
+ output (print_output=True). Switching off printing the command can be useful in case it contains
+ a password in plain text.
+ """
+ cwdo = '/var/tmp/uos-migration/UOS_migration_log/mig_log.txt'
+ cwde = '/var/tmp/uos-migration/UOS_migration_log/mig_err.txt'
+ # fderr = open(cwde, 'a')
+ # from logging import *
+ # if print_cmd:
+ # log.debug("Calling command '%s'" % cmd)
+
+ # Python 2.6 has a bug in shlex that interprets certain characters in a string as
+ # a NULL character. This is a workaround that encodes the string to avoid the issue.
+ if print_output:
+ fdout = open(cwdo, 'a')
+ fderr = open(cwde, 'a')
+ if sys.version_info[0] == 2 and sys.version_info[1] == 6:
+ cmd = cmd.encode("ascii")
+ # cmd = shlex.split(cmd, False)
+ process = subprocess.Popen(
+ cmd,
+ # stdout=subprocess.PIPE,
+ # stderr=subprocess.STDOUT,
+ stdout=fdout,
+ stderr=fderr,
+ bufsize=1,
+ shell=True
+ )
+ output = ""
+ try:
+ for line in iter(process.stdout.readline, b""):
+ output += line.decode()
+ except:
+ pass
+
+ # loggerinst.info(line.decode().rstrip("\n"))
+
+ # Call communicate() to wait for the process to terminate so that we can get the return code by poll().
+ # It's just for py2.6, py2.7+/3 doesn't need this.
+ process.communicate()
+
+ return_code = process.poll()
+ return output, return_code
+
--
2.20.1

View File

@ -1,56 +0,0 @@
From 05c4f0df087afa8b95ba5f365a55cee52cdd8d56 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 14:08:34 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=86=85=E6=A0=B8=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
views/server.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/views/server.py b/views/server.py
index e7570b8..71cbb8e 100644
--- a/views/server.py
+++ b/views/server.py
@@ -181,5 +181,34 @@ def delete_host_info(data):
DBHelper().execute(sql)
res = {'data': 'success'}
+ json_res = json.dumps(res)
+ return json_res
+
+
+def get_kernel_data(data):
+ """
+ 获取系统内核和仓库内核版本
+ :return:
+ """
+ get_kernel_version_sql = 'select agent_ip,agent_kernel,agent_repo_kernel from agent_info where ' \
+ 'agent_online_status=0 and repo_status=0 and agent_storage>=10 and ' \
+ 'agent_migration_os is null;'
+ data = DBHelper().execute(get_kernel_version_sql).fetchall()
+ res = {}
+ info_list = []
+ info_dict_keys_list = ['agent_ip', 'agent_kernel', 'agent_repo_kernel']
+ if len(data) != 0:
+ for i in data:
+ if i[1] and i[2]:
+ kernel_arr = ('不迁移内核' + ',' + i[2]).split(',')
+ kernel_list = list(i)
+ kernel_list[2] = kernel_arr
+ else:
+ kernel_list = [list(i)[0], '', '']
+ info_list.append(dict(zip(info_dict_keys_list, kernel_list)))
+
+ res['info'] = info_list
+ res['num'] = len(info_list)
+
json_res = json.dumps(res)
return json_res
\ No newline at end of file
--
2.20.1

View File

@ -1,74 +0,0 @@
From 6047fe2bac9d1b63fd9099f1ca4944cc9c647d0a Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:10:28 +0800
Subject: [PATCH] =?UTF-8?q?repo=E6=96=87=E4=BB=B6=E9=80=89=E6=8B=A9kernel?=
=?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 | 50 +++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index e510680..00b3c89 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -121,3 +121,53 @@ def ifnot_mig_kernel(kernel_version):
f.write(kernel_patterns)
f.close()
+def disable_exclude():
+ with open('/etc/yum.conf', 'r') as f:
+ content = f.read()
+ f.close()
+ if re.search(r'^exclude=', content, re.MULTILINE):
+ content = re.sub(r"\n(exclude=)", r"\n#\1", content)
+ #content = re.sub(r"\nexclude=", r"\n#exclude=", content)
+ with open('/etc/yum.conf','w+') as f:
+ f.write(content)
+ f.close()
+
+
+# migration kernel
+def mig_kernel(kernel_version):
+ disable_exclude()
+ cwd = '/var/tmp/uos-migration/kernel/'
+ if not os.path.exists(cwd):
+ os.mkdir(cwd)
+ ret = os.listdir(cwd)
+ for i in ret:
+ os.unlink(cwd+i)
+ cmd = ' rpm -qa | grep "kernel\|bpftool\|perf" |xargs -i rpm -q --qf "%{NAME}\\n" {}'
+ if '0' == kernel_version:
+ return None
+ else:
+ repo = ''
+ if '4.18.0' == kernel_version:
+ repo = 'UniontechOS-kernel-'+kernel_version.strip()
+ elif '5.10.0' == kernel_version:
+ repo = 'UniontechOS-kernel-'+kernel_version.strip()
+ elif '3.10.0' == kernel_version:
+ repo = 'UniontechOS-kernel-' + kernel_version.strip()
+ else:
+ return 1
+ down_cmd = 'yumdownloader --destdir "/var/tmp/uos-migration/kernel" --enablerepo '+repo
+ ret = os.popen(cmd).readlines()
+ for i in ret:
+ downpackage = down_cmd+' '+i.strip()+'-'+kernel_version.strip()
+ # os.system(downpackage)
+ run_subprocess(downpackage)
+
+ cwd = '/var/tmp/uos-migration/kernel/'
+ if os.listdir(cwd):
+ cmd = 'rpm -Uvh "{}*" --nodeps --oldpackage'.format(cwd)
+ # os.system(cmd)
+ run_subprocess(cmd)
+ else:
+ # loggen.debug('Can not download kernel .')
+ #log.err
+ return 1
--
2.20.1

View File

@ -1,54 +0,0 @@
From ec2e4820e87b355faf0c3a92dc0b22ddb326b7b6 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:17:57 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E5=92=8C=E7=BC=93=E5=AD=98=E6=96=87=E4=BB=B6=E5=88=9B=E5=BB=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/migration.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index 00b3c89..ef78ed8 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -171,3 +171,33 @@ def mig_kernel(kernel_version):
# loggen.debug('Can not download kernel .')
#log.err
return 1
+
+
+def init_log_dir():
+ if not os.path.isdir(PRE_MIG_DIR):
+ os.makedirs(PRE_MIG_DIR)
+ if not os.path.isdir(MIGRATION_KERNEL):
+ os.makedirs(MIGRATION_KERNEL)
+ if not os.path.isdir(MIGRATION_DIR):
+ os.makedirs(MIGRATION_DIR)
+ if not os.path.isdir(MIGRATION_DATA_RPMS_DIR):
+ os.makedirs(MIGRATION_DATA_RPMS_DIR)
+ if not os.path.exists(PROGRESS):
+ with open(PROGRESS,'w+') as fp:
+ fp.write(' ')
+ fp.close()
+ if not os.path.exists(MIGRATION_DATA_RPMS_3_INFO):
+ with open(MIGRATION_DATA_RPMS_3_INFO,'w+') as fp:
+ fp.write(' ')
+ fp.close()
+ if not os.path.exists(MIGRATION_LOG):
+ with open(MIGRATION_LOG,'w+') as fp:
+ fp.write(' ')
+ fp.close()
+ if not os.path.exists(PRE_MIG):
+ with open(PRE_MIG,'w+') as fp:
+ fp.write(' ')
+ fp.close()
+ migInit_porgress()
+
+
--
2.20.1

View File

@ -1,33 +0,0 @@
From ec7c2d5065e3aeab507bcc4f10e667e7712df201 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:21:06 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE=E5=BA=93?=
=?UTF-8?q?=E8=BF=81=E7=A7=BB=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/migration.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index ef78ed8..6dddb7b 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -201,3 +201,12 @@ def init_log_dir():
migInit_porgress()
+def get_mig_state(task_id):
+ sql = "SELECT task_data FROM agent_task WHERE task_id = {} ;".format(task_id)
+ ret_sql_msg_info = DBHelper().execute(sql)
+ try:
+ state = ret_sql_msg_info.fetchall()[0][0]
+ if len(state):
+ return str(state)
+ except:
+ return None
--
2.20.1

View File

@ -1,35 +0,0 @@
From 8dbb02f7ffc89e6e5f3a634dac500b197028124d Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:24:51 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=8Eagent=5Finfo=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=B3=BB=E7=BB=9F=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/migration.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index 6dddb7b..ebee24d 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -210,3 +210,14 @@ def get_mig_state(task_id):
return str(state)
except:
return None
+
+
+def get_old_osnameversion():
+ sql = "SELECT agent_os FROM agent_info WHERE agent_ip = '{}' ;".format(get_local_ip())
+ ret_sql_msg_info = DBHelper().execute(sql)
+ try:
+ state = ret_sql_msg_info.fetchall()[0][0]
+ if len(state):
+ return str(state)
+ except:
+ return None
--
2.20.1

View File

@ -1,38 +0,0 @@
From 1683b7dbd84ce4bdc399d3da731c9c5b22ed07fe Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:33:19 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=B3=BB=E7=BB=9F=E7=89=88?=
=?UTF-8?q?=E6=9C=AC=E5=92=8C=E7=B3=BB=E7=BB=9F=E5=90=8D=E7=A7=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/migration.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
index ebee24d..fec143a 100644
--- a/sysmig_agent/migration.py
+++ b/sysmig_agent/migration.py
@@ -221,3 +221,17 @@ def get_old_osnameversion():
return str(state)
except:
return None
+
+
+def get_old_osname():
+ nv = get_old_osnameversion()
+ oldosname = re.sub(r'[0-9]', '', nv)
+ return oldosname
+
+
+def get_old_osversion():
+ nv = get_old_osnameversion()
+ oldosversion = re.sub(r'[A-Z,a-z]', '', nv)
+ return oldosversion
+
+
--
2.20.1

View File

@ -1,75 +0,0 @@
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

View File

@ -1,80 +0,0 @@
From 481d09eba9e03bda1d87fc9d21451634d23fff30 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 14:47:54 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9repo=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 13 ++++++++++++-
views/migration.py | 15 ++++++++++++---
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/index.py b/index.py
index f6a171f..9665e29 100644
--- a/index.py
+++ b/index.py
@@ -18,7 +18,6 @@ mods = {
'check_os_kernel': migration.check_os_kernel,
'check_migration_progress': migration.check_migration_progress,
'check_progress': migration.check_progress,
- 'check_repo': migration.check_repo,
'check_repo_kernel': migration.check_repo_kernel,
'check_user': migration.check_user,
'close_tool': migration.close_tool,
@@ -32,6 +31,7 @@ mods = {
'check_info': migration.check_info,
'check_kernel': migration.check_kernel,
'get_kernel_data': server.get_kernel_data,
+ 'check_repo': migration.check_repo,
}
@@ -122,6 +122,17 @@ def get_kernel_data():
return Response(mod, content_type='application/json')
+@app.route('/check_repo', methods=['GET', 'POST'])
+def check_repo():
+ """
+ 检测平台软件仓库
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
diff --git a/views/migration.py b/views/migration.py
index d9ac551..a628694 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -123,9 +123,18 @@ def check_user(data):
def check_repo(data):
- services = check_services(data, '/check_repo')
- if services:
- return services
+ """
+ 检测平台软件仓库
+ :param data:
+ :return:
+ """
+ sql = "select agent_ip from agent_info where agent_online_status = 0 and agent_storage >= 10;"
+ agent_ip_list = DBHelper().execute(sql)
+ for i in agent_ip_list:
+ repo_status_sql = "update agent_info set repo_status='2' where agent_ip='%s'" % list(i)[0]
+ DBHelper().execute(repo_status_sql)
+ get_agent_ip(data, sql, '/check_repo')
+ return 'success'
def check_os_kernel(data):
--
2.20.1

View File

@ -1,72 +0,0 @@
From a55f866eee6a937842777af38beee70ec1cad8e4 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 14:55:44 +0800
Subject: [PATCH] =?UTF-8?q?agent=E5=90=91server=E5=8F=91=E9=80=81=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E6=9B=B4=E6=96=B0=E8=AF=B7=E6=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/agent_request.py | 49 +++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 sysmig_agent/agent_request.py
diff --git a/sysmig_agent/agent_request.py b/sysmig_agent/agent_request.py
new file mode 100644
index 0000000..31d0cfe
--- /dev/null
+++ b/sysmig_agent/agent_request.py
@@ -0,0 +1,49 @@
+# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+# SPDX-License-Identifier: MulanPubL-2.0-or-later
+
+import requests
+import json
+from sysmig_agent.share import getSysMigConf ,json_list_to_json, sql_online_statue
+
+uos_sysmig_conf = json.loads(getSysMigConf())
+ip = json.loads(uos_sysmig_conf).get('serverip').strip()[1:-1]
+port = int(json.loads(uos_sysmig_conf).get('serverport').strip()[1:-1])
+mod_sql = '/sql_task'
+
+headers = {'content-type': 'application/json'}
+
+
+class PostIntranetIP:
+ def __init__(self, url, data):
+ self.url = url
+ self.data = data
+
+ def post_intranetip(self):
+ try:
+ r = requests.post(url=self.url, data=self.data, headers=headers)
+ except:
+ r = None
+ return r
+
+
+def post_client_data(data):
+ post_url = "http://" + ip + ":" + str(port) + mod_sql
+ print('______>post:'+post_url+'\n____> data: '+str(data) +'ip port '+ip+str(port))
+ post_data = PostIntranetIP(post_url, data)
+ return post_data.post_intranetip()
+
+
+def post_server(statue, task_id):
+ keylist = ['mod','statue','task_id']
+ valuelist = ['sql_task',statue,str(task_id)]
+ data = json_list_to_json(keylist,valuelist)
+
+# data={"mod":"sql_task", "statue": "task_start", "task_id":2}
+ t = post_client_data(data)
+ print("requires post return code :"+str(t))
+ f = 0
+ if not t or t.status_code != 200:
+ t = post_client_data(data)
+ sql_online_statue(1, task_id)
+ else:
+ sql_online_statue(0, task_id)
--
2.20.1

View File

@ -1,102 +0,0 @@
From 0dfa49f9703103dd8f978d419555f5a4e8d72caf Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 15:01:48 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=BD=AF=E4=BB=B6=E6=BA=90?=
=?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=86=85=E6=A0=B8=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/short_task.py | 79 ++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
create mode 100644 sysmig_agent/short_task.py
diff --git a/sysmig_agent/short_task.py b/sysmig_agent/short_task.py
new file mode 100644
index 0000000..1e1a1c8
--- /dev/null
+++ b/sysmig_agent/short_task.py
@@ -0,0 +1,79 @@
+# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+# SPDX-License-Identifier: MulanPubL-2.0-or-later
+
+# import os
+# import platform
+# from share import list_to_json
+# import sys
+# import re
+# import subprocess
+# import json
+from sysmig_agent.share import *
+from flask import Flask, render_template, url_for, redirect, make_response, session, Response
+import urllib.request
+from sysmig_agent.agent_request import post_server
+
+sys.path.append("..")
+from connect_sql import DBHelper
+
+
+def os_kernel():
+ platformInfo = platform.platform()
+ systemKernelVersion = platformInfo.split('-', -1)
+ agent_kernel = systemKernelVersion[1]
+ return agent_kernel
+
+
+
+def os_repo_kernel():
+ version_list = []
+ os_version_ret = platform.dist()
+ version = os_version_ret[1].split('.', -1)
+ AGENT_OS = os_version_ret[0] + version[0]
+ try:
+ ret = os.popen("yum repolist all|awk '{print $1}'")
+ except:
+ ret = os.popen("yum repolist --all|awk '{print $1}'")
+ kernel_repo = kernel_repo_name = []
+ str_kernel = ''
+ for r in ret.readlines():
+ if not r:
+ continue
+ if 'UniontechOS' in r:
+ kernel_repo.append(r.strip('\n'))
+ if '8' == version[0]:
+ for i in range(len(kernel_repo)):
+ # cmd = 'yum repoquery --nvr kernel --enablerepo ' + kernel_repo[i]
+ cmd = 'yum repoquery --repo ' + kernel_repo[i] + ' kernel'
+ ret = str(subprocess.check_output(cmd, shell=True), 'utf-8')[:-1]
+ # except Exception:
+ ret = ret.split('\n', -1)
+ for i in range(len(ret)):
+ if re.match('kernel', ret[i]):
+ kernel_version = re.sub('kernel-.*:', '', ret[i])
+ kernel_version = re.sub('-.*$', '', kernel_version)
+ version_list.append(kernel_version.strip())
+ if not str_kernel:
+ str_kernel = kernel_version.strip()
+ else:
+ str_kernel = str_kernel + ',' + kernel_version.strip()
+ # print(version_list)
+ elif '7' == version[0]:
+ for i in range(len(kernel_repo)):
+ cmd = 'yum list --enablerepo {} kernel'.format(kernel_repo[i])
+ if '3.10.0' in kernel_repo[i]:
+ cmd = 'yum list --enablerepo {} --disablerepo UniontechOS-AppStream kernel'.format(kernel_repo[i])
+ ret = str(subprocess.check_output(cmd, shell=True), 'utf-8')[:-1]
+ ret = ret.split('\n', -1)
+ for n in range(len(ret)):
+ if 'uelc' in ret[n]:
+ # kernel_version = re.sub('kernel-.* ', '', ret[n])
+ kernel_version = re.sub('-.*$', '', ret[n])
+ kernel_version = kernel_version.split(' ',-1)
+ kernel_version = kernel_version[len(kernel_version)-1]
+ version_list.append(kernel_version.strip())
+ if not str_kernel:
+ str_kernel = kernel_version.strip()
+ else:
+ str_kernel = str_kernel + ',' + kernel_version.strip()
+ return str_kernel
--
2.20.1

View File

@ -1,50 +0,0 @@
From 0e0d63d10ebbd4ee9a0f755e2a1178a69e3d6d9e Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 15:05:30 +0800
Subject: [PATCH] =?UTF-8?q?server=E4=B8=8B=E5=8F=91=E6=A3=80=E6=B5=8B?=
=?UTF-8?q?=E5=86=85=E6=A0=B8=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/short_task.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/sysmig_agent/short_task.py b/sysmig_agent/short_task.py
index 1e1a1c8..23d461b 100644
--- a/sysmig_agent/short_task.py
+++ b/sysmig_agent/short_task.py
@@ -77,3 +77,29 @@ def os_repo_kernel():
else:
str_kernel = str_kernel + ',' + kernel_version.strip()
return str_kernel
+
+
+
+def check_kernel(data):
+ task_id = json.loads(data).get('task_id')
+ # 更新SQL任务开始状态
+ sql_task_statue('1', task_id)
+ # 发送消息给Server更新任务流状态
+ post_server('task_start', task_id )
+ # agent kernel
+ agent_kernel = os_kernel()
+ # agent repo kernel
+ agent_repo_kernel = os_repo_kernel()
+ agent_ip = get_local_ip()
+ statue = 1
+ sql = "UPDATE agent_info SET agent_kernel = '{}',agent_repo_kernel = '{}' WHERE agent_ip = '{}';".format(
+ agent_kernel, agent_repo_kernel, agent_ip)
+ try:
+ DBHelper().execute(sql)
+ statue = 2
+ except:
+ statue = 3
+ sql_task_statue(statue, task_id)
+ sql_task_statue(statue, task_id)
+ post_server('task_close', task_id)
+ return 's'
--
2.20.1

View File

@ -1,46 +0,0 @@
From 7cbf75c501a0c8bc21c2c9ca041b3f283ec4a0ca Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 15:07:45 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=BD=AF=E4=BB=B6=E4=BB=93?=
=?UTF-8?q?=E5=BA=93=E6=A3=80=E6=B5=8B=E7=BB=93=E6=9E=9C=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/index.py b/index.py
index 9665e29..d76404e 100644
--- a/index.py
+++ b/index.py
@@ -32,6 +32,7 @@ mods = {
'check_kernel': migration.check_kernel,
'get_kernel_data': server.get_kernel_data,
'check_repo': migration.check_repo,
+ 'get_repo_data': server.get_repo_data,
}
@@ -133,6 +134,17 @@ def check_repo():
return Response(mod, content_type='application/json')
+@app.route('/get_repo_data', methods=['GET', 'POST'])
+def get_repo_data():
+ """
+ 定时检查软件仓库检测结果
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
--
2.20.1

View File

@ -1,52 +0,0 @@
From 50941c1ad6ad3be2d8b1826a690df73227e15831 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 15:09:48 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E7=B3=BB=E7=BB=9F=E7=9A=84?=
=?UTF-8?q?=E7=A3=81=E7=9B=98=E5=8F=AF=E7=94=A8=E7=A9=BA=E9=97=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 9e7bd35..0bd73f6 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -484,3 +484,31 @@ def run_subprocess(cmd="", print_cmd=True, print_output=True):
return_code = process.poll()
return output, return_code
+
+
+def os_storage():
+ """
+ 判断系统剩余空间大小
+ :return: GB
+ """
+ path = '/var/cache'
+ stat = os.statvfs(path)
+ CACHE_SPACE = 10.0
+ state = 1
+ ava_cache = format(stat.f_bavail * stat.f_frsize / 1024 // 1024 / 1024, '.1f')
+ if stat:
+ # with open(PRE_MIG,'a+') as pf:
+ # pf.write('/var/cache可用空间为'+ava_cache+'GB')
+ # pf.close()
+ if float(ava_cache) >= CACHE_SPACE:
+ state = 0
+ return ava_cache
+ # data = '可用空间为'+ava_cache+'GB'
+ else:
+ return ava_cache
+ # data = '可用空间为' + ava_cache + 'GB,请清理/var/cache的空间后重试。'
+ else:
+ return ava_cache
+ # data = '可用空间为'+ava_cache+'GB,请清理/var/cache的空间后重试。'
+ # return list_to_json(keylist,valuelist)
+
--
2.20.1

View File

@ -1,60 +0,0 @@
From f9cd5557c5dbb1292cb6895d3da47d54af65b40d Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 15:15:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A3=80=E6=B5=8B=E7=B3=BB?=
=?UTF-8?q?=E7=BB=9F=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=B9=B6=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/short_task.py | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/sysmig_agent/short_task.py b/sysmig_agent/short_task.py
index 23d461b..11dd9ef 100644
--- a/sysmig_agent/short_task.py
+++ b/sysmig_agent/short_task.py
@@ -103,3 +103,38 @@ def check_kernel(data):
sql_task_statue(statue, task_id)
post_server('task_close', task_id)
return 's'
+
+
+
+def check_info(data):
+ task_id = json.loads(data).get('task_id')
+ # 更新SQL任务状态
+ statue = 1
+ sql_task_statue(statue, task_id)
+ # 发送消息给Server更新任务流状态
+ post_server('task_start', task_id)
+ # 获取agent系统类型
+ agent_os = get_agent_os()
+ # agent storage
+ agent_storage = os_storage()
+ agent_ip = get_local_ip()
+ sql = "UPDATE agent_info SET hostname = '{}', agent_os ='{}', agent_arch = '{}' ,agent_storage = {} ," \
+ "agent_online_status = {} WHERE agent_ip = '{}';".format(platform.node(), agent_os, platform.machine(),
+ agent_storage, 0, agent_ip)
+ try:
+ DBHelper().execute(sql)
+ statue = 2
+ except:
+ statue = 3
+ sql_task_statue(statue, task_id)
+ # 更新SQL任务状态
+ sql_task_statue(statue, task_id)
+ post_server('task_close', task_id)
+ return 'success'
+
+def get_agent_os():
+ os_version_ret = platform.dist()
+ version = os_version_ret[1].split('.', -1)
+ AGENT_OS = os_version_ret[0] + version[0]
+ return AGENT_OS
+
--
2.20.1

View File

@ -1,120 +0,0 @@
From bcfdd0fe37de13d71ae503e3f084bf86ff51b37b Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 17:35:30 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0abi=E6=A3=80=E6=B5=8B?=
=?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=9D=83=E9=87=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/abi_weight.py | 97 ++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
create mode 100644 sysmig_agent/abi_weight.py
diff --git a/sysmig_agent/abi_weight.py b/sysmig_agent/abi_weight.py
new file mode 100644
index 0000000..ce6b15f
--- /dev/null
+++ b/sysmig_agent/abi_weight.py
@@ -0,0 +1,97 @@
+# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+# SPDX-License-Identifier: MulanPubL-2.0-or-later
+
+import os
+
+# ABI_INCOMPAT_PATH = '/home/xzx/nfs/abi-incompat-pkg.txt'
+# ABI_COMPAT_PATH = '/home/xzx/nfs/abi-compat-pkg.txt'
+pwd = '/root/nfs'
+ABI_INCOMPAT_PATH = pwd+'/abi-incompat-pkg.txt'
+ABI_COMPAT_PATH = pwd + '/abi-compat-pkg.txt'
+AppStream =pwd + '/uos-sysmig/ut-Migration-tools/sysmig_agent/AppStream.txt'
+BaseOS = pwd + '/uos-sysmig/ut-Migration-tools/sysmig_agent/txts/BaseOS.txt'
+
+
+def get_list_pkg(path):
+ with open(path, 'r') as ap:
+ rpm = ap.readlines()
+ ap.close()
+ return rpm
+#
+
+# 调用
+def get_abi_incompat_pkg():
+ query = []
+ rpms = get_list_pkg(ABI_INCOMPAT_PATH)
+ for i in range(len(rpms)):
+ rpm = rpms[i].split('|', -1)
+ if len(query) > 0:
+ for q in range(len(query)):
+ if str(rpm[0]).strip() == str(query[q]):
+ break
+ if q == len(query) - 1:
+ query.append(rpm[0])
+ else:
+ query.append(rpm[0])
+ return query
+
+
+def return_error(debuginfo):
+ #####logging debug info
+ print(debuginfo)
+
+
+# 传入txt和rpm队列返回匹配个数
+def match_rpm(txt_path, rpm_query):
+ with open(txt_path, 'r') as ap:
+ appstream_rpms = ap.readlines()
+ ap.close()
+ total_rpm = 0
+ q = []
+ for i in range(len(rpm_query)):
+ for n in range(len(appstream_rpms)):
+ if str(rpm_query[i].strip().strip('\n')) == str(appstream_rpms[n].strip().strip('\n')):
+ total_rpm = total_rpm + 1
+ q.append(rpm_query[i])
+ break
+ if n == (len(appstream_rpms)):
+ print('No compat with AppStream and BaseOS list : ' + rpm_query[i])
+ return total_rpm
+
+
+def rpm_priority(rpm_compat_query, rpm_incompat_query):
+ app_weight = 50
+ base_weight = 50
+ if not os.path.exists(AppStream) and os.path.exists(BaseOS):
+ return return_error('debuginfo:can not open this file...')
+ total_incompat_app = match_rpm(AppStream, rpm_incompat_query)
+ total_incompat_base = match_rpm(BaseOS, rpm_incompat_query)
+ total_compat_app = match_rpm(AppStream, rpm_compat_query)
+ total_compat_base = match_rpm(BaseOS, rpm_compat_query)
+ app_weight_percent = (total_compat_app / (total_incompat_app + total_compat_app)) * app_weight
+ base_weight_percent = (total_compat_base / (total_incompat_base + total_compat_base)) * base_weight
+ AllWeight = app_weight_percent + base_weight_percent
+ AllWeight = format(AllWeight, '.0f')
+ return AllWeight
+
+
+def first_high_weight(rpm_incompat_query):
+ riq = ['gcc', 'glibc', 'binutils']
+ for i in range(len(riq)):
+ for n in range(len(rpm_incompat_query)):
+ if riq[i] == rpm_incompat_query[n]:
+ return False
+ return True
+
+
+def abi_check_priority():
+ rpm_incompat_query = get_abi_incompat_pkg()
+ rpm_compat_query = get_list_pkg(ABI_COMPAT_PATH)
+ del rpm_incompat_query[:2]
+ del rpm_compat_query[0]
+ if first_high_weight(rpm_incompat_query):
+ AllWeight = rpm_priority(rpm_compat_query, rpm_incompat_query)
+ else:
+ AllWeight = 0
+ print(AllWeight)
+
--
2.20.1

View File

@ -1,81 +0,0 @@
From d99a78a973b264280272bac87590870d598d7541 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 17:42:17 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=BD=AF=E4=BB=B6=E4=BB=93?=
=?UTF-8?q?=E5=BA=93=E6=A3=80=E6=B5=8B=E7=BB=93=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
views/server.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/views/server.py b/views/server.py
index 71cbb8e..b13d908 100644
--- a/views/server.py
+++ b/views/server.py
@@ -211,4 +211,57 @@ def get_kernel_data(data):
res['num'] = len(info_list)
json_res = json.dumps(res)
- return json_res
\ No newline at end of file
+ return json_res
+
+
+def get_repo_data(data):
+ """
+ 定时检查软件仓库检测结果
+ :return:
+ """
+ task_status_sql = "select agent_id from agent_task where task_status=2"
+ get_task_status = DBHelper().execute(task_status_sql).fetchall()
+ if len(get_task_status) == 0:
+ data = {"centos7_x86": "", "centos8_x86": "", "centos7_aarch64": "", "centos8_aarch64": ""}
+ json_data = json.dumps(data)
+ return json_data
+ else:
+ centos7_x86_sql = "select agent_ip from agent_info where (agent_os='centos7' or agent_os='redhat7') " \
+ "and agent_arch='x86_64' and repo_status=1;"
+
+ centos8_x86_sql = "select agent_ip from agent_info where (agent_os='centos8' or agent_os='redhat8') " \
+ "and agent_arch='x86_64' and repo_status=1;"
+
+ centos7_aarch64_sql = "select agent_ip from agent_info where (agent_os='centos7' or agent_os='redhat7') " \
+ "and agent_arch='aarch64' and repo_status=1;"
+
+ centos8_aarch64_sql = "select agent_ip from agent_info where (agent_os='centos8' or agent_os='redhat8') " \
+ "and agent_arch='aarch64' and repo_status=1;"
+
+ data = {}
+ get_centos7_x86_status = DBHelper().execute(centos7_x86_sql).fetchall()
+ if len(get_centos7_x86_status) == 0:
+ data['centos7_x86'] = 'success'
+ else:
+ data['centos7_x86'] = 'faild'
+
+ get_centos8_x86_status = DBHelper().execute(centos8_x86_sql).fetchall()
+ if len(get_centos8_x86_status) == 0:
+ data['centos8_x86'] = 'success'
+ else:
+ data['centos8_x86'] = 'faild'
+
+ get_centos7_aarch64_status = DBHelper().execute(centos7_aarch64_sql).fetchall()
+ if len(get_centos7_aarch64_status) == 0:
+ data['centos7_aarch64'] = 'success'
+ else:
+ data['centos7_aarch64'] = 'faild'
+
+ get_centos8_aarch64_status = DBHelper().execute(centos8_aarch64_sql).fetchall()
+ if len(get_centos8_aarch64_status) == 0:
+ data['centos8_aarch64'] = 'success'
+ else:
+ data['centos8_aarch64'] = 'faild'
+
+ json_data = json.dumps(data)
+ return json_data
\ No newline at end of file
--
2.20.1

View File

@ -1,643 +0,0 @@
From 0864ae482d003c316f7f03839e49d54133981698 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 17:42:55 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4ABI=E6=A3=80=E6=B5=8B?=
=?UTF-8?q?=E8=84=9A=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.sh | 458 --------------------------------
sysmig_agent/Abitranrept.sh | 153 -----------
2 files changed, 611 deletions(-)
delete mode 100755 sysmig_agent/Abisystmcompchk.sh
delete mode 100755 sysmig_agent/Abitranrept.sh
diff --git a/sysmig_agent/Abisystmcompchk.sh b/sysmig_agent/Abisystmcompchk.sh
deleted file mode 100755
index 15938fc..0000000
--- a/sysmig_agent/Abisystmcompchk.sh
+++ /dev/null
@@ -1,458 +0,0 @@
-#!/bin/bash
-########################变量定义#################################
-
-LOCAL_DIR=/var/tmp/uos-migration/data
-
-#原始数据目录
-UOS_DIR=$LOCAL_DIR/uos/rpms
-DIFF_DIR=$LOCAL_DIR/all-diff
-
-#输出结果目录
-EXP_DIR=$LOCAL_DIR/exp-rst
-
-#系统基本信息文件
-SYSTEM_INFO=systeminfo.txt
-
-#软件包对比文件
-PKG_COMP_LIST_01=pkginfo_1.txt
-PKG_COMP_LIST_02=pkginfo_2.txt
-PKG_COMP_LIST_04=pkginfo_4.txt
-
-#不兼容兼容定义
-START_CHANGE="================ changes of START==============="
-ENDS_CHANGE="================ end of changes of END==============="
-
-#兼容、不兼容检查结果输出列表
-ABI_COMPAT_PKG=abi-compat-pkg.txt
-ABI_INCOMPAT_PKG=abi-incompat-pkg.txt
-
-#生成总包文件
-UOS_PKG_RPMS_LIST=uos-pkg-rpms-list.txt
-OTH_PKG_RPMS_LIST=oth-pkg-rpms-list.txt
-
-ABI_DIFF_PKG_ERR=abi-diff-pkg-err.txt
-SUFFIX=.oked
-
-CACHE_SPACE="/var/tmp/uos-migration/UOS_analysis_report/rpmva-before.txt"
-
-#1. 创建目录
-create_file_path()
-{
- #接收yum仓库下载的rpm目录
- if [ ! -d "$UOS_DIR" ]
- then
- mkdir -p $UOS_DIR
- echo "mkdir -p $UOS_DIR success ... "
- fi
-
- #数据导出目录
- if [ ! -d "$EXP_DIR" ]
- then
- mkdir -p $EXP_DIR
- echo "mkdir -p $EXP_DIR success ... "
- fi
-
- #abidiff工具检测结果目录
- if [ ! -d "$DIFF_DIR" ]
- then
- mkdir -p $DIFF_DIR
- echo "mkdir -p $DIFF_DIR success ... "
- fi
-}
-
-#2. 获取rpm包列表,并解压rpm包
-get_rpm_list()
-{
- #清理历史数据
- if [ -f "$EXP_DIR/$UOS_PKG_RPMS_LIST" ]
- then
- rm -f $EXP_DIR/$UOS_PKG_RPMS_LIST
- fi
-
- if [ -f "$EXP_DIR/$OTH_PKG_RPMS_LIST" ]
- then
- rm -f $EXP_DIR/$OTH_PKG_RPMS_LIST
- fi
-
- #获取当前系统包列表
- for line in `rpm -qa | sort`
- do
- var=${line%-*}
- echo ${var%-*} >> $EXP_DIR/$OTH_PKG_RPMS_LIST
- done
-
- #源仓库批量下载当前系统包列表
- for downpkg in `cat $EXP_DIR/$OTH_PKG_RPMS_LIST`
- do
- string=$downpkg
- downpkg_list="${downpkg_list} ${string}"
- done
-
- yumdownloader --destdir=$UOS_DIR $downpkg_list --skip-broken
-
- #获取迁移系统包列表
- cd $UOS_DIR && for line1 in `ls *.rpm`;do var1=${line1%-*} echo ${var1%-*} >> $EXP_DIR/$UOS_PKG_RPMS_LIST ;done
-
- #当前系统与迁移系统共有的包列表
- grep -f $EXP_DIR/$UOS_PKG_RPMS_LIST $EXP_DIR/$OTH_PKG_RPMS_LIST > $EXP_DIR/$PKG_COMP_LIST_04
-
- #当前系统有,迁移系统无的包列表
- grep -wvf $EXP_DIR/$UOS_PKG_RPMS_LIST $EXP_DIR/$OTH_PKG_RPMS_LIST > $EXP_DIR/$PKG_COMP_LIST_02
-
- #根据包名找到对应的.rpm包,通过判断:(包名长度+1)个字符为数字判断是否为要解压的包
- for data in `cat $EXP_DIR/$PKG_COMP_LIST_04`
- do
- data_len=`expr length "$data"`
- len_char=`expr $data_len + 1`
-
- cmd_rst=`ls $data*`
- #针对同一包名多个查找结果处理
- for pkg_name in $cmd_rst
- do
- char=${pkg_name:$len_char:1}
- echo "$char" | [ -n "`sed -n '/^[0-9][0-9]*$/p'`" ] && rpm2cpio $pkg_name | cpio -idmv
- if [ $? == 0 ];then
-
- #条件不完整,可根据情况添加检测的目录
- rpm -qpl $pkg_name | grep -v ".build-id\|\/etc\/\|\/share\/" > $EXP_DIR/rpm-pkg-info.txt
- deal_file $EXP_DIR/rpm-pkg-info.txt $data
- mv $UOS_DIR/$pkg_name $UOS_DIR/$pkg_name$SUFFIX
- fi
- done
- done
-}
-
-
-#根据解压列表,过滤出兼容性检测的文件
-deal_file()
-{
- #清理数据
- rm -f $EXP_DIR/$2.diff
-
- for line in `cat $1`
- do
- rst=`file -i $line`
- if [[ ${rst#*charset=} == "binary" ]];then
-
- #获取要对比的文件名
- uos_bin=${line##*\/}
-
- #获取要对比的文件名路径
- uos_path_1=${line#*\/}
- uos_path=${uos_path_1%%\/*}
-
- #获取本系统文件名
- rst_find=`find /$uos_path -name $uos_bin`
- if [[ ${rst_find} != 0 ]];then
-
- #做对比到处结果
- abidiff .$line $rst_find > $EXP_DIR/abidiff_comp_rst.txt
- #abidiff工具检测结果不存在报错
- if [[ ! -f "$EXP_DIR/abidiff_comp_rst.txt" ]];then
- echo "abidiff $line $rst_find err!!!!"
- continue
- else
- if [[ -s $EXP_DIR/abidiff_comp_rst.txt ]];then
-
- #存在不为空,按照abipkgdiff工具结果格式生成报告
- echo ${START_CHANGE//START/\'$uos_bin\'} >> $DIFF_DIR/$2.diff
- cat $EXP_DIR/abidiff_comp_rst.txt >> $DIFF_DIR/$2.diff
- echo ${ENDS_CHANGE//END/\'$uos_bin\'} >> $DIFF_DIR/$2.diff
- echo " " >> $DIFF_DIR/$2.diff
- else
- #存在为空,直接导入结果列表
- cat $EXP_DIR/abidiff_comp_rst.txt >> $DIFF_DIR/$2.diff
- fi
- fi
- fi
- fi
- done
-}
-
-#3. abi检查结果包括兼容、非兼容的二进制包
-# 逐个处理 .diff 结果文件
-get_abi_comp_rest()
-{
- echo ""
- echo "------------------------- 获取abi兼容、非兼容包列表开始 -------------------------"
- TOTAL_NUM=0
- TOTAL_COMP_NUM=0
- FILE_SO=".so"
- FILE_EXEC=".exec"
- FILE_MOD=".mod"
- DATA_LINE_1="================ changes"
- DATA_LINE_2="Functions changes summary: "
- DATA_LINE_3="Variables changes summary: "
- DATA_LINE_4="Function symbols changes summary: "
- DATA_LINE_5="Variable symbols changes summary: "
- ABI_DIFF_PKG_ABNO=abi-diff-pkg-abno.txt
- ABI_INCOMPAT_PKG_ERR=abi-incompat-pkg-err.txt
-
- ABI_COMPAT_PKG_LINE="包名"
- ABI_INCOMPAT_PKG_LINE1="abi不兼容的包有INCOMP_PKG_NUM|"
- ABI_INCOMPAT_PKG_LINE2="包名|不兼容类型|不兼容来源|说明"
-
- cd $DIFF_DIR
-
- #初始化文件头信息
- echo $ABI_COMPAT_PKG_LINE >> $EXP_DIR/$ABI_COMPAT_PKG
- echo $ABI_INCOMPAT_PKG_LINE1 >> $EXP_DIR/$ABI_INCOMPAT_PKG
- echo $ABI_INCOMPAT_PKG_LINE2 >> $EXP_DIR/$ABI_INCOMPAT_PKG
-
- for abi_diff_file in `ls *.diff`
- do
- TOTAL_NUM=`expr $TOTAL_NUM + 1`
- NAME=${abi_diff_file%.*}
- FILE_SIZE=`ls -l $abi_diff_file | awk '{print $5}'`
- if [ $FILE_SIZE -eq 0 ];then
- #abi兼容性对比结果文件大小为 0 ,该软件包兼容
- echo $NAME >> $EXP_DIR/$ABI_COMPAT_PKG
- TOTAL_COMP_NUM=`expr $TOTAL_COMP_NUM + 1`
- else
- #将差错报告按以下条件重定向到文件,并分析
- grep "^================ changes" --after-context=4 $abi_diff_file > $abi_diff_file.tmp
- if [ $? -ne 0 ];then
- grep_rest_tmp="$abi_diff_file|================ changes|grep non-existent!"
- echo $grep_rest_tmp >> $EXP_DIR/$ABI_DIFF_PKG_ABNO
- else
- sed -i '/^--$/d' $abi_diff_file.tmp
- fi
- NUM1=0
- #兼容性开关,0-兼容1-不兼容
- COMP_FLAG=0
- while read line
- do
- if [[ $line == *$DATA_LINE_1* ]];then
- NUM2=$(( $NUM1 % 5 ))
- if [ $NUM2 = 0 ];then
- str1=${line%\'*}
- data_line="${str1#*\'}"
- if [[ $data_line =~ $FILE_SO ]]
- then
- COMP_TYPE="库差异"
- elif [[ $data_line =~ $FILE_EXEC ]]
- then
- COMP_TYPE="可执行文件"
- elif [[ $data_line =~ $FILE_MOD ]]
- then
- COMP_TYPE="视频文件"
- else
- COMP_TYPE="二进制差异"
- fi
- else
- #该情况不规范,需要查看
- echo "$NAME|$COMP_TYPE|$data_line|$line" >> $EXP_DIR/$ABI_DIFF_PKG_ERR
- fi
- elif [[ $line == *$DATA_LINE_2* ]];then
- str2="${line#*: }"
- removed_num=${str2% Removed*}
- change_line=${str2% Changed*}
- change_num=${tmp#*, }
- added_line=${str2% Added*}
- added_num=${tmp1##*,}
- if [[ $removed_num -eq 0 ]] && [[ $change_num -eq 0 ]] && [[ $added_num -eq 0 ]]
- then
- abi_var_comp_2="${abi_diff_file%.*}|$line|兼容"
- else
- abi_var_incomp_2="$NAME|$COMP_TYPE|$data_line|$line"
- echo $abi_var_incomp_2 >> $EXP_DIR/$ABI_INCOMPAT_PKG
- #此时abi编译以来库文件或者二进制包不兼容那么该rpm包不兼容
- COMP_FLAG=1
- fi
- elif [[ $line == *$DATA_LINE_3* ]];then
- str3="${line#*: }"
- removed_num=${str3% Removed*}
- change_line=${str3% Changed*}
- change_num=${tmp#*, }
- added_line=${str3% Added*}
- added_num=${tmp1##*,}
- if [[ $removed_num -eq 0 ]] && [[ $change_num -eq 0 ]] && [[ $added_num -eq 0 ]]
- then
- #abi检查结果中rpm包以来的库文件或者二进制文件兼容
- abi_var_comp_3="${abi_diff_file%.*}|$line|兼容"
- else
- abi_var_incomp_3="$NAME|$COMP_TYPE|$data_line|$line|"
- echo $abi_var_incomp_3 >> $EXP_DIR/$ABI_INCOMPAT_PKG
- #此时abi编译以来库文件或者二进制包不兼容那么该rpm包不兼容
- COMP_FLAG=1
- fi
- elif [[ $line == *$DATA_LINE_4* ]];then
- str4=${line#*: }
- removed_num=${str4% Removed*}
- if [ $removed_num -ne 0 ]
- then
- #abi检查结果中rpm包依赖的库文件或者二进制文件不兼容
- abi_var_incomp_4="$NAME|$COMP_TYPE|$data_line|$str4"
- echo $abi_var_incomp_4 >> $EXP_DIR/$ABI_INCOMPAT_PKG
- COMP_FLAG=1
- else
- #此时abi编译依赖库文件或者二进制包兼容
- abi_var_comp_4="${abi_diff_file%.*}|$line|兼容"
- fi
- elif [[ $line == *$DATA_LINE_5* ]];then
- str5=${line#*: }
- removed_num=${str5% Removed*}
- if [ $removed_num -ne 0 ]
- then
- #abi检查结果中rpm包依赖的库文件或者二进制文件不兼容
- abi_var_incomp_5="$NAME|$COMP_TYPE|$data_line|$str5"
- echo $abi_var_incomp_5 >> $EXP_DIR/$ABI_INCOMPAT_PKG
- COMP_FLAG=1
- else
- #此时abi编译依赖库文件或者二进制包兼容
- abi_var_comp_5="${abi_diff_file%.*}|$line|兼容"
- fi
- else
- ohter_err_info="$NAME|$COMP_TYPE|$data_line|$line|"
- echo $other_err_info >> $EXP_DIR/$ABI_INCOMPAT_PKG_ERR
- fi
- NUM1=`expr $NUM1 + 1`
- done < ./$abi_diff_file.tmp
- #根据兼容性开发COMP_FLAG判断该rpm包是否兼容
- if [ $COMP_FLAG -eq 0 ]
- then
- echo $NAME >> $EXP_DIR/$ABI_COMPAT_PKG
- else
- NUM10=`expr $NUM1 + 1`
- fi
-
- fi
- done
- rm -f *.diff.tmp
-
- ABI_INCOMP_NUM_TMP=`cat $EXP_DIR/$ABI_INCOMPAT_PKG | awk -F "|" '{print $1}' | sort | uniq | wc -l`
- ABI_INCOMP_NUM=`expr $ABI_INCOMP_NUM_TMP - 2`
- sed -i 's/INCOMP_PKG_NUM/'$ABI_INCOMP_NUM'/g' $EXP_DIR/$ABI_INCOMPAT_PKG
- echo "兼容包列表:$EXP_DIR/$ABI_COMPAT_PKG"
- echo "非兼容包列表:$EXP_DIR/$ABI_INCOMPAT_PKG"
- echo "------------------------- 获取abi兼容、非兼容包列表结束 -------------------------"
-}
-
-#4. 获取系统基本信息
-get_system_info()
-{
- #数据清理
- rm -f $EXP_DIR/$SYSTEM_INFO
-
- #SYSTEM_INFO_1_LINE1="|当前系统|迁移系统"
- SYSTEM_INFO_1_LINE1="|当前系统"
- #SYSTEM_INFO_2_LINE2="系统版本|CUR_VERSION|TRA_VERSION"
- SYSTEM_INFO_2_LINE2="系统版本|CUR_VERSION"
- #SYSTEM_INFO_3_LINE3="内核版本|CUR_KERNEL_VERSION|TRA_KERNEL_VERSION"
- SYSTEM_INFO_3_LINE3="内核版本|CUR_KERNEL_VERSION"
-
- SYSTEM_INFO_5_LINE5="/var/cache可用空间|CUR_USE_SPACE"
- SYSTEM_INFO_6_LINE6="架构|CUR_ARCH"
-
- #SYSTEM_INFO_8_LINE8="软件包|被替换的软件包|安装的软件包"
- SYSTEM_INFO_8_LINE8="软件包|被替换的软件包"
- #SYSTEM_INFO_9_LINE9="软件包数量|REPLACE_PKG_NUM|INSTALL_PKG_NUM"
- SYSTEM_INFO_9_LINE9="软件包数量|REPLACE_PKG_NUM"
-
- SYSTEM_INFO_11_LINE11="ABI"
- SYSTEM_INFO_12_LINE12="兼容数量|COMP_NUM"
- SYSTEM_INFO_13_LINE13="不兼容数量|INCOMP_NUM"
- SYSTEM_INFO_14_LINE14="总数|SUM_NUM"
-
- echo $SYSTEM_INFO_1_LINE1 >> $EXP_DIR/$SYSTEM_INFO
-
- #获取系统版本
- cur_sysinfo_1=`cat /etc/os-release | grep PRETTY_NAME`
- cur_sysinfo_2=${cur_sysinfo_1#*=}
- cur_sysinfo_len_1=`echo ${cur_sysinfo_1#*=} | wc -L`
- cur_sysinfo_len=`expr $cur_sysinfo_len_1 - 2`
-
- cur_sysinfo=${cur_sysinfo_2:1:$cur_sysinfo_len}
-
- system_info_2_line2=${SYSTEM_INFO_2_LINE2//CUR_VERSION/$cur_sysinfo}
- echo $system_info_2_line2 >> $EXP_DIR/$SYSTEM_INFO
-
- #获取内核版本
- cur_kernel_info=`uname -r`
-
- system_info_3_line3=${SYSTEM_INFO_3_LINE3//CUR_KERNEL_VERSION/$cur_kernel_info}
- echo $system_info_3_line3 >> $EXP_DIR/$SYSTEM_INFO
- echo " " >> $EXP_DIR/$SYSTEM_INFO
-
- #cache空间及架构
- cur_cache_space_tmp=`head -1 $CACHE_SPACE`
- cur_cache_space=${cur_cache_space_tmp#*为}
- cur_system_arch=`uname -m`
-
- system_info_5_line5=${SYSTEM_INFO_5_LINE5//CUR_USE_SPACE/$cur_cache_space}
- echo $system_info_5_line5 >> $EXP_DIR/$SYSTEM_INFO
-
- system_info_6_line6=${SYSTEM_INFO_6_LINE6//CUR_ARCH/$cur_system_arch}
- echo $system_info_6_line6 >> $EXP_DIR/$SYSTEM_INFO
- echo " " >> $EXP_DIR/$SYSTEM_INFO
-
- echo $SYSTEM_INFO_8_LINE8 >> $EXP_DIR/$SYSTEM_INFO
-
- abi_comp_pkg_num_tmp=`cat $EXP_DIR/$ABI_COMPAT_PKG | wc -l`
- cur_pkg_num=`expr $abi_comp_pkg_num_tmp - 1`
-
- system_info_9_line9=${SYSTEM_INFO_9_LINE9//REPLACE_PKG_NUM/$cur_pkg_num}
- echo $system_info_9_line9 >> $EXP_DIR/$SYSTEM_INFO
- echo " " >> $EXP_DIR/$SYSTEM_INFO
-
- echo $SYSTEM_INFO_11_LINE11 >> $EXP_DIR/$SYSTEM_INFO
- system_info_12_line12=${SYSTEM_INFO_12_LINE12//COMP_NUM/$cur_pkg_num}
- echo $system_info_12_line12 >> $EXP_DIR/$SYSTEM_INFO
-
- abi_incomp_pkg_num_tmp=`cat $EXP_DIR/$ABI_INCOMPAT_PKG | awk -F "|" '{print $1}'| sort | uniq |wc -l`
- abi_incomp_pkg_num=`expr $abi_incomp_pkg_num_tmp - 2`
- system_info_13_line13=${SYSTEM_INFO_13_LINE13//INCOMP_NUM/$abi_incomp_pkg_num}
- echo $system_info_13_line13 >> $EXP_DIR/$SYSTEM_INFO
-
- abi_pkg_num=`expr $abi_comp_pkg_num + $abi_incomp_pkg_num`
- system_info_14_line14=${SYSTEM_INFO_14_LINE14//SUM_NUM/$abi_pkg_num}
- echo $system_info_14_line14 >> $EXP_DIR/$SYSTEM_INFO
-
- #echo "====================End enter get_system_info=============="
-}
-
-#5. 软件包对比
-pkg_comp_rst()
-{
- #软件包对比文件头定义
- PKGINFO_1_LINE1="待替换/安装的软件包共SUM1个新安装的软件包共SUM2个"
- PKGINFO_2_LINE2="当前系统持有(不替换)|迁移系统软件包总表"
- PKGINFO_3_LINE3="OTH_VERSION|UOS_VERSION"
-
- #echo "==============Start enter pkg_comp_rst========="
- #清理数据
- rm -f $EXP_DIR/$PKG_COMP_LIST_01
-
- pkg_sum_num=`cat $EXP_DIR/$UOS_PKG_RPMS_LIST | wc -l`
- pkg_num_inst_tmp=`cat $EXP_DIR/$ABI_COMPAT_PKG | wc -l`
- pkg_num_inst=`expr $pkg_num_inst_tmp - 1`
-
-
- pkginfo_1_line1_tmp=${PKGINFO_1_LINE1//SUM1/$pkg_sum_num}
- pkginfo_1_line1=${pkginfo_1_line1_tmp//SUM2/$pkg_num_inst}
-
- echo $pkginfo_1_line1 >> $EXP_DIR/$PKG_COMP_LIST_01
-
- echo $PKGINFO_2_LINE2 >> $EXP_DIR/$PKG_COMP_LIST_01
-
- #获取系统版本
- cur_sysinfo_1=`cat /etc/os-release | grep PRETTY_NAME`
- cur_sysinfo_2=${cur_sysinfo_1#*=}
- cur_sysinfo_len_1=`echo ${cur_sysinfo_1#*=} | wc -L`
- cur_sysinfo_len=`expr $cur_sysinfo_len_1 - 2`
-
- cur_sysinfo=${cur_sysinfo_2:1:$cur_sysinfo_len}
-
- trans_sysinfo_1="UOS Server Enterprise "
-
- pkginfo_3_line3_tmp=${PKGINFO_3_LINE3//OTH_VERSION/$cur_sysinfo}
- pkginfo_3_line3=${pkginfo_3_line3_tmp//UOS_VERSION/$trans_sysinfo_1}
- echo $pkginfo_3_line3 >> $EXP_DIR/$PKG_COMP_LIST_01
-
-}
-
-create_file_path
-get_rpm_list
-get_abi_comp_rest
-get_system_info
-pkg_comp_rst
\ No newline at end of file
diff --git a/sysmig_agent/Abitranrept.sh b/sysmig_agent/Abitranrept.sh
deleted file mode 100755
index 891e6f2..0000000
--- a/sysmig_agent/Abitranrept.sh
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/bin/bash
-
-#系统迁移后调用该脚本获取迁移后系统信息,为迁移后生成报告准备
-
-LOCAL_DIR=/var/tmp/uos-migration/data
-#LOCAL_DIR=/var/data
-
-#输出结果目录
-EXP_DIR=$LOCAL_DIR/exp-rst
-
-#系统基本信息文件
-SYSTEM_INFO=systeminfo.txt
-TRAND_END_SYSINFO=trans-end-sysinfo.txt
-
-#软件包对比文件
-PKG_COMP_LIST_01=pkginfo_1.txt
-PKG_COMP_LIST_01_TRANS=pkginfo_1_trans.txt
-PKG_COMP_LIST_03=pkginfo_3.txt
-
-#1. 获取迁移后系统基本信息
-get_system_info()
-{
- #数据清理
- rm -f $EXP_DIR/$TRAND_END_SYSINFO
-
- line_num=1
- while read line
- do
- if [ $line_num -eq 1 ];then
- SYSTEM_INFO_1_LINE1="$line|迁移系统"
- echo $SYSTEM_INFO_1_LINE1 >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 2 ];then
- #获取系统版本
- cur_sysinfo_1=`cat /etc/os-release | grep PRETTY_NAME`
- cur_sysinfo_2=${cur_sysinfo_1#*=}
- cur_sysinfo_len_1=`echo ${cur_sysinfo_1#*=} | wc -L`
- cur_sysinfo_len=`expr $cur_sysinfo_len_1 - 2`
-
- cur_sysinfo=${cur_sysinfo_2:1:$cur_sysinfo_len}
-
- SYSTEM_INFO_2_LINE2="$line|$cur_sysinfo"
- echo $SYSTEM_INFO_2_LINE2 >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 3 ];then
- #当前系统版本
- cur_kernel_info=`uname -r`
- SYSTEM_INFO_3_LINE3="$line|$cur_kernel_info"
- echo $SYSTEM_INFO_3_LINE3 >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 4 ];then
- echo "" >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 5 ];then
- echo $line >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 6 ];then
- echo $line >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 7 ];then
- echo "" >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 8 ];then
- SYSTEM_INFO_8_LINE8="$line|安装的软件包"
- echo $SYSTEM_INFO_8_LINE8 >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 9 ];then
- install_num=`rpm -qa | grep uelc20 | wc -l`
- SYSTEM_INFO_9_LINE9="$line|$install_num"
- echo $SYSTEM_INFO_9_LINE9 >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 10 ];then
- echo "" >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 11 ];then
- echo $line >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 12 ];then
- echo $line >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 13 ];then
- echo $line >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- if [ $line_num -eq 14 ];then
- echo $line >> $EXP_DIR/$TRAND_END_SYSINFO
- fi
-
- line_num=`expr $line_num + 1`
-
- done < $EXP_DIR/$SYSTEM_INFO
-}
-
-#5. 软件包对比
-pkg_comp_rst()
-{
- VAR_LINE="迁移系统特有(新安装)"
-
- #清理数据
- rm -f $EXP_DIR/$PKG_COMP_LIST_01_TRANS
-
- line_num=1
-
- while read line
- do
-
- if [ $line_num -eq 1 ];then
- echo $line >> $EXP_DIR/$PKG_COMP_LIST_01_TRANS
- fi
-
- if [ $line_num -eq 2 ];then
- var_1=${line%|*}
- var_2=${line#*|}
- PKGINFO_2_LINE2="$var_1|$VAR_LINE|$var_2"
- echo $PKGINFO_2_LINE2 >> $EXP_DIR/$PKG_COMP_LIST_01_TRANS
- fi
-
- if [ $line_num -eq 3 ];then
- echo $line >> $EXP_DIR/$PKG_COMP_LIST_01_TRANS
- fi
-
- line_num=`expr $line_num + 1`
- done < $EXP_DIR/$PKG_COMP_LIST_01
-
- #获取已安装包列表
- for line1 in `rpm -qa | grep uelc20`
- #for line1 in `rpm -qa | grep el8`
- do
- var1=${line1%-*}
- echo ${var1%-*} >> $EXP_DIR/$PKG_COMP_LIST_03
- done
-
- #迁移完成后uelc20包列表不为空如果为空创建空文件以便统计汇总xls
- if [ ! -f $EXP_DIR/$PKG_COMP_LIST_03 ];then
- touch $EXP_DIR/$PKG_COMP_LIST_03
- fi
-}
-
-get_system_info
-pkg_comp_rst
-
--
2.20.1

View File

@ -1,54 +0,0 @@
From 25a688b1ada05e7bf2a713cbdac2df127dbf7104 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 09:44:30 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=89=8D=E7=8E=AF=E5=A2=83?=
=?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/index.py b/index.py
index d76404e..2faae57 100644
--- a/index.py
+++ b/index.py
@@ -12,7 +12,6 @@ from flask import Flask, render_template, url_for, request, redirect, make_respo
app = Flask(__name__)
mods = {
- 'check_environment': migration.check_environment,
'check_storage': migration.check_storage,
'check_os': migration.check_os,
'check_os_kernel': migration.check_os_kernel,
@@ -33,6 +32,7 @@ mods = {
'get_kernel_data': server.get_kernel_data,
'check_repo': migration.check_repo,
'get_repo_data': server.get_repo_data,
+ 'check_environment':migration.check_environment,
}
@@ -145,6 +145,17 @@ def get_repo_data():
return Response(mod, content_type='application/json')
+@app.route('/check_environment', methods=['GET', 'POST'])
+def check_environment():
+ """
+ agent迁移前环境检查任务
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
--
2.20.1

View File

@ -1,45 +0,0 @@
From f4604d225a9db3e9c18c3eb8de5cde28cd7c2c55 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 09:52:09 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8E=AF=E5=A2=83=E6=A3=80?=
=?UTF-8?q?=E6=9F=A5=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
views/migration.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/views/migration.py b/views/migration.py
index a628694..b7eaefa 100644
--- a/views/migration.py
+++ b/views/migration.py
@@ -88,9 +88,21 @@ def check_services(data, url):
def check_environment(data):
- services = check_services(data, '/check_environment')
- if services:
- return services
+ """
+ agent迁移前环境检查任务
+ :param data:
+ :return:
+ """
+ agent_ip_list = json.loads(data).get('agent_ip')
+ data = json.loads(data)
+ url = '/check_environment'
+ for i in agent_ip_list:
+ get_task_id_sql = "select task_id from cur_task where agent_ip='%s'" % i
+ task_id = DBHelper().execute(get_task_id_sql).fetchall()
+ data['task_id'] = task_id[0][0]
+ json_data = json.dumps(data)
+ send_task_to_agent(json_data, url, i)
+ return 'success'
def check_os(data):
--
2.20.1

View File

@ -1,140 +0,0 @@
From 9031ccf7e657286dfb18fe181fe97080ce5228dc Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 09:58:36 +0800
Subject: [PATCH] =?UTF-8?q?ABI=E6=A3=80=E6=B5=8B=E6=8A=A5=E5=91=8A?=
=?UTF-8?q?=E5=9F=BA=E7=A1=80=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 116 ++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
create mode 100644 sysmig_agent/Abisystmcompchk.py
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
new file mode 100644
index 0000000..abe6083
--- /dev/null
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -0,0 +1,116 @@
+# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+# SPDX-License-Identifier: MulanPubL-2.0-or-later
+
+
+import queue,os,string
+import threading,codecs
+import time,rpm,stat,re
+import datetime
+import platform
+import json,xlrd,xlwt
+import socket
+from xlutils.copy import copy
+from shutil import copyfile
+#from sysmig_agent.share import *
+from multiprocessing import Process
+from multiprocessing import cpu_count
+
+from logger import *
+#from connect_sql import DBHelper
+
+workQueue = queue.Queue()
+queueLock = threading.Lock()
+
+#为便于测试将变量、接口从share.py中拷贝到当前文件待联调通过后删除即可
+######################## add for test start ########################
+local_dir = '/var/tmp/uos-migration/data/'
+exp_rst_dir = local_dir+'exp-rst/'
+
+current_system_unique = exp_rst_dir + 'current-system-unique.csv'
+migration_system_install = exp_rst_dir + 'migration-system-install.csv'
+migration_system_total = exp_rst_dir + 'migration-system-total.csv'
+abi_comp_chk = exp_rst_dir + 'abi-comp-chk.csv'
+abi_incomp_chk = exp_rst_dir + 'abi-incomp-chk.csv'
+exitFlag = 0
+total_rpm_nums = 0
+percentage = ''
+deal_rpm_num = 0
+agent_abi_check_result = exp_rst_dir + 'agent_ABI_check_result.csv'
+suffix_list = ['.mo', '.gz', '.xml', '.conf', '.png', '.page', '.woff', '.ttf', '.pyc', '.typelib', '.pdf', '.ppt', '.txt', '.ico', '.icc', '.tcc', '.gif', '.oga', '.rom', '.jpg', '.dict', '.webm', '.pyc', '.wav', '.ucode', '.ttc', '.gresource', '.otf', '.t1', '.db', '.elc', '.cache', '.fd', '.iso', '.efi', '.mmdb', '.bz2', '.img', '.bin', '.fw', '.cis', '.itb', '.inp', '.sbcf', '.ddc', '.sfi', '.bseq', '.mfa2', '.chk', '.mgc', '.stub', '.dfu', '.dat', '.sys', '.bts', '.dlmem', '.brd', '.hwm', '.pwd', '.pwi', '.exe', '.der', '.p12', '.ogg', '.signed', '.dafsa', '.gpg', '.tri', '.x86_64']
+
+#Queue = queue.Queue()
+
+def os_storage():
+ """
+ 判断系统剩余空间大小
+ :return: GB
+ """
+ path = '/var/cache'
+ stat = os.statvfs(path)
+ CACHE_SPACE = 10.0
+ state = 1
+ ava_cache = format(stat.f_bavail * stat.f_frsize / 1024 // 1024 / 1024, '.1f')
+ if stat:
+ # with open(PRE_MIG,'a+') as pf:
+ # pf.write('/var/cache可用空间为'+ava_cache+'GB')
+ # pf.close()
+ if float(ava_cache) >= CACHE_SPACE:
+ state = 0
+ return ava_cache
+ # data = '可用空间为'+ava_cache+'GB'
+ else:
+ return ava_cache
+ # data = '可用空间为' + ava_cache + 'GB,请清理/var/cache的空间后重试。'
+ else:
+ return ava_cache
+ # data = '可用空间为'+ava_cache+'GB,请清理/var/cache的空间后重试。'
+ # return list_to_json(keylist,valuelist)
+
+def get_local_ip():
+ try:
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.connect(('8.8.8.8', 80))
+ ip = s.getsockname()[0]
+ return ip
+ finally:
+ s.close()
+
+def abi_check_sys_type():
+ path = '/etc/os-version'
+ if os.path.exists(path):
+ with open(path,'r') as v:
+ ret = v.readlines()
+ localos=ostype=''
+ for i in range(len(ret)):
+ if not ret[i]:
+ continue
+ if 'MinorVersion' in ret[i]:
+ strminor = str(ret[i])
+ _, localos = strminor.split('=',1)
+ if 'EditionName[zh_CN]' in ret[i]:
+ strminor = str(ret[i])
+ _, ostype = strminor.split('=',1)
+ ostype = re.sub('[^a-zA-Z]+','',ostype)
+ localos = localos.strip().strip('\n') + ostype.strip().strip('\n')
+ #localos = new_os.format(localos.strip().strip('\n'))
+ return localos
+
+def abi_check_sys():
+ c8 = ['1020a', '1021a', '1050a']
+ c7 = ['1000c', '1001c', '1002a']
+ system_type = abi_check_sys_type()
+ if not system_type:
+ os_version_ret = platform.dist()
+ osname = os_version_ret[1].strip()
+ osn = osname.split('.',-1)[0]
+ return osn.strip('\n')
+ for i in range(len(c8)):
+ if c8[i] in system_type:
+ return 8
+ for i in range(len(c7)):
+ if c7[i] in system_type:
+ return 7
+ return None
+
+######################## add for test end ########################
+######################## add for test end ########################
\ No newline at end of file
--
2.20.1

View File

@ -1,74 +0,0 @@
From 2d5291afc5a6edfe9f2359e808eb4dab35834d6f Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 10:00:20 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=8E=AF=E5=A2=83=E6=A3=80?=
=?UTF-8?q?=E6=9F=A5=E8=BF=9B=E5=BA=A6=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/index.py b/index.py
index 2faae57..4ca7b38 100644
--- a/index.py
+++ b/index.py
@@ -33,6 +33,7 @@ mods = {
'check_repo': migration.check_repo,
'get_repo_data': server.get_repo_data,
'check_environment':migration.check_environment,
+ 'get_environment_data': server.get_environment_data,
}
@@ -156,6 +157,17 @@ def check_environment():
return Response(mod, content_type='application/json')
+@app.route('/get_environment_data', methods=['GET', 'POST'])
+def get_environment_data():
+ """
+ 获取环境检查进度本
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
@@ -297,27 +309,6 @@ def MT_repo_kernel():
return render_template('MT_kernel.html')
-@app.route('/Mt_environment', methods=['GET', 'POST'])
-def Mt_environment():
- """
- 跳转迁移前环境检测界面
- :return:
- """
- return render_template('MT_check_environment.html')
-
-
-@app.route('/MT_check_environment', methods=['GET', 'POST'])
-def MT_check_environment():
- """
- 迁移前系统环境检查
- :return:
- """
- mod = check_methods()
- if mod:
- return Response(mod, content_type='application/json')
- return render_template('MT_check_environment.html')
-
-
@app.route('/MT_check_progress', methods=['GET', 'POST'])
def MT_check_progress():
"""
--
2.20.1

View File

@ -1,45 +0,0 @@
From 2be33254274159375af1783396ee30b4c696d7c1 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:06:58 +0800
Subject: [PATCH] =?UTF-8?q?ABI=E6=8A=A5=E5=91=8A=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E5=86=85=E6=A0=B8=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index abe6083..fdbe2e2 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -113,4 +113,22 @@ def abi_check_sys():
return None
######################## add for test end ########################
-######################## add for test end ########################
\ No newline at end of file
+######################## add for test end ########################
+
+#20220107 add by lihp
+#20220112 modify by lihp: add deal kernel migration fail
+def platform_release(Flag):
+ if Flag == '0':
+ cmd = "rpm -qa | grep kernel | grep -E 'an7|an8|el7|el8'"
+ else:
+ cmd = "rpm -qa | grep kernel | grep -E 'el7|el8|an7|an8|uelc'"
+ kernel_version=''
+ for line in os.popen(cmd):
+ pattern = re.compile(r'^[-+]?[-0-9]\d*\.\d*|[-+]?\.?[0-9]\d*$')
+ if pattern.match(line[7]):
+ kernel_version = line.split('-',1)[1]
+ if 'uelc' in line:
+ break
+ elif 'oe1' in line:
+ break
+ return kernel_version.rsplit('.', 1)[0]
--
2.20.1

View File

@ -1,54 +0,0 @@
From 7fe482e8fe8438cfb0c714c4861a578e6749b2f8 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:10:47 +0800
Subject: [PATCH] =?UTF-8?q?ABI=E6=A3=80=E6=B5=8B=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E5=9B=9B=E7=A7=8D=E6=A3=80=E6=B5=8B=E5=88=86=E7=B1=BB=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index fdbe2e2..cc48f45 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -132,3 +132,32 @@ def platform_release(Flag):
elif 'oe1' in line:
break
return kernel_version.rsplit('.', 1)[0]
+
+
+#Create agent ABI check result file
+def agent_ABI_check_result():
+ string = ',,,Y,,\n'
+
+ #mycopyfile(abi_incomp_chk, agent_abi_check_result, abi_log)
+ facp = open(agent_abi_check_result, 'w')
+ for line in open(abi_incomp_chk):
+
+ tmp01 = line.split(',', 5)
+ tmp = tmp01[4]
+
+ if tmp == '库差异':
+ str_01 = tmp01[0]+','+tmp01[1]+','+tmp01[2]+','+tmp01[3]+',1,'+tmp01[5]
+ elif tmp == '二进制差异':
+ str_01 = tmp01[0]+','+tmp01[1]+','+tmp01[2]+','+tmp01[3]+',2,'+tmp01[5]
+ elif tmp == '可执行文件差异':
+ str_01 = tmp01[0]+','+tmp01[1]+','+tmp01[2]+','+tmp01[3]+',3,'+tmp01[5]
+ elif tmp == '视频文件差异':
+ str_01 = tmp01[0]+','+tmp01[1]+','+tmp01[2]+','+tmp01[3]+',4,'+tmp01[5]
+
+ facp.write(str_01)
+ facp.close()
+
+ fp = open(agent_abi_check_result, 'a')
+ for rpm_name in open(abi_comp_chk):
+ fp.write(rpm_name.split(',')[0] + string)
+ fp.close()
\ No newline at end of file
--
2.20.1

View File

@ -1,46 +0,0 @@
From d8be08a9ea07b3500a3b6460e9325014ffcf379b Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:16:10 +0800
Subject: [PATCH] =?UTF-8?q?ABI=E6=A3=80=E6=B5=8B=E8=AE=B0=E5=BD=95?=
=?UTF-8?q?=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index cc48f45..e442cb5 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -160,4 +160,23 @@ def agent_ABI_check_result():
fp = open(agent_abi_check_result, 'a')
for rpm_name in open(abi_comp_chk):
fp.write(rpm_name.split(',')[0] + string)
- fp.close()
\ No newline at end of file
+ fp.close()
+
+
+def logger_init():
+ log_file = 'Abisystmcompchk.log' + '.' + datetime.datetime.now().strftime('%Y%m%d%H%M')
+ log_path = '/var/tmp/uos-migration/UOS_migration_log/'
+ if not os.path.exists(log_path):
+ os.makedirs(log_path)
+
+ logger = logging.getLogger()
+ logger.setLevel(logging.INFO)
+ log_name = log_path + log_file
+ logfile = log_name
+ fh = logging.FileHandler(logfile, mode='w')
+ fh.setLevel(logging.DEBUG)
+ formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s")
+ fh.setFormatter(formatter)
+ logger.addHandler(fh)
+
+ return logger
--
2.20.1

View File

@ -1,46 +0,0 @@
From 0827581dc9f64cfa96601fa36ae1fdc6d8e14dac Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:19:04 +0800
Subject: [PATCH] =?UTF-8?q?ABI=E5=A2=9E=E5=8A=A0ELF=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index e442cb5..541e9a8 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -180,3 +180,25 @@ def logger_init():
logger.addHandler(fh)
return logger
+
+
+# Check whether it is an ELF file
+def is_ELFfile(filepath, logger):
+ if not os.path.exists(filepath):
+ logger.info('file not exit:' + filepath)
+ return False
+ try:
+ FileStates = os.stat(filepath)
+ FileMode = FileStates[stat.ST_MODE]
+ if not stat.S_ISREG(FileMode) or stat.S_ISLNK(FileMode):
+ return False
+ with open(filepath, 'rb') as f:
+ header = (bytearray(f.read(4)[1:4])).decode(encoding="utf-8")
+ # logger.info("header is {}".format(header))
+ if header in ["ELF"]:
+ return True
+ except UnicodeDecodeError as e:
+ # logger.info("is_ELFfile UnicodeDecodeError {}".format(filepath))
+ # logger.info(str(e))
+ pass
+ return False
--
2.20.1

View File

@ -1,53 +0,0 @@
From b21342f766124ff7fbb737fa882329ae7873d970 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:30:03 +0800
Subject: [PATCH] =?UTF-8?q?ABI=E6=8A=A5=E5=91=8A=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E8=BD=AF=E4=BB=B6=E5=8C=85=E5=AF=B9=E6=AF=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 541e9a8..7a810f9 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -202,3 +202,32 @@ def is_ELFfile(filepath, logger):
# logger.info(str(e))
pass
return False
+
+
+#Get migration behind rpm list, filter dist of '.uelc20'
+def get_migrate_behind_rpm_pkg():
+ dist='.uelc20'
+ migration_before_uelc20_rpm = exp_rst_dir + 'migration-before-uelc20-rpm.csv'
+ migration_behind_uelc20_rpm = exp_rst_dir + 'migration-behind-uelc20-rpm.csv'
+
+ rpm_pkg_list=[]
+
+ ts = rpm.TransactionSet()
+ mi = ts.dbMatch()
+
+ fhu = open(migration_behind_uelc20_rpm, 'w')
+ if system_version_id() == '7':
+ for rpm_pkg in mi:
+ if dist in rpm_pkg['release'].decode():
+ fhu.write(rpm_pkg['name'].decode()+'\n')
+ rpm_pkg_list.append(rpm_pkg['name'].decode())
+ else:
+ for rpm_pkg in mi:
+ if dist in rpm_pkg['release']:
+ fhu.write(rpm_pkg['name']+'\n')
+ rpm_pkg_list.append(rpm_pkg['name'])
+ fcw.close()
+
+ return rpm_pkg_list
+
+
--
2.20.1

View File

@ -1,114 +0,0 @@
From c741aa97826c80c5a26387f3c2fe7c78942be679 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:32:52 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9C=A8rpm=E6=95=B0=E6=8D=AE=E5=BA=93?=
=?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=B3=BB=E7=BB=9F=E8=BD=AF=E4=BB=B6=E5=8C=85?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 89 +++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 7a810f9..3ebee71 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -231,3 +231,92 @@ def get_migrate_behind_rpm_pkg():
return rpm_pkg_list
+# Get the current system package
+def get_system_pkg_name(flag, mig_logger):
+ dist = '.uelc20'
+ rpm_pkg_list = ''
+ rpm_pkg_oth = []
+
+ if not os.path.exists(exp_rst_dir):
+ os.makedirs(exp_rst_dir)
+
+ migration_before_uelc20_rpm = exp_rst_dir + 'migration-before-uelc20-rpm.csv'
+ migration_before_eln_rpm = exp_rst_dir + 'migration-before-eln-rpm.csv'
+
+ ts = rpm.TransactionSet()
+ mi = ts.dbMatch()
+
+ # migration before filter dist of '.uelc20'
+ if flag == '0':
+ if os.path.exists(migration_before_uelc20_rpm):
+ os.remove(migration_before_uelc20_rpm)
+ if os.path.exists(migration_before_eln_rpm):
+ os.remove(migration_before_eln_rpm)
+
+ fbfu = open(migration_before_uelc20_rpm, 'w')
+ fbfe = open(migration_before_eln_rpm, 'w')
+ if system_version_id() == '7':
+ for rpm_pkg in mi:
+ if dist in rpm_pkg['release'].decode():
+ fbfu.write(rpm_pkg['name'].decode() + '\n')
+ else:
+ fbfe.write(rpm_pkg['name'].decode() + '\n')
+ rpm_pkg_list = rpm_pkg_list + ' ' + rpm_pkg['name'].decode()
+ else:
+ for rpm_pkg in mi:
+ if dist in rpm_pkg['release']:
+ fbfu.write(rpm_pkg['name'] + '\n')
+ else:
+ fbfe.write(rpm_pkg['name'] + '\n')
+ rpm_pkg_list = rpm_pkg_list + ' ' + rpm_pkg['name']
+ fbfu.close()
+ fbfe.close()
+ return rpm_pkg_list
+
+ # migration behind filter dist of '.uelc20'
+ elif flag == '1':
+ if os.path.exists(migration_before_uelc20_rpm):
+ with open(migration_before_uelc20_rpm, 'r') as fbfu:
+ fbfu_list = fbfu.readlines()
+
+ if os.path.exists(migration_system_install):
+ os.remove(migration_system_install)
+
+ fbhe = open(migration_system_install, 'w')
+ rst = str(abi_check_sys())
+ if rst == '7':
+ for rpm_pkg in mi:
+ if dist in rpm_pkg['release'].decode():
+ if rpm_pkg['name'].decode() not in fbfu_list:
+ fbhe.write(rpm_pkg['name'].decode() + '\n')
+ elif rst == '8':
+ for rpm_pkg in mi:
+ if dist in rpm_pkg['release']:
+ if rpm_pkg['name'] not in fbfu_list:
+ fbhe.write(rpm_pkg['name'] + '\n')
+ else:
+ mig_logger.info('migrate behind not exit verison id !!!')
+ fbhe.close()
+ else:
+ mig_logger.info('file not exit:' + migration_before_uelc20_rpm)
+ mig_logger.info('Please do migration before system compation check !!!')
+ return False
+ return True
+
+ elif flag == '2':
+ if system_version_id() == '7':
+ for rpm_name in mi:
+ if dist not in rpm_name['release'].decode():
+ rpm_pkg_oth.append(rpm_name['name'].decode())
+ dist_flag = '1'
+ else:
+ for rpm_name in mi:
+ if dist not in rpm_name['release']:
+ rpm_pkg_oth.append(rpm_name['name'])
+ dist_flag = '1'
+
+ if dist_flag == '1':
+ return rpm_pkg_oth
+ else:
+ mig_logger.info('The current system is UOS, not support migration, please check !!!')
+ return False
--
2.20.1

View File

@ -1,56 +0,0 @@
From 738918f6c6a3fe1e6ae6c8b7f125feb132936c21 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 10:36:32 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=8E=AF=E5=A2=83=E6=A3=80?=
=?UTF-8?q?=E6=B5=8B=E8=BF=9B=E5=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
views/server.py | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/views/server.py b/views/server.py
index b13d908..c959c2a 100644
--- a/views/server.py
+++ b/views/server.py
@@ -264,4 +264,32 @@ def get_repo_data(data):
data['centos8_aarch64'] = 'faild'
json_data = json.dumps(data)
- return json_data
\ No newline at end of file
+ return json_data
+
+
+def get_environment_data(data):
+ """
+ 获取环境检查进度
+ :return:
+ """
+ get_environment_pro_sql = "select agent_ip,task_progress,task_status from agent_task;"
+ progress = DBHelper().execute(get_environment_pro_sql).fetchall()
+ res = {}
+ info_list = []
+ finall_progress = []
+ for i in progress:
+ sql = "select agent_id from agent_info where agent_ip='%s' and agent_online_status=0 and repo_status=0 " \
+ "and agent_storage>=10 and agent_migration_os is null;" % i[0]
+ get_sql = DBHelper().execute(sql).fetchall()
+ if get_sql:
+ finall_progress.append(list(i))
+
+ info_dict_keys_list = ['agent_ip', 'task_progress', 'task_status']
+ for i in finall_progress:
+ info_list.append(dict(zip(info_dict_keys_list, list(i))))
+
+ res['info'] = info_list
+ res['num'] = len(finall_progress)
+
+ json_res = json.dumps(res)
+ return json_res
\ No newline at end of file
--
2.20.1

View File

@ -1,56 +0,0 @@
From f5106e3a71de94278d5ea337014038a3c607285e Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:39:36 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=96=87=E4=BB=B6=E6=98=AF?=
=?UTF-8?q?=E5=90=A6=E4=B8=BA=E4=BA=8C=E8=BF=9B=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 3ebee71..14cad1d 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -320,3 +320,35 @@ def get_system_pkg_name(flag, mig_logger):
else:
mig_logger.info('The current system is UOS, not support migration, please check !!!')
return False
+
+
+class myThread (threading.Thread):
+ def __init__(self, threadID, name, q, lock, fpw, fpr, q_query, log):
+ threading.Thread.__init__(self)
+ self.threadID = threadID
+ self.name = name
+ self.q = q
+ self.lock = lock
+ self.fpw = fpw
+ self.fpr = fpr
+ self.q_query = q_query
+ self.log = log
+ def run(self):
+ self.log.info ("Open the thread" + self.name)
+ process_data(self.name, self.q, self.lock, self.fpw, self.fpr, self.q_query, self.log)
+ self.log.info ("Exit the thread" + self.name)
+
+
+def is_binwary_file(filename):
+ TEXT_BOMS = {
+ codecs.BOM_UTF16_BE,
+ codecs.BOM_UTF16_LE,
+ codecs.BOM_UTF32_BE,
+ codecs.BOM_UTF32_LE,
+ codecs.BOM_UTF8,
+ }
+ with open(filename, 'rb') as file:
+ CHUNKSIZE = 8192
+ initial_bytes = file.read(CHUNKSIZE)
+ file.close
+ return not any(initial_bytes.startswith(bom) for bom in TEXT_BOMS) and b'\0' in initial_bytes
--
2.20.1

View File

@ -1,146 +0,0 @@
From 5b38d0362e73afd8a3cd16fdd1e32dfd7cde00ba Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:45:29 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ELF=E5=AF=B9=E6=AF=94?=
=?UTF-8?q?=E5=87=BD=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 107 +++++++++++++++++++++++++++++++-
1 file changed, 106 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 14cad1d..d3c09e6 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -322,6 +322,7 @@ def get_system_pkg_name(flag, mig_logger):
return False
+
class myThread (threading.Thread):
def __init__(self, threadID, name, q, lock, fpw, fpr, q_query, log):
threading.Thread.__init__(self)
@@ -338,7 +339,6 @@ class myThread (threading.Thread):
process_data(self.name, self.q, self.lock, self.fpw, self.fpr, self.q_query, self.log)
self.log.info ("Exit the thread" + self.name)
-
def is_binwary_file(filename):
TEXT_BOMS = {
codecs.BOM_UTF16_BE,
@@ -352,3 +352,108 @@ def is_binwary_file(filename):
initial_bytes = file.read(CHUNKSIZE)
file.close
return not any(initial_bytes.startswith(bom) for bom in TEXT_BOMS) and b'\0' in initial_bytes
+
+def incomp_binwary_desc(binwary_file):
+ if binwary_file.endswith('.so'):
+ incomp_info_desc = '库差异'
+ elif binwary_file.endswith('.exec'):
+ incomp_info_desc = '可执行文件'
+ elif binwary_file.endswith('.mod'):
+ incomp_info_desc = '视频文件'
+ else:
+ incomp_info_desc = '二进制差异'
+ return incomp_info_desc
+
+def deal_files_list(fwincomp, fwcomp, cur_file_list, trn_file_list, rpm_full_pkg_name, list_log):
+ #compatiable
+ comp_flag=1
+ link_flag = '0'
+ cur_file_deal = ''
+
+ rpm_pkg_dir = local_dir + 'uos/rpms'
+ rpm_pkg_name = rpm_full_pkg_name.rsplit('-',2)[0]
+ pkg_version = rpm_full_pkg_name.rsplit('-',2)[1]
+
+ for cur_file_name in cur_file_list:
+
+ cur_file_binwary = cur_file_name.strip('\n')
+
+ if not os.path.exists(cur_file_binwary):
+ continue
+
+ if os.path.isdir(cur_file_binwary):
+ continue
+
+ if '.' in cur_file_binwary.rsplit('/',1)[1]:
+ if '.'+cur_file_binwary.rsplit('.',1)[1] in suffix_list:
+ continue
+
+ if not is_ELFfile(cur_file_binwary, list_log):
+ continue
+
+ if is_binwary_file(cur_file_binwary):
+ trn_file_deal = rpm_pkg_dir + cur_file_binwary
+ if not os.path.exists(trn_file_deal):
+ continue
+
+ #link file realpath
+ if os.path.islink(cur_file_binwary):
+ cur_file_deal = os.path.realpath(cur_file_binwary)
+ if cur_file_name in trn_file_list:
+ trn_file_deal_tmp = rpm_pkg_dir + cur_file_binwary
+ trn_file_deal = os.path.realpath(trn_file_deal_tmp)
+ link_flag = '1'
+ else:
+ continue
+ else:
+ if link_flag:
+ link_flag = '0'
+ continue
+ if cur_file_name in trn_file_list:
+ trn_file_deal = rpm_pkg_dir + cur_file_binwary
+ cur_file_deal = cur_file_binwary
+ else:
+ continue
+
+ abidiff_rst_list = list(os.popen('abidiff %s %s' %(trn_file_deal, cur_file_binwary)))
+ if len(abidiff_rst_list):
+ i = 0
+ if cur_file_binwary.endswith('.exec'):
+ while i < 2:
+ for line in abidiff_rst_list[i].split(':',1)[1].split(','):
+ if line.split(' ', 2)[1] != '0':
+ bin_name = cur_file_name.strip('\n').rsplit('/', 1)[1]
+ compatiablity='N'
+ incomp_reason = incomp_binwary_desc(bin_name)
+ diff_detail = abidiff_rst_list[i].split(':', 1)[1]
+ fwincomp.write(rpm_pkg_name+','+bin_name+','+pkg_version+','+compatiablity+','+incomp_reason+','+diff_detail)
+ comp_flag = 0
+ i = i + 1
+ #20220112 lihp: add if branch
+ elif abidiff_rst_list[0].startswith('ELF SONAME'):
+ i = i + 1
+ while i < 2:
+ for line in abidiff_rst_list[i].split(':',1)[1].split(','):
+ if line.split(' ', 2)[1] != '0':
+ bin_name = cur_file_name.strip('\n').rsplit('/', 1)[1]
+ compatiablity='N'
+ incomp_reason = incomp_binwary_desc(bin_name)
+ diff_detail = abidiff_rst_list[i].split(':', 1)[1]
+ fwincomp.write(rpm_pkg_name+','+bin_name+','+pkg_version+','+compatiablity+','+incomp_reason+','+diff_detail)
+ comp_flag = 0
+ i = i + 1
+ else:
+ while i < 4:
+ for line in abidiff_rst_list[i].split(':',1)[1].split(','):
+ if line.split(' ', 2)[1] != '0':
+ bin_name = cur_file_name.strip('\n').rsplit('/', 1)[1]
+ compatiablity='N'
+ incomp_reason = incomp_binwary_desc(bin_name)
+ diff_detail = abidiff_rst_list[i].split(':', 1)[1]
+ fwincomp.write(rpm_pkg_name+','+bin_name+','+pkg_version+','+compatiablity+','+incomp_reason+','+diff_detail)
+ comp_flag = 0
+ i = i + 1
+ else:
+ continue
+ if comp_flag:
+ fwcomp.write(rpm_pkg_name + ',' + ',' + ',' + 'Y,' + ',' + '\n')
\ No newline at end of file
--
2.20.1

View File

@ -1,64 +0,0 @@
From 2277378be0320a9ae296e6a02137497d53151bd3 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:51:30 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=EF=BC=8C=E6=8F=90=E4=BE=9B=E6=96=87=E4=BB=B6=E5=AF=B9?=
=?UTF-8?q?=E6=AF=94=E8=B7=AF=E5=BE=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 37 ++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index d3c09e6..438fc2d 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -456,4 +456,39 @@ def deal_files_list(fwincomp, fwcomp, cur_file_list, trn_file_list, rpm_full_pkg
else:
continue
if comp_flag:
- fwcomp.write(rpm_pkg_name + ',' + ',' + ',' + 'Y,' + ',' + '\n')
\ No newline at end of file
+ fwcomp.write(rpm_pkg_name + ',' + ',' + ',' + 'Y,' + ',' + '\n')
+
+
+def process_data(threadName, q, queueLock, incompfw, compfw, Queue, pro_log):
+ global exitFlag
+ global total_rpm_nums
+ global percentage
+ global deal_rpm_num
+ status = '1'
+
+ rpm_pkg_path = local_dir + 'uos/rpms/'
+
+ abisys =str(abi_check_sys())
+ while not exitFlag:
+ queueLock.acquire()
+ if not workQueue.empty():
+ rpm_full_name=q.get()
+ rpm_pkg_name=rpm_full_name.rsplit('-',2)[0]
+ rpm_path_name=rpm_pkg_path + rpm_full_name
+ if '7' == abisys:
+ print('----------7-0---------')
+ list_file_cur=list(os.popen('rpm -ql %s ' %(rpm_pkg_name)))
+ list_file_trn=list(os.popen('rpm -qpl %s ' %(rpm_path_name)))
+ else:
+ list_file_cur=list(os.popen('rpm -ql --noartifact %s ' %(rpm_pkg_name)))
+ list_file_trn=list(os.popen('rpm -qpl --noartifact %s ' %(rpm_path_name)))
+ os.system('rpm2cpio %s | cpio -idmv' %(rpm_full_name))
+ deal_files_list(incompfw, compfw, list_file_cur, list_file_trn, rpm_full_name, pro_log)
+ deal_rpm_num = deal_rpm_num + 1
+ percentage = ("%d" % (deal_rpm_num/total_rpm_nums*100))
+ msg_tup = (percentage, status)
+ Queue.put(msg_tup)
+ pro_log.info('message tup queue:' + str(msg_tup))
+ queueLock.release()
+ else:
+ queueLock.release()
\ No newline at end of file
--
2.20.1

View File

@ -1,52 +0,0 @@
From e87ba07ce71ff048e6a7acb51230b09db4f5fd3b Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 10:55:30 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=BD=AF=E4=BB=B6=E6=BA=90?=
=?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=88=B0=E6=9C=AC=E5=9C=B0=E7=9A=84=E8=BD=AF?=
=?UTF-8?q?=E4=BB=B6=E5=8C=85=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 438fc2d..bac4205 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -491,4 +491,28 @@ def process_data(threadName, q, queueLock, incompfw, compfw, Queue, pro_log):
pro_log.info('message tup queue:' + str(msg_tup))
queueLock.release()
else:
- queueLock.release()
\ No newline at end of file
+ queueLock.release()
+
+
+def get_system_pkg_list(migbeflist):
+ download_rpm_nums = 0
+ migration_rpm_pkg_path = local_dir + 'uos/rpms'
+
+ #clean history data
+ if os.path.exists(migration_system_total):
+ os.remove(migration_system_total)
+
+ ftw = open(migration_system_total, 'w')
+ items = os.listdir(migration_rpm_pkg_path)
+ newlist = []
+ for names in items:
+ if names.endswith(".rpm"):
+ ftw.write(names.rsplit('-',1)[0].rsplit('-',1)[0] + '\n')
+ migbeflist.append(names.rsplit('-',1)[0].rsplit('-',1)[0])
+ newlist.append(names)
+ download_rpm_nums = download_rpm_nums + 1
+ ftw.close()
+ if download_rpm_nums:
+ return newlist
+ else:
+ return False
--
2.20.1

View File

@ -1,38 +0,0 @@
From bdf226b949fd997e71d9375ecc5f71553d3bf005 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 10:55:37 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96repo=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/index.py b/index.py
index 4ca7b38..8629ae3 100644
--- a/index.py
+++ b/index.py
@@ -168,6 +168,17 @@ def get_environment_data():
return Response(mod, content_type='application/json')
+@app.route('/get_repo_arch_info', methods=['GET', 'POST'])
+def get_repo_arch_info():
+ """
+ 获取软件仓库架构和系统信息
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
--
2.20.1

View File

@ -1,70 +0,0 @@
From 10648fa7ce12f1e01c97d91429c11f0b6fae907b Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 11:00:36 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=BD=AF=E4=BB=B6=E4=BB=93?=
=?UTF-8?q?=E5=BA=93=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 1 +
views/server.py | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/index.py b/index.py
index 8629ae3..d9a564b 100644
--- a/index.py
+++ b/index.py
@@ -34,6 +34,7 @@ mods = {
'get_repo_data': server.get_repo_data,
'check_environment':migration.check_environment,
'get_environment_data': server.get_environment_data,
+ 'get_repo_arch_info': server.get_repo_arch_info,
}
diff --git a/views/server.py b/views/server.py
index c959c2a..0a8eeed 100644
--- a/views/server.py
+++ b/views/server.py
@@ -291,5 +291,35 @@ def get_environment_data(data):
res['info'] = info_list
res['num'] = len(finall_progress)
+ json_res = json.dumps(res)
+ return json_res
+
+
+def get_repo_arch_info(data):
+ """
+ 获取软件仓库架构和系统信息
+ :param data:
+ :return:
+ """
+ sql = "select agent_os,agent_arch from agent_info where agent_online_status='0' and agent_storage>='10' " \
+ "and agent_migration_os is null;"
+ get_info = DBHelper().execute(sql).fetchall()
+ get_info_list = []
+ for i in get_info:
+ get_info_list.append(list(i))
+
+ for i in get_info_list :
+ if i[0] == 'redhat7':
+ i[0] = 'centos7'
+ if i[0] == 'redhat8':
+ i[0] = 'centos8'
+
+ info_list = []
+ info_dict_keys_list = ['agent_os', 'agent_arch']
+ for i in get_info_list:
+ info_list.append(dict(zip(info_dict_keys_list, i)))
+
+ res = {}
+ res['info'] = info_list
json_res = json.dumps(res)
return json_res
\ No newline at end of file
--
2.20.1

View File

@ -1,36 +0,0 @@
From 749ace03d1a3a0a47f68a558a1a6fb4f63b4bd81 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 13:42:21 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1abi=E5=85=BC=E5=AE=B9?=
=?UTF-8?q?=E7=9A=84=E5=88=97=E8=A1=A8=E6=80=BB=E6=95=B0=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index bac4205..f402a74 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -516,3 +516,15 @@ def get_system_pkg_list(migbeflist):
return newlist
else:
return False
+
+
+def incomp_pkg_num():
+ tmp=''
+ num=0
+ for line in open(abi_incomp_chk, 'r').readlines():
+ tmp_01 = line.split(',')[0]
+ if tmp!=tmp_01:
+ num = num + 1
+ tmp = line.split(',')[0]
+ return num
+
--
2.20.1

View File

@ -1,42 +0,0 @@
From e5178a05c2a6a2032e1db5a5d2329b8b63862dcc Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 13:57:59 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=B3=BB=E7=BB=9F=E7=89=88?=
=?UTF-8?q?=E6=9C=AC=E5=92=8C=E7=B3=BB=E7=BB=9FID?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index f402a74..913fef1 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -528,3 +528,21 @@ def incomp_pkg_num():
tmp = line.split(',')[0]
return num
+
+def system_version_id():
+ fp = open('/etc/os-release', 'r')
+ for line in fp:
+ if 'VERSION_ID' in line:
+ break
+ fp.close()
+ return line.split('=', 1)[1].replace('"', '').replace('\n', '')
+
+
+def get_cur_sys_version():
+ fp = open('/etc/os-release', 'r')
+ for line in fp:
+ if 'PRETTY_NAME' in line:
+ break
+ fp.close()
+ return line.split('=', 1)[1].replace('"', '').replace('\n', '')
+
--
2.20.1

View File

@ -1,45 +0,0 @@
From be2eee80486e06dc4cfe097fa10d2254df5800c4 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:00:33 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=A3=80=E6=B5=8B=E7=9A=84?=
=?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 913fef1..43a4594 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -546,3 +546,24 @@ def get_cur_sys_version():
fp.close()
return line.split('=', 1)[1].replace('"', '').replace('\n', '')
+
+def get_migration_sys_info():
+
+ behind_sys_info = exp_rst_dir + 'before-system-info.txt'
+ with open(behind_sys_info, 'r') as file_object:
+ behind_list_info = file_object.readlines()
+
+ migration_sys_info = '1|2|' + get_cur_sys_version()
+ behind_list_info.append(migration_sys_info)
+
+ #20220107 modify lihp: get kernel version
+ #migration_kernel_verison = '2|2|' + platform.release()
+ migration_kernel_verison = '2|2|' + platform_release('1')
+ behind_list_info.append(migration_kernel_verison)
+
+ with open(migration_system_install, 'r') as frm:
+ install_pkgs_num = str(len(frm.readlines()))
+ behind_list_info.append('8|2|' + install_pkgs_num)
+
+ return behind_list_info
+
--
2.20.1

View File

@ -1,87 +0,0 @@
From ce89ad8b486b2151243c4ba03f6a5778f353ac1f Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:02:56 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=90=88=E5=9F=BA=E7=A1=80=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E5=92=8CABI=E5=85=BC=E5=AE=B9=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E5=88=B0=E6=8A=A5=E5=91=8A=E5=B9=B6=E8=B0=83=E6=95=B4=E6=A0=BC?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 61 +++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 43a4594..d14581b 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -567,3 +567,64 @@ def get_migration_sys_info():
return behind_list_info
+
+#Create data list for write to .xls of sheet[0]
+#ge['1|1|CentOS Linux 8 (Core)', '2|1|4.18.0-147.el8.x86_64', '4|1|26.4GB', '5|1|x86_64', '8|1|1278', '11|1|1', '12|1|2', '13|1|2']
+def get_cur_sys_info_list():
+ list_info = []
+ before_sys_info = exp_rst_dir + 'before-system-info.txt'
+ sys_version_tmp = exp_rst_dir + 'sys-version-tmp'
+
+ #Used after system migration
+ with open(sys_version_tmp, 'w') as file_object:
+ file_object.write(get_cur_sys_version())
+
+ #current system version, write sheet[0]:1-row,1-column
+ cur_sys_info = '1|1|' + get_cur_sys_version()
+ list_info.append(cur_sys_info)
+
+ #current kernel version, write sheet[0]:2-row,1-column
+ #20220107 modify lihp: get kernel version of migrate before
+ #cur_kernel_verison = '2|1|' + platform.release()
+ cur_kernel_verison = '2|1|' + platform_release('0')
+ list_info.append(cur_kernel_verison)
+
+ #/var/cache available space,write sheet[0]:4-row,1-column
+ cur_var_cache = '4|1|' + os_storage() + 'GB'
+ list_info.append(cur_var_cache)
+
+ #system architecture, write sheet[0]:5-row,1-line
+ cur_arch = '5|1|' + platform.processor()
+ list_info.append(cur_arch)
+
+ #Be replaced rpm packages number,write sheet[0]:8-row,1-column
+ with open(migration_system_total, 'r') as fr:
+ replace_pkgs_num = str(len(fr.readlines()))
+ list_info.append('8|1|' + replace_pkgs_num)
+
+ #Compatible with the number, write sheet[0]:11-row,1-column
+ with open(abi_comp_chk, 'r') as fc:
+ comp_num_int = len(fc.readlines())
+ comp_num = '11|1|' + str(comp_num_int)
+ list_info.append(comp_num)
+
+ #Icompatible with the number,write sheet[0]:12-row,1-column
+ incomp_num = '12|1|' + str(incomp_pkg_num())
+ list_info.append(incomp_num)
+
+ #The total number of packageswrite sheet[0]:13-row,1-column
+ sum_num = comp_num_int + incomp_pkg_num()
+ list_info.append('13|1|' + str(sum_num))
+
+ #write to file,report generation after migration
+ with open(before_sys_info, 'w') as fpbsi:
+ fpbsi.write(cur_sys_info + '\n')
+ fpbsi.write(cur_kernel_verison + '\n')
+ fpbsi.write(cur_var_cache + '\n')
+ fpbsi.write(cur_arch + '\n')
+ fpbsi.write('8|1|' + replace_pkgs_num + '\n')
+ fpbsi.write(comp_num + '\n')
+ fpbsi.write(incomp_num + '\n')
+ fpbsi.write('13|1|' + str(sum_num) + '\n')
+
+ return list_info
--
2.20.1

View File

@ -1,38 +0,0 @@
From 6b30dd600fa78f0ee91762b8ca450a96e1ede0b0 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 14:06:04 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8=E7=A9=BA=E9=97=B4=E6=A3=80?=
=?UTF-8?q?=E6=B5=8B=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/index.py b/index.py
index d9a564b..6b3b3d7 100644
--- a/index.py
+++ b/index.py
@@ -180,6 +180,17 @@ def get_repo_arch_info():
return Response(mod, content_type='application/json')
+@app.route('/get_storage_num', methods=['GET', 'POST'])
+def get_storage_num():
+ """
+ 获取可用空间足够和不足数量
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
--
2.20.1

View File

@ -1,39 +0,0 @@
From e4bfbc6e0d5ecf6768a24e8ae173c0bd39b667b1 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:11:10 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E8=A7=A3=E5=8E=8B=E7=9A=84rp?=
=?UTF-8?q?m=E6=96=87=E4=BB=B6=E5=88=B0=E5=92=8C=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=B0=E5=AF=B9=E6=AF=94=E7=9B=AE=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index d14581b..cf34c87 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -628,3 +628,17 @@ def get_cur_sys_info_list():
fpbsi.write('13|1|' + str(sum_num) + '\n')
return list_info
+
+
+def mycopyfile(srcfile, dstfile, logger):
+ if not os.path.exists(srcfile):
+ logger.info("Please check!!!! src file not exit:" + srcfile)
+ return False
+ else:
+ fpath,fname=os.path.split(dstfile)
+ if not os.path.exists(fpath):
+ os.makedirs(fpath)
+ copyfile(srcfile,dstfile)
+
+ return dstfile
+
--
2.20.1

View File

@ -1,59 +0,0 @@
From 02efd99c88ae7ff70f757ed975a75aa4210f380f Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:23:24 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=A3=80=E6=B5=8B=E6=A8=A1=E6=9D=BF?=
=?UTF-8?q?=E5=A1=AB=E5=85=85=E5=BD=93=E5=89=8D=E5=B7=B2=E6=9C=89=E7=9A=84?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 34 +++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index cf34c87..bf32e49 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -642,3 +642,37 @@ def mycopyfile(srcfile, dstfile, logger):
return dstfile
+
+#Generate report name
+def create_migrate_report_name(flag, logg):
+
+ migrate_before_report_path = '/var/tmp/uos-migration/UOS_analysis_report/'
+ migrate_behind_report_path = '/var/tmp/uos-migration/UOS_migration_completed_report/'
+
+ migrate_report_before_sample_name = 'UOS_migration_report_HOSTIP_HOSTNAME_YYYYMMDDHHMM-BEFORE.xls'
+ migrate_report_behind_sample_name = 'UOS_migration_report_HOSTIP_HOSTNAME_YYYYMMDDHHMM-BEHIND.xls'
+
+ hostip = get_local_ip()
+ hostname = socket.gethostname()
+ hosttime = datetime.datetime.now().strftime('%Y%m%d%H%M')
+ abs_path = os.path.abspath('sysmig_agent/txts/')
+
+ if not os.path.exists(migrate_behind_report_path):
+ os.makedirs(migrate_behind_report_path)
+
+ #migration before
+ if flag=='0':
+ migrate_name_01 = migrate_report_before_sample_name.replace('HOSTIP', hostip)
+ migrate_name_02 = migrate_name_01.replace('HOSTNAME', hostname)
+ migrate_name = migrate_before_report_path + migrate_name_02.replace('YYYYMMDDHHMM-BEFORE', hosttime)
+ migrate_path_name_sample = abs_path + '/' + migrate_report_before_sample_name
+
+ #migration behind
+ elif flag=='1':
+ migrate_name_01 = migrate_report_behind_sample_name.replace('HOSTIP', hostip)
+ migrate_name_02 = migrate_name_01.replace('HOSTNAME', hostname)
+ migrate_name = migrate_behind_report_path + migrate_name_02.replace('YYYYMMDDHHMM-BEHIND', hosttime)
+ migrate_path_name_sample = abs_path + '/' + migrate_report_behind_sample_name
+
+ #Rename the real report name
+ return mycopyfile(migrate_path_name_sample, migrate_name, logg)
--
2.20.1

View File

@ -1,62 +0,0 @@
From 353746455579de2e782f180b70d66a666c3572e0 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 14:31:05 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96agent=E5=AD=98=E5=82=A8?=
=?UTF-8?q?=E7=A9=BA=E9=97=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 1 +
views/server.py | 23 ++++++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/index.py b/index.py
index 6b3b3d7..2f5c946 100644
--- a/index.py
+++ b/index.py
@@ -35,6 +35,7 @@ mods = {
'check_environment':migration.check_environment,
'get_environment_data': server.get_environment_data,
'get_repo_arch_info': server.get_repo_arch_info,
+ 'get_storage_num': server.get_storage_num,
}
diff --git a/views/server.py b/views/server.py
index 0a8eeed..369a750 100644
--- a/views/server.py
+++ b/views/server.py
@@ -322,4 +322,25 @@ def get_repo_arch_info(data):
res = {}
res['info'] = info_list
json_res = json.dumps(res)
- return json_res
\ No newline at end of file
+ return json_res
+
+
+def get_storage_num(data):
+ """
+ 获取可用空间足够和不足数量
+ :param data:
+ :return:
+ """
+ success_num_sql = "select agent_ip from agent_info where agent_online_status='0' and agent_storage>='10' " \
+ "and agent_migration_os is null;"
+ get_success_num = DBHelper().execute(success_num_sql).fetchall()
+
+ faild_num_sql = "select agent_ip from agent_info where agent_online_status='0' and agent_storage<'10' " \
+ "and agent_migration_os is null;"
+ get_faild_num = DBHelper().execute(faild_num_sql).fetchall()
+
+ success = len(get_success_num)
+ faild = len(get_faild_num)
+ data = {'success': success, 'faild': faild}
+ json_data = json.dumps(data)
+ return json_data
\ No newline at end of file
--
2.20.1

View File

@ -1,36 +0,0 @@
From ea5231b768fbbb8d23d1d5b45eb94d01d05bcbae Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:37:41 +0800
Subject: [PATCH] =?UTF-8?q?=E5=86=99=E5=85=A5=E6=AF=8F=E4=B8=80=E8=A1=8C?=
=?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=88=B0=E6=8A=A5=E5=91=8A=E5=86=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index bf32e49..7b77d95 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -676,3 +676,15 @@ def create_migrate_report_name(flag, logg):
#Rename the real report name
return mycopyfile(migrate_path_name_sample, migrate_name, logg)
+
+
+def write_row_and_column(report_name_rc, value_list, index):
+
+ row_column_rb = xlrd.open_workbook(report_name_rc, formatting_info=True)
+ r_sheet = row_column_rb.sheet_by_index(index)
+ row_column_wb = copy(row_column_rb)
+ row_column_sheet = row_column_wb.get_sheet(index)
+
+ for data in value_list:
+ row_column_sheet.write(int(data.split('|')[0]),int(data.split('|')[1]),data.split('|')[2])
+ row_column_wb.save(report_name_rc)
--
2.20.1

View File

@ -1,38 +0,0 @@
From 70b692876cec1e7615fe157fdab44293b0cbb697 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 14:39:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=BF=81=E7=A7=BB=E6=A3=80?=
=?UTF-8?q?=E6=B5=8B=E6=8A=A5=E5=91=8A=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/index.py b/index.py
index 2f5c946..505e91f 100644
--- a/index.py
+++ b/index.py
@@ -192,6 +192,17 @@ def get_storage_num():
return Response(mod, content_type='application/json')
+@app.route('/export_reports', methods=['GET', 'POST'])
+def export_reports():
+ """
+ 导出迁移检测报告
+ :return:
+ """
+ mod = check_methods()
+ if mod:
+ return Response(mod, content_type='application/json')
+
+
@app.route('/', methods=['GET', 'POST'])
def MT_index():
"""
--
2.20.1

View File

@ -1,69 +0,0 @@
From a609740d7ec3993c33db7179715abb9d624239ae Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:40:54 +0800
Subject: [PATCH] =?UTF-8?q?=E5=86=99=E5=85=A5=E5=A4=9A=E8=A1=8C=E5=92=8C?=
=?UTF-8?q?=E5=A4=9A=E5=88=97=E7=9A=84=E6=95=B0=E6=8D=AE=E5=88=B0=E6=8A=A5?=
=?UTF-8?q?=E5=91=8A=E5=86=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 44 +++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 7b77d95..4484fef 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -688,3 +688,47 @@ def write_row_and_column(report_name_rc, value_list, index):
for data in value_list:
row_column_sheet.write(int(data.split('|')[0]),int(data.split('|')[1]),data.split('|')[2])
row_column_wb.save(report_name_rc)
+
+
+def write_column_by_column(report_name_cc, column_value_list, row, column, index):
+
+ column_column_rb = xlrd.open_workbook(report_name_cc, formatting_info=True)
+ r_sheet = column_column_rb.sheet_by_index(index)
+ column_column_wb = copy(column_column_rb)
+ column_column_sheet = column_column_wb.get_sheet(index)
+
+ row_cc = row
+ for column_data in column_value_list:
+ column_column_sheet.write(row_cc, column, column_data.replace('\n','').split(',')[0])
+ row_cc = row_cc + 1
+
+ column_column_wb.save(report_name_cc)
+
+def write_row_by_row(report_name_rr, row_value_list, row, column, index):
+
+ row_row_rb = xlrd.open_workbook(report_name_rr, formatting_info=True)
+ r_sheet = row_row_rb.sheet_by_index(index)
+ row_row_wb = copy(row_row_rb)
+ row_row_sheet = row_row_wb.get_sheet(index)
+
+ before_summary_info = r_sheet.row_values(0)[0].replace('INCOMP_NUM', str(incomp_pkg_num()))
+ row_row_sheet.write(0, 0, before_summary_info)
+
+ row_rr = row
+ column_rr = column
+ for row_data in row_value_list:
+ row_list = row_data.replace('\n','').split(',')
+ i = column
+ column_rr = column
+ while i < (len(row_list) - 1):
+ if i==2 or i==3:
+ i = i + 1
+ continue
+ elif i==5:
+ row_row_sheet.write(row_rr, column_rr, row_list[i]+','+row_list[i+1])
+ else:
+ row_row_sheet.write(row_rr, column_rr, row_list[i])
+ i = i + 1
+ column_rr = column_rr + 1
+ row_rr = row_rr + 1
+ row_row_wb.save(report_name_rr)
--
2.20.1

View File

@ -1,65 +0,0 @@
From 5afe6e02fd325701cf308e0e4ad3297ac509adb3 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:46:44 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=80=BB=E7=BB=93=E7=9A=84?=
=?UTF-8?q?=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF=E5=88=B0=E6=8A=A5=E5=91=8A?=
=?UTF-8?q?=E5=86=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 40 +++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 4484fef..50bd201 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -732,3 +732,43 @@ def write_row_by_row(report_name_rr, row_value_list, row, column, index):
column_rr = column_rr + 1
row_rr = row_rr + 1
row_row_wb.save(report_name_rr)
+
+
+def write_summary_data(report_name_summary, index, flag):
+ summary_rb = xlrd.open_workbook(report_name_summary, formatting_info=True)
+ r_sheet = summary_rb.sheet_by_index(index)
+ summary_wb = copy(summary_rb)
+ summary_sheet = summary_wb.get_sheet(index)
+
+ if flag == '0':
+ with open(abi_comp_chk, 'r') as fs:
+ comp_num = len(fs.readlines())
+ before_summary_num = comp_num + incomp_pkg_num()
+
+ before_summary_info = r_sheet.row_values(0)[0].replace('REPLACE_NUM', str(before_summary_num))
+ summary_sheet.write(0, 0, before_summary_info)
+ summary_sheet.write(2, 0, get_cur_sys_version())
+
+ elif flag == '1':
+ migrbef_sysver = exp_rst_dir + 'sys-version-tmp'
+
+ with open(abi_comp_chk, 'r') as fsp:
+ comp_num = len(fsp.readlines())
+
+ with open(migration_system_install, 'r') as fsmp:
+ install_comp_num = str(len(fsmp.readlines()))
+ behind_summary_num = comp_num + incomp_pkg_num()
+
+ with open(migrbef_sysver, 'r') as file_object:
+ sys_version = file_object.read()
+
+ # 20220107 modify lihp: keep the history data
+ # os.remove(migrbef_sysver)
+
+ behind_summary_info_tmp = r_sheet.row_values(0)[0].replace('REPLACE_NUM', str(behind_summary_num))
+ behind_summary_info = behind_summary_info_tmp.replace('INSTALL_NUM', install_comp_num)
+ summary_sheet.write(0, 0, behind_summary_info)
+ summary_sheet.write(2, 0, sys_version)
+ summary_sheet.write(2, 2, get_cur_sys_version())
+
+ summary_wb.save(report_name_summary)
--
2.20.1

View File

@ -1,70 +0,0 @@
From 7decf366a655e8c7c93d165ce007cc37231a3fcc Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Mon, 13 Nov 2023 14:49:44 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=8A=A5=E5=91=8A=E7=9A=84?=
=?UTF-8?q?=E5=88=86=E4=B8=BA=E5=A4=9A=E4=B8=AAsheet=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/Abisystmcompchk.py | 46 +++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py
index 50bd201..0b5c519 100644
--- a/sysmig_agent/Abisystmcompchk.py
+++ b/sysmig_agent/Abisystmcompchk.py
@@ -772,3 +772,49 @@ def write_summary_data(report_name_summary, index, flag):
summary_sheet.write(2, 2, get_cur_sys_version())
summary_wb.save(report_name_summary)
+
+
+# Deal report of sheet by num value
+def switch_write_migrate_report(report_name, num, flag):
+ # sheet[0]-system info: write data:row|column|value
+ if num == 0:
+ if flag == '0':
+ migration_value_list = get_cur_sys_info_list()
+ elif flag == '1':
+ migration_value_list = get_migration_sys_info()
+ write_row_and_column(report_name, migration_value_list, num)
+ # sheet[1]-rpm package
+ elif num == 1:
+ with open(current_system_unique, 'r') as fr_cur:
+ column_cur_list = fr_cur.readlines()
+ write_column_by_column(report_name, column_cur_list, 3, 0, num)
+
+ if flag == '0':
+ # sheet[1]:2-column
+ with open(migration_system_total, 'r') as fr_migr:
+ column_migr_list = fr_migr.readlines()
+ write_column_by_column(report_name, column_migr_list, 3, 1, num)
+ elif flag == '1':
+ # sheet[1]:2-column
+ with open(migration_system_install, 'r') as fr_migr:
+ column_migr_list = fr_migr.readlines()
+ write_column_by_column(report_name, column_migr_list, 3, 1, num)
+
+ # sheet[1]:3-row
+ with open(migration_system_total, 'r') as fr_migr:
+ column_migr_list = fr_migr.readlines()
+ write_column_by_column(report_name, column_migr_list, 3, 2, num)
+
+ # summary data write to sheet[1]
+ write_summary_data(report_name, num, flag)
+
+ # sheet[2]-ABI compartion
+ elif num == 2:
+ with open(abi_comp_chk, 'r') as fr_comp:
+ column_comp_list = fr_comp.readlines()
+ write_column_by_column(report_name, column_comp_list, 1, 0, num)
+ # sheet[3]-ABI Incompartion
+ elif num == 3:
+ with open(abi_incomp_chk, 'r') as fr_incomp:
+ column_incomp_list = fr_incomp.readlines()
+ write_row_by_row(report_name, column_incomp_list, 2, 0, num)
--
2.20.1

Binary file not shown.

View File

@ -1,96 +1,12 @@
Name: migration-tools
Version: 1.0.2
Release: 84
Version: 1.0.3
Release: 0
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
Source1: requires.tar.gz
Source2: xlwt-1.3.0-py2.py3-none-any.whl
# patches
Patch0: 0001-format-code.patch
Patch1: 0002-modify-excel-report-content.patch
Patch2: 0003-delete-redundant-code.patch
Patch3: 0004-connect-sql-function.patch
Patch4: 0005-execution-sql-function.patch
Patch5: 0006-add-loger-interface-function.patch
Patch6: 0007-add-function-to-import-machine.patch
Patch7: 0008-add-agent_info-table-in-database.patch
Patch8: 0009-add-task_stream-table-in-database.patch
Patch10: 0010-create-task-stream-interface.patch
Patch11: 0011-replace-agent-with-func-diractory.patch
Patch12: 0012-add-agent_task-in-database.patch
Patch13: 0013-display-agent-host-information.patch
Patch14: 0014-modify-task-stream-interface.patch
Patch15: 0015-delete-host-information-interface.patch
Patch16: 0016-get-local-ip-on-the-agent.patch
Patch17: 0017-add-process-data-in-database.patch
Patch18: 0018-detection-of-imported-host-information-interface.patch
Patch19: 0019-update-abi-result-to-database.patch
Patch20: 0020-get-task-process-and-migration-stage-information.patch
Patch21: 0021-get-agent-ip-interface.patch
Patch22: 0022-udpate-agent-host-status-online.patch
Patch23: 0023-update-the-status-of-the-migration-phase.patch
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
Patch29: 0029-json-and-list-format-interchange.patch
Patch30: 0030-system-information-import-info-the-database-after-migration.patch
Patch31: 0031-migration-check-and-extract-macros.patch
Patch32: 0032-add-migration.py-to-migration-function.patch
Patch33: 0033-check-system-kernrel.patch
Patch34: 0034-add-centos7-and-centos8-migration-interface.patch
Patch35: 0035-the-migration-process-can-choose-not-to-migrate-the-kernel.patch
Patch36: 0036-add-an-interface-to-obtain-kernel-information.patch
Patch37: 0037-add-subprocess-function-and-loggin.patch
Patch38: 0038-obtain-kernel-data.patch
Patch39: 0039-repository-file-choose-kernel-version-to-migration.patch
Patch40: 0040-intial-logfile-and-tmpfile.patch
Patch41: 0041-get-migration-status-from-database.patch
Patch42: 0042-get-initial-os-version-from-agent_info-interface.patch
Patch43: 0043-process-os-version-and-os-name.patch
Patch44: 0044-migrate-in-myutiple-steps.patch
Patch45: 0045-modify-repository-file.patch
Patch46: 0046-agent-sends-task-update-requrst-to-the-server.patch
Patch47: 0047-check-kernel-version-in-repository.patch
Patch48: 0048-server-send-kernel-detection-task.patch
Patch49: 0049-add-interface-to-check-repository-result.patch
Patch50: 0050-check-free-space-in-system-disk.patch
Patch51: 0051-add-basic-system-detection-information-and-upload-the-database.patch
Patch52: 0052-increase-the-weight-of-abi-detection-result.patch
Patch53: 0053-get-repository-detection-result.patch
Patch54: 0054-removed-detection-abi-script.patch
Patch55: 0055-add-envirnment-detection-interface-before-migration.patch
Patch56: 0056-modify-detection-envirnment-interface.patch
Patch57: 0057-abi-basic-data-for-report.patch
Patch58: 0058-get-detection-envirnment-process-interface.patch
Patch59: 0059-add-kernel-detection-result-to-abi-report.patch
Patch60: 0060-add-four-detection-item-to-abi-report.patch
Patch61: 0061-detection-abi-log.patch
Patch62: 0062-add-detection-ELF-content-in-abi-file.patch
Patch63: 0063-add-compare-with-package-result-in-abi-report.patch
Patch64: 0064-get-system-package-information-in-rpm-database.patch
Patch65: 0065-get-checking-envirnmnet-process.patch
Patch66: 0066-check-if-file-is-binary.patch
Patch67: 0067-add-an-abi-comparation-function.patch
Patch68: 0068-get-file-list-and-provide-file-path-to-compare.patch
Patch69: 0069-get-package-list-downloaded-locally-from-the-software-repository.patch
Patch70: 0070-interface-for-obtaining-repo-interface.patch
Patch71: 0071-get-package-list-from-repository.patch
Patch72: 0072-count-the-total-number-of-abi-compatible-lists.patch
Patch73: 0073-get-os-version-and-os-id.patch
Patch74: 0074-detection-basic-system-information.patch
Patch75: 0075-detection-basic-information-and-format-abi-compatibility-information-to-report.patch
Patch76: 0076-detection-storage-interface.patch
Patch77: 0077-copy-from-unzip-rpm-diractory-and-system-file-to-compatility-diractory.patch
Patch78: 0078-fill-in-the-data-in-the-checked-templace.patch
Patch79: 0079-get-agent-storage-information.patch
Patch80: 0080-write-the-data-of-each-row-into-report.patch
Patch81: 0081-add-interface-to-export-migration-check-report.patch
Patch82: 0082-write-the-data-of-each-row-and-column-into-report.patch
Patch83: 0083-add-basic-summary-information-to-the-report.patch
Patch84: 0084-divide-detection-report-into-mutiple-sheet-pages.patch
BuildArch: noarch
BuildRequires: systemd
@ -189,6 +105,9 @@ rm -rf /usr/bin/migration-tools
%endif
%changelog
* Mon Nov 11 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.3-0
- update to 1.0.3
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-84
- 0084-divide-detection-report-into-mutiple-sheet-pages.patch