Expand lab seed tiers, OpenAPI PARAMS, and console DATA/Params UX.

This commit is contained in:
2026-07-18 08:46:39 +03:00
parent f8d3cbdd59
commit 63cc409424
71 changed files with 38380 additions and 796 deletions
+39 -8
View File
@@ -229,12 +229,25 @@ async def ui_demo_state(request: Request) -> JSONResponse:
raise HTTPException(status_code=503, detail=str(error)) from error
async with pool.acquire() as connection:
pve = await simulation_state_summary(connection)
return JSONResponse({"vsphere": vsphere, "proxmox_stub": pve})
profile = vsphere.get("profile_hint") or "minimal"
loaded = profile in {"small", "large", "big", "demo-cluster", "demo", "enterprise"}
return JSONResponse(
{
"vsphere": vsphere,
"proxmox_stub": pve,
"loaded": loaded,
"label": f"{vsphere.get('hosts', 0)} hosts · {vsphere.get('vms', 0)} VMs",
"profile": profile,
}
)
profile = vsphere.get("profile_hint") or "minimal"
loaded = profile in {"small", "large", "big", "demo-cluster", "demo", "enterprise"}
return JSONResponse(
{
"vsphere": vsphere,
"loaded": vsphere.get("vms", 0) >= 100,
"loaded": loaded,
"label": f"{vsphere.get('hosts', 0)} hosts · {vsphere.get('vms', 0)} VMs",
"profile": profile,
}
)
@@ -245,17 +258,35 @@ async def ui_demo_load(request: Request) -> JSONResponse:
settings = _settings(request)
summary: dict = {}
profile_name = "demo-cluster"
size_raw = request.query_params.get("size") or request.query_params.get("profile")
if not size_raw:
try:
body = await request.json()
except Exception:
body = {}
if isinstance(body, dict):
size_raw = body.get("size") or body.get("profile")
profile_name = str(size_raw or "large").strip().lower() or "large"
if profile_name in {"demo-cluster", "demo", "enterprise"}:
profile_name = "big"
if profile_name not in {"small", "large", "big"}:
raise HTTPException(
status_code=400,
detail=f"unknown size {profile_name!r}; sizes: small, large, big",
)
if settings is not None and getattr(settings, "enable_pve_stub", False):
pool = _database_pool(request)
profile = build_profile("demo-cluster")
pve_name = "demo-cluster" if profile_name == "big" else profile_name
try:
profile = build_profile(pve_name)
except Exception:
profile = build_profile("demo-cluster")
async with pool.acquire() as connection:
await apply_seed(connection, profile)
summary = await simulation_state_summary(connection)
profile_name = profile.name
try:
vsphere = await seed_vsphere_inventory(
get_database(request), force=True, profile="demo-cluster"
get_database(request), force=True, profile=profile_name
)
except Exception as error:
raise HTTPException(status_code=503, detail=f"database is not ready: {error}") from error
@@ -271,7 +302,7 @@ async def ui_demo_unload(request: Request) -> JSONResponse:
settings = _settings(request)
summary: dict = {}
profile_name = "small"
profile_name = "minimal"
try:
if settings is not None and getattr(settings, "enable_pve_stub", False):
pool = _database_pool(request)
@@ -280,7 +311,7 @@ async def ui_demo_unload(request: Request) -> JSONResponse:
await apply_seed(connection, profile)
summary = await simulation_state_summary(connection)
profile_name = profile.name
vsphere = await seed_vsphere_inventory(get_database(request), force=True, profile="small")
vsphere = await seed_vsphere_inventory(get_database(request), force=True, profile="minimal")
except HTTPException:
raise
except Exception as error: