Files
pxe-server/webapp/views/__init__.py
cproudlock 397063f987 Webapp: Updates pages, image page tabs with review-before-save, BPRT sync
Updates group:
- Dell drivers and BIOS: check Dell's catalogs against all three driver maps
  and models.txt, download with a shared speed cap, repack, preview, apply
  with backups and rollback.
- iPXE boot files: check GitHub for the signed Secure Boot set, verify the
  sha256 and each file's signer, install atomically, roll back. Includes the
  by-hand procedure.
- Blancco: upload a release, stage it, test-boot it from the menu, activate,
  roll back.
- BPRT sync: validate a batch uploaded from the MediaCreator Lite cache
  (scripts/windows/Sync-BPRT.ps1 or a zip), show the diff, swap with the site
  overlay files kept.

Images: one sidebar entry per image with Overview, Drivers, Unattend and OS and
Packages tabs. Every save shows a diff first, keeps the file's format, makes a
backup and can be undone. Driver lint runs inline.

Enrollment: upload standard/engineer MCL packages, one per tenant/purpose,
with archive and restore. Hardware coverage counts engineer as Win11.
2026-10-13 16:58:55 -04:00

38 lines
1.5 KiB
Python

"""Feature blueprints registered by app.py (one module per page group).
views.dell_updates - Updates > Dell drivers and BIOS
views.ipxe - Updates > iPXE Secure Boot files
views.blancco_update - Updates > Blancco Drive Eraser releases
Shared here: the download speed cap form handler. The cap is one setting
(services/updates_common.py settings.json) used by every download; each
Updates page with downloads shows the same form and posts it to its own
route, which calls save_speed_cap() and redirects back to that page.
"""
import math
from flask import flash, request
from services import updates_common
from services.audit import audit
def save_speed_cap():
"""Validate and save the shared speed cap from the posted form, audit and
flash the result. Returns the saved settings, or None when refused."""
try:
value = float(request.form.get("max_mbps", ""))
if not math.isfinite(value): # float() accepts "nan"
raise ValueError("not a number")
data = updates_common.save_settings(value)
except ValueError as ex:
msg = str(ex) if "between" in str(ex) else "enter a number of MB/s (0 = no cap)"
flash(f"Speed cap not saved: {msg}", "danger")
return None
audit("UPDATES_SPEED_CAP", f"{data['max_mbps']} MB/s")
cap = data["max_mbps"]
flash(f"Download speed cap set to {cap:g} MB/s (shared by Dell and iPXE downloads)."
if cap else "Download speed cap removed (shared by Dell and iPXE downloads).", "success")
return data