f8bbb783b0
Nieuw bestand control/app_volumes.py met Libpod volume operaties:
- GET /volumes — lijst alle volumes (optioneel ?filters=key=value)
- POST /volumes — volume aanmaken (name, driver, labels, driverOpts)
- GET /volumes/{name} — details van één volume
- GET /volumes/{name}/exists — bestaanskontrolle (204 → true, 404 → false)
- DELETE /volumes/{name} — volume verwijderen (?force=true optioneel)
- POST /volumes/prune — ⚠️ verwijdert alle ongebruikte volumes
Filters: key=value formaat wordt automatisch omgezet naar
{"key":["value"]} JSON dat de Libpod API verwacht.
Containerfile: COPY app_volumes.py toegevoegd.
app.py: init_volumes_router geregistreerd.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from app_images import init_images_router
|
|
from app_volumes import init_volumes_router
|
|
from app_files import init_files_router
|
|
from app_pods import init_pods_router
|
|
from app_containers import init_containers_router, start_stats_poller
|
|
from app_networks import init_networks_router
|
|
from app_system import init_system_router
|
|
from fastapi import FastAPI
|
|
import requests_unixsocket
|
|
from common import (
|
|
_systemctl as _common_systemctl,
|
|
run,
|
|
)
|
|
import uvicorn
|
|
|
|
app = FastAPI(title="Podman MVP Control Plane", root_path="/api")
|
|
SESSION = requests_unixsocket.Session()
|
|
PODMAN_API_BASE = "http+unix://%2Frun%2Fuser%2F1000%2Fpodman%2Fpodman.sock/v5.4.2"
|
|
WORKLOADS_DIR = "/app/workloads"
|
|
|
|
@app.on_event("startup")
|
|
async def _startup_stats_poller():
|
|
await start_stats_poller()
|
|
|
|
def _systemctl(cmd):
|
|
return _common_systemctl(cmd, run)
|
|
|
|
# --- ROUTERS ---
|
|
# Images API lives in dedicated modules to keep this file from growing further.
|
|
app.include_router(init_images_router(SESSION, PODMAN_API_BASE))
|
|
app.include_router(init_volumes_router(SESSION, PODMAN_API_BASE))
|
|
app.include_router(init_files_router(SESSION, PODMAN_API_BASE, WORKLOADS_DIR))
|
|
app.include_router(init_networks_router(SESSION, PODMAN_API_BASE))
|
|
app.include_router(init_containers_router(
|
|
SESSION,
|
|
PODMAN_API_BASE,
|
|
WORKLOADS_DIR,
|
|
_systemctl,
|
|
))
|
|
app.include_router(init_pods_router(
|
|
SESSION,
|
|
PODMAN_API_BASE,
|
|
WORKLOADS_DIR,
|
|
_systemctl,
|
|
))
|
|
app.include_router(init_system_router(SESSION, PODMAN_API_BASE, WORKLOADS_DIR))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|