contract 0.18.0: one name per display role, the kiosk's own
Core called the roles dashboard / lobby / partskiosk. The kiosks call them Dashboard / Lobby / 3DPrintRoom, which are the literal contents of C:\Enrollment\display-type.txt, read by the GE-Enforce dispatcher to pick a target. Two vocabularies for three kiosks, each with its own copy of the same route map. That is not cosmetic. A display reporting its own type sends what its file says, so it could report a role core would not accept, and core could store 'partskiosk', a value no dispatcher would ever match. The enforcement report column would have shown one vocabulary from the device and the other from the DashboardDefault fallback, in the same column. The machine's file wins, because that is what a person edits. DISPLAY_ROLE_PATHS takes the kiosk spelling and the display scope now uses that dict rather than holding a second one, so the two cannot drift again. normalize_display_role resolves any casing and the retired 'partskiosk' forward; the dispatcher already matched its map case-insensitively and the server now agrees with it. Nothing is turned away over a capital: the API accepts any spelling and stores the canonical one, displaypath resolves through the normalizer so rows written before this keep working, and the settings dropdown canonicalises on open so an old value does not render as a blank select. A reported subtype is normalised on the way in, but an UNRECOGNISED one is kept verbatim. That is a kiosk with a typo in its file or a role nobody declared, and both are worth seeing in the fleet table rather than blanked or guessed at. Contract bumped for the added names. DashboardDefault is finally listed in __all__ too - 0.17.0 put it on the surface and never exported it.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"description": "GE-Enforce manifest store. Owns imaging PC-type scopes and their install manifests (apps, scripts, files, registry, version gates) as shopdb data, served to the GE-Enforce client as JSON. Requires GE-Enforce lib >= 2.6 on target PCs (the _CmmVersion gate).",
|
||||
"author": "ShopDB Team",
|
||||
"dependencies": [],
|
||||
"core_version": ">=0.7.0,<1.0.0",
|
||||
"core_version": ">=0.18.0,<1.0.0",
|
||||
"api_prefix": "/api/geenforce",
|
||||
"default_enabled": false,
|
||||
"provides": {
|
||||
|
||||
@@ -30,7 +30,7 @@ running replace_scope_draft is an idempotent draft rebuild.
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from shopdb.api import db
|
||||
from shopdb.api import db, DISPLAY_ROLE_PATHS
|
||||
|
||||
from . import service
|
||||
|
||||
@@ -47,17 +47,18 @@ RELAUNCH_WINDOW_JSON = (
|
||||
|
||||
# Data-driven display-type -> kiosk target map. The value of
|
||||
# C:\Enrollment\display-type.txt selects the row; the target is a route the
|
||||
# kiosk browser opens against the local kiosk base URL. Edit here to retarget a
|
||||
# subtype. Keys are matched case-insensitively by the dispatcher.
|
||||
# kiosk browser opens against the local kiosk base URL. Keys are matched
|
||||
# case-insensitively by the dispatcher.
|
||||
#
|
||||
# NOT a copy any more: this IS core's DISPLAY_ROLE_PATHS, read through the
|
||||
# contract surface. It used to be a second map with the same routes under
|
||||
# different names, which is how a display could report a role core could not
|
||||
# store. Retarget a subtype in shopdb/core/models/dashboarddefault.py.
|
||||
#
|
||||
# TODO-confirm: 3DPrintRoom points at the printedparts /parts-kiosk route as a
|
||||
# PLACEHOLDER. Confirm the real 3D-print-room kiosk target with the floor team
|
||||
# before this scope is published to production displays.
|
||||
DISPLAY_TYPE_TARGETS = {
|
||||
'Dashboard': '/shopfloor',
|
||||
'Lobby': '/tv',
|
||||
'3DPrintRoom': '/parts-kiosk',
|
||||
}
|
||||
DISPLAY_TYPE_TARGETS = DISPLAY_ROLE_PATHS
|
||||
|
||||
DISPATCHER_FILENAME = 'Invoke-DisplayKioskDispatch.ps1'
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ from datetime import datetime, timezone
|
||||
from flask import current_app
|
||||
from sqlalchemy import func
|
||||
|
||||
from shopdb.api import db, Application
|
||||
from shopdb.api import db, Application, normalize_display_role
|
||||
|
||||
from .models import (
|
||||
ManifestScope, ManifestPublishedVersion, ManifestEnforcementReport,
|
||||
@@ -49,6 +49,25 @@ class LibVersionTooOldError(Exception):
|
||||
'if you are certain those PCs must not receive this scope.')
|
||||
|
||||
|
||||
def _canonical_subtype(value):
|
||||
"""Store a reported subtype under core's role vocabulary where it names one.
|
||||
|
||||
A display reports the literal contents of C:\\Enrollment\\display-type.txt,
|
||||
hand-edited on the machine, so casing drifts freely. Normalising on the way
|
||||
in means the fleet table reads one vocabulary rather than whatever each
|
||||
kiosk happened to be typed as.
|
||||
|
||||
A value that names NO known role is kept VERBATIM, not dropped: an unknown
|
||||
subtype is a kiosk with a typo or a role nobody told the server about, and
|
||||
both are things you want to see in the table rather than have silently
|
||||
blanked. Non-display scopes report no subtype at all and land as None.
|
||||
"""
|
||||
text = (value or '').strip()
|
||||
if not text:
|
||||
return None
|
||||
return normalize_display_role(text) or text
|
||||
|
||||
|
||||
def _utcnow():
|
||||
return datetime.now(timezone.utc).replace(tzinfo=None)
|
||||
|
||||
@@ -263,7 +282,7 @@ def record_enforcement_report(payload):
|
||||
phase=phase,
|
||||
appliedversion=payload.get('appliedversion'),
|
||||
enforcerversion=payload.get('enforcerversion'),
|
||||
subtype=(payload.get('subtype') or None),
|
||||
subtype=_canonical_subtype(payload.get('subtype')),
|
||||
installedcount=installed,
|
||||
skippedcount=int(counts.get('skipped', 0)),
|
||||
failedcount=failed,
|
||||
|
||||
Reference in New Issue
Block a user