export migration check report
This commit is contained in:
parent
9d8a277dcf
commit
077d02a06f
102
0003-export-migration-check-report.patch
Normal file
102
0003-export-migration-check-report.patch
Normal file
@ -0,0 +1,102 @@
|
||||
From 75714106374a4e62630c0e6b131f74a0717518bc Mon Sep 17 00:00:00 2001
|
||||
From: lixin <lixinb@uniontech.com>
|
||||
Date: Mon, 13 Nov 2023 15:17:47 +0800
|
||||
Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=A3=80=E6=B5=8B=E6=8A=A5?=
|
||||
=?UTF-8?q?=E5=91=8A=E5=AF=BC=E5=87=BA?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
---
|
||||
views/reports.py | 25 +++++++++++++++++++++++++
|
||||
views/server.py | 33 ++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 57 insertions(+), 1 deletion(-)
|
||||
create mode 100644 views/reports.py
|
||||
|
||||
diff --git a/views/reports.py b/views/reports.py
|
||||
new file mode 100644
|
||||
index 0000000..6295283
|
||||
--- /dev/null
|
||||
+++ b/views/reports.py
|
||||
@@ -0,0 +1,25 @@
|
||||
+import os
|
||||
+from logger import *
|
||||
+from connect_sql import DBHelper
|
||||
+
|
||||
+
|
||||
+os.chdir('/usr/lib/uos-sysmig-server')
|
||||
+migration_log = Logger('/var/tmp/uos-migration/migration.log', logging.DEBUG, logging.DEBUG)
|
||||
+
|
||||
+
|
||||
+def migration_detection(data):
|
||||
+ """
|
||||
+ 迁移检测报告
|
||||
+ :return:
|
||||
+ """
|
||||
+ agent_ip = data.get('agent_ip')
|
||||
+ info_sql = "select AES_DECRYPT(agent_passwd, 'coco'),agent_username from agent_info where agent_ip='%s'" % agent_ip
|
||||
+ info = DBHelper().execute(info_sql).fetchall()
|
||||
+ scp_log = "sshpass -p %s scp -r %s@%s:/var/tmp/uos-migration/UOS_analysis_report*.tar.gz /var/uos-migration/" % \
|
||||
+ (str(info[0][0], encoding="utf-8"), info[0][1], agent_ip)
|
||||
+ try:
|
||||
+ os.system(scp_log)
|
||||
+ migration_log.info(scp_log)
|
||||
+ except:
|
||||
+ migration_log.error('export report scp error:%s' % scp_log)
|
||||
+ return 'success'
|
||||
\ No newline at end of file
|
||||
diff --git a/views/server.py b/views/server.py
|
||||
index 369a750..4cfab8f 100644
|
||||
--- a/views/server.py
|
||||
+++ b/views/server.py
|
||||
@@ -1,8 +1,13 @@
|
||||
import json
|
||||
+import os
|
||||
from datetime import datetime
|
||||
|
||||
from connect_sql import DBHelper
|
||||
from sysmig_agent.share import getSysMigConf
|
||||
+from views import reports
|
||||
+from logger import *
|
||||
+
|
||||
+migration_log = Logger('/var/tmp/uos-migration/migration.log', logging.DEBUG, logging.DEBUG)
|
||||
|
||||
def import_host_info(data):
|
||||
"""
|
||||
@@ -343,4 +348,30 @@ def get_storage_num(data):
|
||||
faild = len(get_faild_num)
|
||||
data = {'success': success, 'faild': faild}
|
||||
json_data = json.dumps(data)
|
||||
- return json_data
|
||||
\ No newline at end of file
|
||||
+ return json_data
|
||||
+
|
||||
+
|
||||
+reports_type = {
|
||||
+ "migration_detection": reports.migration_detection,
|
||||
+}
|
||||
+
|
||||
+def export_reports(data):
|
||||
+ """
|
||||
+ 导出各种报告
|
||||
+ :param data:
|
||||
+ :return:
|
||||
+ """
|
||||
+ data = json.loads(data)
|
||||
+ report_type = reports_type.get(data.get('reports_type'))
|
||||
+ if report_type:
|
||||
+ mkdir_log_pwd = "/var/uos-migration/"
|
||||
+ isExists = os.path.exists(mkdir_log_pwd)
|
||||
+ if not isExists:
|
||||
+ try:
|
||||
+ os.makedirs(mkdir_log_pwd)
|
||||
+ migration_log.info(mkdir_log_pwd)
|
||||
+ except:
|
||||
+ migration_log.war("export report mkdir war:%s" % mkdir_log_pwd)
|
||||
+
|
||||
+ report_type(data)
|
||||
+ return 'success'
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: migration-tools
|
||||
Version: 1.0.3
|
||||
Release: 2
|
||||
Release: 3
|
||||
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
|
||||
@ -9,7 +9,7 @@ Source2: xlwt-1.3.0-py2.py3-none-any.whl
|
||||
# patches
|
||||
Patch001: 0001-download-the-rpm-package-in-the-system.patch
|
||||
Patch002: 0002-get-information-before-migration.patch
|
||||
|
||||
Patch003: 0003-export-migration-check-report.patch
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: systemd
|
||||
@ -108,6 +108,9 @@ rm -rf /usr/bin/migration-tools
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Nov 11 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.3-3
|
||||
- 0003-export-migration-check-report.patch
|
||||
|
||||
* Mon Nov 11 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.3-2
|
||||
- 0002-get-information-before-migration.patch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user