Bootstrap v2 už nejde spustit bez režimu:
výchozí akce je Run Bootstrap Check s mode=check, Run Bootstrap Repair je samostatná akce s potvrzením, Run Bootstrap Deploy je oddělený ve výrazném varování a není defaultní.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import html
|
||||
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from fastapi import APIRouter, Depends, Form, HTTPException, Request
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
|
||||
from app.auth import require_user
|
||||
@@ -18,6 +18,7 @@ from app.routes.jobs import render_job_status
|
||||
from app.templates.layout import page
|
||||
|
||||
router = APIRouter()
|
||||
BOOTSTRAP_MODES = {"check", "repair", "deploy"}
|
||||
|
||||
|
||||
def render_readiness_pill(ready: bool) -> str:
|
||||
@@ -107,23 +108,36 @@ def migration_readiness_page(request: Request, user=Depends(require_user)):
|
||||
<form method="post" action="/portal/migration-readiness/run">
|
||||
<button type="submit">Spustit preflight kontrolu</button>
|
||||
</form>
|
||||
<form method="post" action="/portal/migration-readiness/bootstrap" onsubmit="return confirm('Spustit Bootstrap v2? Tato akce upravuje server přes maintenance job.');">
|
||||
<button type="submit" class="danger">Run Bootstrap v2</button>
|
||||
<form method="post" action="/portal/migration-readiness/bootstrap">
|
||||
<input type="hidden" name="mode" value="check">
|
||||
<button type="submit" class="btn-secondary">Run Bootstrap Check</button>
|
||||
</form>
|
||||
<form method="post" action="/portal/migration-readiness/bootstrap" onsubmit="return confirm('Spustit Bootstrap v2 repair? Tato akce opravuje práva přes maintenance job.');">
|
||||
<input type="hidden" name="mode" value="repair">
|
||||
<button type="submit" class="btn-secondary">Run Bootstrap Repair</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<strong>Bootstrap v2 provádí zásahy do systému.</strong>
|
||||
<div class="alert">
|
||||
<strong>Bootstrap v2 má explicitní režimy.</strong>
|
||||
<ul>
|
||||
<li>Opravuje ownership /opt/appfactory.</li>
|
||||
<li>Nastavuje executable práva pro maintenance a alert skripty.</li>
|
||||
<li>Deployuje core services.</li>
|
||||
<li>Spouští preflight-check.sh.</li>
|
||||
<li><strong>check</strong> bezpečně ověřuje stav bez oprav.</li>
|
||||
<li><strong>repair</strong> opravuje ownership /opt/appfactory a nastavuje executable práva pro maintenance a alert skripty.</li>
|
||||
<li><strong>deploy</strong> provádí plný bootstrap včetně deploy core services a spuštění preflight-check.sh.</li>
|
||||
</ul>
|
||||
<p>Portál bootstrap nespouští přímo přes shell. Pouze založí maintenance job pro {html.escape(BOOTSTRAP_SCRIPT)}.</p>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<strong>Plný Bootstrap Deploy není výchozí akce.</strong>
|
||||
<p>Režim deploy deployuje core services a může změnit stav systému. Spouštějte ho jen po kontrole dopadu.</p>
|
||||
<form method="post" action="/portal/migration-readiness/bootstrap" onsubmit="return confirm('Spustit plný Bootstrap v2 deploy? Tato akce deployuje core services přes maintenance job.');">
|
||||
<input type="hidden" name="mode" value="deploy">
|
||||
<button type="submit" class="danger">Run Bootstrap Deploy</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card {"stat-success" if summary["ready"] else "stat-danger"}"><span>Stav</span><strong>{render_readiness_pill(summary["ready"])}</strong></div>
|
||||
<div class="stat-card stat-success"><span>OK</span><strong>{html.escape(str(summary["ok_count"]))}</strong></div>
|
||||
@@ -163,12 +177,21 @@ def run_migration_readiness(user=Depends(require_user)):
|
||||
|
||||
|
||||
@router.post("/migration-readiness/bootstrap")
|
||||
def run_bootstrap_v2(user=Depends(require_user)):
|
||||
def run_bootstrap_v2(mode: str = Form(...), user=Depends(require_user)):
|
||||
mode = (mode or "").strip().lower()
|
||||
if mode not in BOOTSTRAP_MODES:
|
||||
raise HTTPException(status_code=400, detail="Neplatný režim bootstrapu")
|
||||
|
||||
job_id = create_job(
|
||||
job_type="run_script",
|
||||
target_type="maintenance_script",
|
||||
target_id=BOOTSTRAP_SCRIPT,
|
||||
payload={"script_name": BOOTSTRAP_SCRIPT},
|
||||
payload={
|
||||
"script_name": BOOTSTRAP_SCRIPT,
|
||||
"args": [mode],
|
||||
"arguments": [mode],
|
||||
"mode": mode,
|
||||
},
|
||||
user=user,
|
||||
source="portal_manual",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user