feat(containers-dashboard): voeg host_ip toe aan gepubliceerde poorten en corrigeer portweergave

This commit is contained in:
kodi
2026-02-18 11:41:48 +01:00
parent 3142e9fbd0
commit 2a08ad6989
3 changed files with 29 additions and 4 deletions
+26
View File
@@ -439,6 +439,31 @@ def find_defined_containers():
defined[name] = rel
return defined
def _extract_published_ports(container: dict) -> list[str]:
"""
Normalize Podman API Ports into a stable display list:
- "127.0.0.1:8080:8000/tcp"
- "8080:8000/tcp" (if no host ip)
"""
out: list[str] = []
for p in (container.get("Ports") or []):
host_ip = p.get("host_ip") or p.get("HostIp") or ""
host_port = p.get("host_port") or p.get("HostPort")
cont_port = p.get("container_port") or p.get("ContainerPort")
proto = p.get("protocol") or p.get("Protocol") or ""
if host_port is None or cont_port is None:
continue
s = ""
if host_ip:
s += f"{host_ip}:"
s += f"{host_port}:{cont_port}"
if proto:
s += f"/{proto}"
out.append(s)
return out
@app.get("/containers-dashboard")
def containers_dashboard():
@@ -449,6 +474,7 @@ def containers_dashboard():
for c in real:
_ensure_container_status_field(c)
c["_dashboard_source"] = "podman"
c["_dashboard_published_ports"] = _extract_published_ports(c)
dashboard.append(c)
# B) Dedup set (HOTFIX 3.3) — exact extraction, no sorting