feat(hardware): проброс физических дисков ноды в VM (raw passthrough)
All checks were successful
Backend Tests / pytest (Python 3.12) (push) Successful in 56s
Deploy to Production / Trigger production update (push) Successful in 7s

Добавлена возможность пробросить физический диск ноды в VM по стабильному
пути /dev/disk/by-id/ (scsiN/virtioN/sataN) в карточке «Проброс устройств».

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
markmorado
2026-07-06 23:37:13 +05:00
parent bec7b20e31
commit 782524fff6
10 changed files with 358 additions and 12 deletions

View File

@@ -18,11 +18,30 @@ class DisksMixin:
if not self.proxmox:
return []
try:
return list(self.proxmox.nodes(node).disks.list.get() or [])
disks = list(self.proxmox.nodes(node).disks.list.get() or [])
for d in disks:
d["passthrough_path"] = self._disk_passthrough_path(d)
return disks
except Exception as e:
logger.error(f"Error getting disks for node {node}: {e}")
return []
@staticmethod
def _disk_passthrough_path(disk: Dict) -> Optional[str]:
"""Стабильный путь устройства для проброса в VM.
Предпочитаем /dev/disk/by-id/* (не меняется между загрузками),
затем wwn, в крайнем случае — devpath (/dev/sdX, нестабилен).
"""
by_id = disk.get("by_id_link") or disk.get("by-id-link")
if by_id:
return by_id if str(by_id).startswith("/dev/") else f"/dev/disk/by-id/{by_id}"
wwn = disk.get("wwn")
if wwn:
wwn = str(wwn).replace("0x", "")
return f"/dev/disk/by-id/wwn-0x{wwn}"
return disk.get("devpath")
def get_disk_smart(self, node: str, disk: str) -> Dict:
"""SMART-данные диска (health + attributes)."""
if not self.proxmox: