fix: type disque SATA + df timeout Proxmox

- disk_type : rota booléen (False/True) en plus des int (0/1) — lsblk récent
- df --local : évite le timeout sur montages réseau/NFS (Proxmox)
- 6 nouveaux tests disk_type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gilles Soulier
2026-05-28 20:50:19 +02:00
parent 29a63be483
commit 325b5dc281
2 changed files with 26 additions and 3 deletions
+5 -3
View File
@@ -254,9 +254,10 @@ def get_bus(dev_name):
def disk_type(name, rota): def disk_type(name, rota):
if name.startswith("nvme"): if name.startswith("nvme"):
return "NVMe" return "NVMe"
if str(rota) == "1": # lsblk renvoie rota en entier (0/1) ou booléen (False/True) selon la version
if rota in (1, True, "1"):
return "HDD" return "HDD"
if str(rota) == "0": if rota in (0, False, "0"):
return "SSD" return "SSD"
return "inconnu" return "inconnu"
@@ -265,7 +266,8 @@ def disk_type(name, rota):
def get_df_map(): def get_df_map():
dprint("lecture espace disques via df...") dprint("lecture espace disques via df...")
out = run(["df", "--output=target,size,used,avail", "-B1"]) # --local evite les montages réseau/NFS qui peuvent bloquer (ex: Proxmox)
out = run(["df", "--output=target,size,used,avail", "-B1", "--local"])
result = {} result = {}
if not out: if not out:
return result return result
+21
View File
@@ -103,6 +103,27 @@ def test_bytes_human_none():
assert inventaire.bytes_human(None) == "?" assert inventaire.bytes_human(None) == "?"
# -- disk_type ----------------------------------------------------------------
def test_disk_type_nvme():
assert inventaire.disk_type("nvme0n1", None) == "NVMe"
def test_disk_type_hdd_int():
assert inventaire.disk_type("sda", 1) == "HDD"
def test_disk_type_ssd_int():
assert inventaire.disk_type("sdb", 0) == "SSD"
def test_disk_type_hdd_bool():
assert inventaire.disk_type("sda", True) == "HDD"
def test_disk_type_ssd_bool():
assert inventaire.disk_type("sdb", False) == "SSD"
def test_disk_type_inconnu():
assert inventaire.disk_type("sdc", None) == "inconnu"
# ── get_smart ───────────────────────────────────────────────────────────────── # ── get_smart ─────────────────────────────────────────────────────────────────
SMART_PASSED = """ SMART_PASSED = """