Phase 1a of a multi-session refactor toward a clean blueprint
structure. Pulls the helper code that lived alongside the routes in
the 1621-line app.py into focused modules. app.py is now 625 lines
of mostly routes plus a small Flask wiring header. Behaviour is
unchanged: smoke-tested against the 8 main GET routes (200 OK).
New modules:
- config.py env vars + IMAGE_TYPES + FRIENDLY_NAMES +
SHARED_DEPLOY_* taxonomy + unattend XML
namespaces.
- services/audit.py audit log file handler + audit() helper.
- services/csrf.py session CSRF token + before_request validator
wired via init_csrf(app).
- services/fs.py image_root / deploy_path / unattend_path /
control_path / tools_path + load_json /
save_json + resolve_destination.
- services/system.py service_status / find_usb_mounts /
find_upload_sources.
- services/images.py image_status + load_image_config.
- services/deploy.py import_deploy + _merge_tree +
_replace_with_symlink + allowed_import_source.
- services/unattend.py parse_unattend / build_unattend_xml /
extract_form_data and the qn / qwcm / settings
pass helpers.
- services/wim.py extract_startnet / update_startnet / list_files
wrapping wimextract / wimupdate / wimdir.
Endpoint names kept stable (dashboard, clonezilla_backups, etc.) so
existing url_for(...) calls in templates are unchanged. Phase 1b
(Flask blueprints with ".endpoint" naming) deferred to a future
session because it requires updating ~30 url_for sites in templates
and is mostly cosmetic.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.5 KiB
Python
67 lines
2.5 KiB
Python
"""Configuration constants for the PXE webapp.
|
|
|
|
Reads from environment variables with sensible defaults that match the
|
|
Ansible playbook's deploy paths. Also defines the canonical image type
|
|
list and shared-directory taxonomy used by the import pipeline.
|
|
"""
|
|
|
|
import os
|
|
|
|
# --- Filesystem paths --------------------------------------------------------
|
|
SAMBA_SHARE = os.environ.get("SAMBA_SHARE", "/srv/samba/winpeapps")
|
|
CLONEZILLA_SHARE = os.environ.get("CLONEZILLA_SHARE", "/srv/samba/clonezilla")
|
|
BLANCCO_REPORTS = os.environ.get("BLANCCO_REPORTS", "/srv/samba/blancco-reports")
|
|
ENROLLMENT_SHARE = os.environ.get("ENROLLMENT_SHARE", "/srv/samba/enrollment")
|
|
UPLOAD_DIR = os.environ.get("UPLOAD_DIR", "/home/pxe/image-upload")
|
|
SHARED_DIR = os.path.join(SAMBA_SHARE, "_shared")
|
|
WEB_ROOT = os.environ.get("WEB_ROOT", "/var/www/html")
|
|
BOOT_WIM = os.path.join(WEB_ROOT, "win11", "sources", "boot.wim")
|
|
AUDIT_LOG = os.environ.get("AUDIT_LOG", "/var/log/pxe-webapp-audit.log")
|
|
|
|
# --- Flask -------------------------------------------------------------------
|
|
FLASK_SECRET_KEY = os.environ.get("FLASK_SECRET_KEY", "pxe-manager-dev-key-change-in-prod")
|
|
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 * 1024 # 16 GB max upload
|
|
|
|
# --- Image taxonomy ----------------------------------------------------------
|
|
# Subdirs inside Deploy/ shared across ALL image types.
|
|
SHARED_DEPLOY_GLOBAL = ["Out-of-box Drivers"]
|
|
|
|
# Subdirs inside Deploy/ shared within the same image family (by prefix).
|
|
SHARED_DEPLOY_SCOPED = {
|
|
"gea-": ["Operating Systems", "Packages"],
|
|
"ge-": ["Operating Systems", "Packages"],
|
|
}
|
|
|
|
# Sibling dirs at image root shared within the same image family.
|
|
SHARED_ROOT_DIRS = {
|
|
"gea-": ["Sources"],
|
|
"ge-": ["Sources"],
|
|
}
|
|
|
|
IMAGE_TYPES = [
|
|
"gea-standard",
|
|
"gea-engineer",
|
|
"gea-shopfloor",
|
|
"gea-shopfloor-mce",
|
|
"ge-standard",
|
|
"ge-engineer",
|
|
"ge-shopfloor-lockdown",
|
|
"ge-shopfloor-mce",
|
|
]
|
|
|
|
FRIENDLY_NAMES = {
|
|
"gea-standard": "GE Aerospace Standard",
|
|
"gea-engineer": "GE Aerospace Engineer",
|
|
"gea-shopfloor": "GE Aerospace Shop Floor",
|
|
"gea-shopfloor-mce": "GE Aerospace Shop Floor MCE",
|
|
"ge-standard": "GE Legacy Standard",
|
|
"ge-engineer": "GE Legacy Engineer",
|
|
"ge-shopfloor-lockdown": "GE Legacy Shop Floor Lockdown",
|
|
"ge-shopfloor-mce": "GE Legacy Shop Floor MCE",
|
|
}
|
|
|
|
# --- Unattend XML namespaces -------------------------------------------------
|
|
UNATTEND_NS = "urn:schemas-microsoft-com:unattend"
|
|
WCM_NS = "http://schemas.microsoft.com/WMIConfig/2002/State"
|
|
NSMAP = {None: UNATTEND_NS, "wcm": WCM_NS}
|