homelab: Rueckweg auch als Kurzform (snapshot/sicherung/keiner) fuer die Update-Liste
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
37179b8864
commit
d2f699ac69
@@ -48,6 +48,7 @@ class ZielStand:
|
|||||||
bausteine: list[BausteinStand] = field(default_factory=list)
|
bausteine: list[BausteinStand] = field(default_factory=list)
|
||||||
geprueft: float | None = None # Unix-Sekunden der letzten Prüfung
|
geprueft: float | None = None # Unix-Sekunden der letzten Prüfung
|
||||||
rueckweg: str | None = None # „Sicherung vor jedem Lauf", „Snapshot", „nur Backup"
|
rueckweg: str | None = None # „Sicherung vor jedem Lauf", „Snapshot", „nur Backup"
|
||||||
|
rueckweg_art: str | None = None # Kurzform für die Oberfläche: „snapshot“, „sicherung“ oder „keiner“
|
||||||
|
|
||||||
def als_dict(self) -> dict:
|
def als_dict(self) -> dict:
|
||||||
daten = asdict(self)
|
daten = asdict(self)
|
||||||
|
|||||||
@@ -84,6 +84,13 @@ def _rueckweg(gast: dict) -> str:
|
|||||||
return grund
|
return grund
|
||||||
|
|
||||||
|
|
||||||
|
def _rueckweg_art(gast: dict) -> str:
|
||||||
|
"""Dasselbe in einem Wort — die Oberfläche fasst den Rückweg in der Update-Liste kurz."""
|
||||||
|
if gast.get("snapshot_moeglich"):
|
||||||
|
return "snapshot"
|
||||||
|
return "sicherung" if gast.get("sicherung_moeglich") else "keiner"
|
||||||
|
|
||||||
|
|
||||||
def _rueckweg_frage(gast: dict) -> str:
|
def _rueckweg_frage(gast: dict) -> str:
|
||||||
"""Der Satz zum Rückweg in der Rückfrage vor „Jetzt updaten“."""
|
"""Der Satz zum Rückweg in der Rückfrage vor „Jetzt updaten“."""
|
||||||
if gast.get("snapshot_moeglich"):
|
if gast.get("snapshot_moeglich"):
|
||||||
@@ -203,7 +210,7 @@ def _gast_ziel(gast: dict, jetzt: float) -> ZielStand:
|
|||||||
laeuft = gast.get("status") == "running"
|
laeuft = gast.get("status") == "running"
|
||||||
ziel = ZielStand(id=zid, name=app.name if app else str(gast.get("name") or zid), art=art, instanz="homelab",
|
ziel = ZielStand(id=zid, name=app.name if app else str(gast.get("name") or zid), art=art, instanz="homelab",
|
||||||
erreichbar=(erreichbar(url) if laeuft else False) if url else (laeuft or None),
|
erreichbar=(erreichbar(url) if laeuft else False) if url else (laeuft or None),
|
||||||
rueckweg=_rueckweg(gast))
|
rueckweg=_rueckweg(gast), rueckweg_art=_rueckweg_art(gast))
|
||||||
if not laeuft:
|
if not laeuft:
|
||||||
ziel.bausteine.append(BausteinStand(id="status", name="Status", zustand="unbekannt",
|
ziel.bausteine.append(BausteinStand(id="status", name="Status", zustand="unbekannt",
|
||||||
grund=f"Der Gast ist {gast.get('status') or 'unbekannt'}."))
|
grund=f"Der Gast ist {gast.get('status') or 'unbekannt'}."))
|
||||||
@@ -226,7 +233,8 @@ def _gast_ziel(gast: dict, jetzt: float) -> ZielStand:
|
|||||||
|
|
||||||
def _host_ziel(host: dict) -> ZielStand:
|
def _host_ziel(host: dict) -> ZielStand:
|
||||||
ziel = ZielStand(id="pve", name="Proxmox-Host", art="proxmox-host", instanz="homelab", erreichbar=True,
|
ziel = ZielStand(id="pve", name="Proxmox-Host", art="proxmox-host", instanz="homelab", erreichbar=True,
|
||||||
rueckweg="Kein Snapshot möglich; der Host bleibt beim Update in Betrieb, neu gestartet wird getrennt.")
|
rueckweg="Kein Snapshot möglich; der Host bleibt beim Update in Betrieb, neu gestartet wird getrennt.",
|
||||||
|
rueckweg_art="keiner")
|
||||||
updates = host.get("updates")
|
updates = host.get("updates")
|
||||||
pakete = BausteinStand(id="pakete", name="Proxmox VE und Debian", zustand="aktuell",
|
pakete = BausteinStand(id="pakete", name="Proxmox VE und Debian", zustand="aktuell",
|
||||||
installiert=host.get("version"))
|
installiert=host.get("version"))
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ def test_ziele_aus_dem_echten_bericht(daten):
|
|||||||
gitea = {b["id"]: b for b in z["ct-104"]["bausteine"]}
|
gitea = {b["id"]: b for b in z["ct-104"]["bausteine"]}
|
||||||
assert (gitea["app"]["zustand"], gitea["app"]["kurz"]) == ("neu", "1.27.2 → 1.27.3")
|
assert (gitea["app"]["zustand"], gitea["app"]["kurz"]) == ("neu", "1.27.2 → 1.27.3")
|
||||||
assert z["ct-104"]["name"] == "Gitea" and z["ct-104"]["rueckweg"] == "Snapshot vor jedem Update"
|
assert z["ct-104"]["name"] == "Gitea" and z["ct-104"]["rueckweg"] == "Snapshot vor jedem Update"
|
||||||
|
assert (z["ct-104"]["rueckweg_art"], z["pve"]["rueckweg_art"]) == ("snapshot", "keiner")
|
||||||
|
|
||||||
adguard = {b["id"]: b for b in z["ct-100"]["bausteine"]}
|
adguard = {b["id"]: b for b in z["ct-100"]["bausteine"]}
|
||||||
assert adguard["app"]["zustand"] == "aktuell"
|
assert adguard["app"]["zustand"] == "aktuell"
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ export function rueckwegText(ziel: ZielStand): string {
|
|||||||
|
|
||||||
function rueckwegAusText(text: string | null): "snapshot" | "sicherung" | "keiner" {
|
function rueckwegAusText(text: string | null): "snapshot" | "sicherung" | "keiner" {
|
||||||
const t = (text ?? "").toLowerCase()
|
const t = (text ?? "").toLowerCase()
|
||||||
if (t.includes("snapshot vor")) return "snapshot"
|
if (t.startsWith("snapshot vor")) return "snapshot"
|
||||||
if (t.includes("sicherung vor")) return "sicherung"
|
if (t.startsWith("sicherung")) return "sicherung"
|
||||||
return "keiner"
|
return "keiner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user