refactor(api): move /test-hybrid into app_system router

This commit is contained in:
kodi
2026-02-28 11:58:55 +01:00
parent e61f2ccf76
commit 1226b0654e
4 changed files with 32 additions and 29 deletions
+26 -1
View File
@@ -1,9 +1,11 @@
import os
import subprocess
from fastapi import APIRouter
from common import _podman_get_json as _common_podman_get_json
def init_system_router(session, podman_api_base: str) -> APIRouter:
def init_system_router(session, podman_api_base: str, workloads_dir: str) -> APIRouter:
router = APIRouter(tags=["system"])
@router.get("/health")
@@ -40,4 +42,27 @@ def init_system_router(session, podman_api_base: str) -> APIRouter:
"systemd_user": {"reachable": systemd_reachable},
}
@router.get("/test-hybrid")
def test_hybrid():
# 1. Check filesystem
try:
bestanden = []
for root, _, files in os.walk(workloads_dir):
for f in files:
bestanden.append(os.path.join(root, f))
except Exception as e:
bestanden = f"FS Fout: {str(e)}"
# 2. Check Podman API
try:
api_containers = _common_podman_get_json(session, f"{podman_api_base}/libpod/containers/json?all=true")
except Exception as e:
api_containers = f"API Fout: {str(e)}"
return {
"bestanden_gevonden": bestanden if isinstance(bestanden, list) else [],
"api_containers_aantal": len(api_containers) if isinstance(api_containers, list) else -1,
"api_raw_sample": api_containers[0] if isinstance(api_containers, list) and api_containers else api_containers,
}
return router