refactor(devices): store hardware identity as hw_family / hw_revision
The firmware moved its NVS identity keys from hw_type / hw_version to
hw_family / hw_revision (NvsMigration.cpp), and the NVS generator, cloudflash
and the device models already used the new names. Firestore device docs and
the manufacturing code still wrote and read hw_type / hw_version, so the
device API's hw_family / hw_revision were always "" (0 of 14 docs had them)
and the console used two names for one value.
Device docs now use the firmware's names (schema v1.1.0, decision D2 in the
bellsystems-schema repo). The apps don't read these fields, so no app change.
- Manufacturing batch-create writes hw_family / hw_revision; the inventory
API exposes hw_family / hw_revision (filters: ?hw_family= / ?hw_families=).
Reads fall back to hw_type / hw_version so docs not yet migrated still work.
- devices/firestore_v1.py renames hw_type / hw_version on read and write and
rejects a hw_family that isn't a code (e.g. "Bell Plus"): when the console
generates NVS from it, the firmware builds its OTA URL from that value.
- Inventory, provisioning, onboarding and overview pages use the new names.
Unchanged on purpose: the firmware catalog and flash assets
(/api/firmware/{hw_type}/..., hw_type_override) — a separate store and the
URL devices call; same values, only the variable name differs. The public
cloudflash response keeps its hw_type field (public contract).
Data migration (rename + fix 3 display-label values) runs from the
bellsystems-schema repo AFTER this is deployed: the currently deployed
console still reads hw_type.
Verified: 118 backend tests pass; frontend builds; ESLint errors in
ProvisioningWizard.jsx (7) are pre-existing and unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,18 @@ def test_v1_key_wins_over_legacy_duplicate():
|
||||
assert attrs["networkSettings"] == {"usesStaticIP": True}
|
||||
|
||||
|
||||
def test_legacy_hw_names_become_firmware_names():
|
||||
out = v1.to_firestore({"hw_type": "vesper_plus", "hw_version": "1.0"})
|
||||
assert out == {"hw_family": "vesper_plus", "hw_revision": "1.0"}
|
||||
assert v1.to_api({"hw_type": "agnus", "hw_version": "1.0"}) == {"hw_family": "agnus", "hw_revision": "1.0"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("label", ["Bell Plus", "Bell Core", "vesper plus"])
|
||||
def test_hw_family_display_labels_are_rejected(label):
|
||||
with pytest.raises(ValidationError):
|
||||
v1.to_firestore({"hw_family": label})
|
||||
|
||||
|
||||
def test_retired_users_list_is_dropped():
|
||||
assert "users_list" not in v1.to_firestore({"users_list": [], "device_name": "x"})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user