Skip to content

Feature/check redfish modules - #552

Merged
semx merged 1 commit into
bb-Ricardo:feature/check-redfish-modulesfrom
marcinpsk:feature/check-redfish-modules-upstream
Sep 9, 2026
Merged

semx merged 1 commit into
bb-Ricardo:feature/check-redfish-modulesfrom
marcinpsk:feature/check-redfish-modules-upstream

Conversation

@marcinpsk

Copy link
Copy Markdown

Closes #473

Why

NetBox deprecated inventory items in 4.3. Modules carry a type from a catalog, live in a named bay, and own their interfaces and power ports, so the hardware a server reports can be modelled.

What

New option model_components_as_modules, bool, default false

When it is set and NetBox is 4.3 or newer, every component check_redfish reports becomes a module in a module bay, typed by a module type. On older NetBox the option is ignored and inventory items are used - single configuration fits both.

update_all_items() dispatches to update_all_modules(). The inventory item path is untouched, both sit side by side.

Object model

NBModuleType, NBModuleBay and NBModule, all gated on min_netbox_version = "4.3". A module has no name of its own, so NBModule is keyed on its bay and derives its display name from it. NBInterface and NBPowerPort gain a module foreign key, and NBModule becomes a valid custom field target.

Points to review:

The bay is the physical slot, keyed on something stable. Never on a name of component itself: the CPU socket, the DIMM slot label, the drive slot, the NIC adapter id, the PSU slot. A part swap then reuses the bay and re-points the module type, instead of leaving the old bay behind and creating a second one.

Long slot names. A slot longer than the 64 characters NetBox stores is shortened to a prefix plus a digest of the full name, so two long slots sharing a prefix stay distinct bays rather than collapsing onto one.

Bay matching is strict. update_module() never moves a module between bays, so an unmatched current module is a removed component: marked absent and kept registered with this source, never a target to remap another component onto. The inventory item path's alphabetical fallback would silently move data between slots here.

Manufacturer. NetBox requires one on a module type. Taken from redfish, then from an existing module type for the same model so a curated value is not clobbered, then from the device vendor.

Component links and cascade deletes. NIC ports and the BMC interface are attached to their parent module, PSU power ports to their supply module. NetBox cascade-deletes module components, so these links are cleared again when the option is turned off or no parent module resolves. Without that, a module prune could remove a port this source still manages.

Interface naming. With modules on, a NIC port is named by its stable redfish id (NIC.Integrated.1-1) and the long descriptive label moves to the description. Note overwrite_interface_name defaults to false, so existing interfaces keep their current names unless that is enabled once.

NetBox deprecated inventory items in 4.3 and points at modules as the replacement
(bb-Ricardo/netbox-sync issue 473). Modules carry a type from a catalog, live in a
named bay, and own their interfaces and power ports, so the hardware a server
reports can be modelled as what it is rather than as free text.

New option model_components_as_modules, default False, so nothing changes unless it
is set. When it is set and NetBox is 4.3 or newer, every component check_redfish
reports (CPU, DIMM, drive, controller, enclosure, NIC, PSU, fan, BMC) becomes a
module in a module bay, typed by a module type. On an older NetBox the option is
ignored and inventory items are used, so one configuration works across versions.

update_all_items() dispatches to update_all_modules() and the inventory item path is
untouched, which keeps the two backends side by side rather than replacing one.

Object model: NBModuleType, NBModuleBay and NBModule, all gated on NetBox 4.3.
NBModule has no name of its own, so it is keyed on its bay and derives its display
name from it. NBInterface and NBPowerPort gain a module foreign key, and NBModule
becomes a valid custom field target.

The bay is the physical slot and is keyed on a stable identifier, never on a name
carrying the installed part: the CPU socket, the DIMM slot label, the drive slot,
the NIC adapter id, the PSU slot. A part swap then reuses the bay and re-points the
module type instead of creating a second bay. A slot longer than the 64 characters
NetBox stores is shortened to a prefix plus a digest of the full name, so two long
slots sharing a prefix do not collapse onto one bay.

Bay matching is strict. update_module() never moves a module between bays, so an
unmatched current module is a removed component, marked absent and kept registered
with this source, not a target to remap another component onto.

NetBox requires a manufacturer on a module type. It is taken from redfish, then from
an existing module type for the same model so a curated value is not clobbered, then
from the device vendor.

NIC ports and the BMC interface are attached to their parent module, and PSU power
ports to their supply module. NetBox cascade-deletes module components, so those
links are cleared again when the option is turned off or no parent module resolves,
which stops a module prune removing a port this source still manages. With modules
on, a NIC port is named by its stable redfish id and the long descriptive label
moves to the description.

settings-example.ini is regenerated with netbox-sync.py -g rather than hand edited.

The tests drive the real CheckRedfish methods against the real inventory: the
version and option matrix, the full module graph, idempotency, module type reuse and
re-pointing, bay stability across part swaps, prefix-colliding long names, strict bay
matching, absent components, interface and power port links in both directions, and
the inventory item path still being used when the option is off.
@marcinpsk marcinpsk changed the title Feature/check redfish modules upstream Feature/check redfish modules Sep 9, 2026
@semx

semx commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Verified on top of development: default-off (model_components_as_modules = False), gated on NetBox >= 4.3, and the suite passes with it. #546, #550 and #551 are merged now; since #551 added its option at the same spot, this branch conflicts on module/sources/check_redfish/config.py and settings-example.ini (adjacent inserts only). Could you rebase on current development? I'll merge right after.

@semx
semx changed the base branch from development to feature/check-redfish-modules September 9, 2026 22:59
@semx
semx merged commit 947747c into bb-Ricardo:feature/check-redfish-modules Sep 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants