!103 check free space in system disk

From: @xuezhizone 
Reviewed-by: @xingwei-liu 
Signed-off-by: @xingwei-liu
This commit is contained in:
openeuler-ci-bot 2024-11-06 06:55:12 +00:00 committed by Gitee
commit b596588aee
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,52 @@
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,6 +1,6 @@
Name: migration-tools
Version: 1.0.2
Release: 49
Release: 50
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
@ -56,6 +56,9 @@ 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
BuildArch: noarch
BuildRequires: systemd
@ -154,6 +157,9 @@ rm -rf /usr/bin/migration-tools
%endif
%changelog
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-50
- 0050-check-free-space-in-system-disk.patch
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-49
- 0049-add-interface-to-check-repository-result.patch