- pulp_client: get_repo / sync_repo / get_task (비동기 task href 반환)
- POST /repos/{uuid}/sync: remote 확인 후 동기화 시작, 진행률 조각 반환
- GET /repos/{uuid}/progress: progress_reports 합산 → 바/퍼센트,
완료/실패 시 hx-trigger 제거로 폴링 중단
- task_store: uuid→task_href 메모리 추적 (단일 인스턴스), 대시보드 '동기화 중' 집계
- views.task_progress: state/done/total/percent + created_resources에서 새 vN
- 동기화는 안전 동작이라 확인 모달 없이 실행 (스펙 §5-1)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
"""FastAPI 진입점: 정적 자산 마운트, 라우터 등록, 헬스체크.
|
|
|
|
화면용 라우트는 JSON 이 아니라 HTML(전체 페이지 또는 조각)을 반환한다(스펙 §7).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import httpx
|
|
from fastapi import Depends, FastAPI, Request
|
|
from fastapi.responses import HTMLResponse
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
# 테스트 호환을 위해 re-export (tests 가 app.main.get_pulp_client 를 override 함)
|
|
from .deps import get_pulp_client, templates
|
|
from .pulp_client import PulpClient
|
|
from .routes import dashboard, sync
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent
|
|
|
|
app = FastAPI(title="Pulp 패치 관리 콘솔")
|
|
app.mount("/static", StaticFiles(directory=str(BASE_DIR / "static")), name="static")
|
|
app.include_router(dashboard.router)
|
|
app.include_router(sync.router)
|
|
|
|
__all__ = ["app", "get_pulp_client"]
|
|
|
|
|
|
@app.get("/healthz", response_class=HTMLResponse)
|
|
def healthz(
|
|
request: Request, pulp: PulpClient = Depends(get_pulp_client)
|
|
) -> HTMLResponse:
|
|
"""Pulp status 프록시 → 연결 상태 배지 조각."""
|
|
try:
|
|
pulp.status()
|
|
online, detail = True, "Pulp 연결됨"
|
|
except httpx.HTTPError as exc:
|
|
online, detail = False, f"Pulp 연결 실패: {exc}"
|
|
|
|
return templates.TemplateResponse(
|
|
request,
|
|
"partials/health.html",
|
|
{"online": online, "detail": detail},
|
|
status_code=200 if online else 503,
|
|
)
|