!132 get agent storage inforamation

From: @xuezhizone 
Reviewed-by: @xingwei-liu 
Signed-off-by: @xingwei-liu
This commit is contained in:
openeuler-ci-bot 2024-11-07 13:02:11 +00:00 committed by Gitee
commit 847bc2a3dd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 130 additions and 1 deletions

View File

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

@ -0,0 +1,62 @@
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,6 +1,6 @@
Name: migration-tools
Version: 1.0.2
Release: 77
Release: 79
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
@ -84,6 +84,8 @@ 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
BuildArch: noarch
@ -183,6 +185,12 @@ rm -rf /usr/bin/migration-tools
%endif
%changelog
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-79
- 0079-get-agent-storage-information.patch
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-78
- 0078-fill-in-the-data-in-the-checked-templace.patch
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-77
- 0077-copy-from-unzip-rpm-diractory-and-system-file-to-compatility-diractory.patch