From f519942ffa03915f2a82a6e7bb83f05f431246e6 Mon Sep 17 00:00:00 2001 From: vapao Date: Thu, 9 Dec 2021 11:06:14 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=BB=E6=9C=BA=E6=89=A9=E5=B1=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/host/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spug_api/apps/host/utils.py b/spug_api/apps/host/utils.py index 28b3b64..c0a13d7 100644 --- a/spug_api/apps/host/utils.py +++ b/spug_api/apps/host/utils.py @@ -216,9 +216,13 @@ def fetch_host_extend(ssh): code, out = ssh.exec_command_raw('lsblk -dbn -o SIZE -e 11 2> /dev/null') if code == 0: - for item in out.strip().splitlines()[:10]: + disks = [] + for item in out.strip().splitlines(): item = item.strip() - response['disk'].append(math.ceil(int(item) / 1024 / 1024 / 1024)) + size = math.ceil(int(item) / 1024 / 1024 / 1024) + if size > 10: + disks.append(size) + response['disk'] = disks[:10] code, out = ssh.exec_command_raw("dmidecode -t 17 | grep -E 'Size: [0-9]+' | awk '{s+=$2} END {print s,$3}'") if code == 0: