12248afa3a
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>
26 lines
609 B
Python
26 lines
609 B
Python
"""
|
|
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")
|