Refactor: Container-Erkennung zentralisiert, SMART-Check auf LXC überspringen
Neues Modul services/platform_info.py prüft systemd-detect-virt einmalig beim Start (statt pro Request). SMART-Abfragen werden in Containern übersprungen, da /dev/sdX dort meist nicht verfügbar ist. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Platform/Virtualization Detection
|
||||
Einmalige Prüfung via systemd-detect-virt beim Start.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _detect_virt() -> str:
|
||||
try:
|
||||
r = subprocess.run(["/usr/bin/systemd-detect-virt"], capture_output=True, text=True, timeout=3)
|
||||
return r.stdout.strip()
|
||||
except Exception:
|
||||
return "none"
|
||||
|
||||
|
||||
VIRT_TYPE = _detect_virt()
|
||||
IS_CONTAINER = VIRT_TYPE not in ("none", "")
|
||||
IS_LXC = VIRT_TYPE == "lxc"
|
||||
|
||||
if IS_CONTAINER:
|
||||
logger.info(f"Running inside container (virt={VIRT_TYPE}) — hardware-specific checks disabled")
|
||||
Reference in New Issue
Block a user