Skip to content

Feature/dell serial from service tag - #551

Merged
semx merged 2 commits into
bb-Ricardo:developmentfrom
marcinpsk:feature/dell-serial-from-service-tag
Sep 9, 2026
Merged

Feature/dell serial from service tag#551
semx merged 2 commits into
bb-Ricardo:developmentfrom
marcinpsk:feature/dell-serial-from-service-tag

Conversation

@marcinpsk

Copy link
Copy Markdown

Problem

Dell iDRAC reports the system board PPID (e.g. CNEXAMPLE00001) as ComputerSystem.SerialNumber, so the device serial written to NetBox is the PPID.

The Service Tag (e.g. ABC1234) is what dmidecode -s system-serial-number reports, what the OS and most fleet tooling use to identify the box, and what the iDRAC host name is built from. It was only stored in the service_tag custom field, so NetBox disagreed with every other system about the machine's serial.

Fix

New option dell_serial_from_service_tag, bool, default false, so behaviour is unchanged unless it is set.

When it is set, and the device is a Dell reporting a chassis SKU, the device serial becomes the Service Tag and the PPID moves to a new system_serial custom field. Without a usable SKU the serial stays the system serial, so nothing is lost.

Supporting changes

Device matching is extracted from apply() into find_device_object() and now also matches by Service Tag. The order is meta.inventory_id, then system serial, then Service Tag.

The Service Tag lookup is deliberately not gated on the option. A device persisted with the Service Tag as its serial would otherwise be stranded and silently skipped (continue) if the option were later disabled. get_service_tag() self-gates on the vendor and centralises the lookup, so matching and updating cannot disagree about the value.

Also:

  • The serial lookup did not normalise the value the way update_device() stores it (via get_string_or_none), so a padded serial never matched the stored one.
  • A missing serial probed get_by_data(NBDevice, {"serial": None}). That compares dicts exactly, so it matched a device which has no serial at all.

An absent meta.inventory_id is the normal case when devices are matched by serial, so it no longer logs a misleading "must be an integer" warning for it, and no longer probes get_by_id() with an invalid id.

Generated file

settings-example.ini is regenerated with netbox-sync.py -g

Both check_redfish test modules carried their own copy of the same setup: reset the
inventory singleton, build a CheckRedfish through object.__new__, run the real
add_necessary_base_objects(), and add a device to hang components off. Two more copies
were about to arrive with the interface IP and device serial tests.

conftest.py gains a check_redfish_source fixture which returns a builder. It reuses the
existing inventory fixture instead of resetting the singleton again, so the reset lives
in one place, and it takes the source settings as keyword arguments because each entry
point of the source reads a different subset of them. It returns the source, the
inventory and the device as a namespace.

The primary tag is now always registered. Only the orphan tagging tests needed it, but
the NetBox handler registers it in production regardless, so making it unconditional
brings the fixture closer to a real run rather than further from it.

No test assertion changed. Reverting either of the two fixes these modules cover still
fails them, so the shared setup does not weaken what they check.
Dell iDRAC reports the system board PPID (e.g. CNEXAMPLE00001) as
ComputerSystem.SerialNumber, so the device serial written to NetBox was the PPID.
The Service Tag (e.g. ABC1234) is what dmidecode reports as the system serial
number, what the OS and most fleet tooling use to identify the box, and what the
iDRAC host name is built from. It was only stored in the 'service_tag' custom
field, so NetBox disagreed with every other system about the machine's serial.

New option dell_serial_from_service_tag, default False, so behaviour is unchanged
unless it is set. When it is set, and the device is a Dell reporting a chassis SKU,
the device serial becomes the Service Tag and the PPID moves to a new
'system_serial' custom field. Without a usable SKU the serial stays the system
serial, so nothing is lost.

Three supporting changes:

Device matching is extracted from apply() into find_device_object(), which now also
matches by Service Tag. The order is meta.inventory_id, then system serial, then
Service Tag. The Service Tag lookup is not gated on the option: a device persisted
with the Service Tag as its serial would otherwise be stranded and silently skipped
if the option were later disabled. get_service_tag() centralises the lookup so
matching and updating cannot disagree.

The serial lookup normalises the value the same way update_device() stores it, so a
padded serial still matches, and it is skipped entirely when there is no serial.
get_by_data() compares dicts exactly, so probing serial=None matched a device which
has no serial at all.

meta.inventory_id is validated before it is used. int() accepted values which are not
NetBox ids and silently mapped them onto a real device: bool is a subclass of int, so
`true` became id 1, and float truncates, so `1.9` also became id 1. Zero and negative
values were passed through as well. Only a positive integer, or a string holding one,
is used now. An absent id remains the normal case and is not warned about.

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

The tests drive the real update_device() and find_device_object() against real
NBDevice objects. Twelve of the sixteen fail before this change.
@marcinpsk
marcinpsk force-pushed the feature/dell-serial-from-service-tag branch from d4f3171 to c710d0e Compare September 9, 2026 17:06
@semx
semx merged commit 254a914 into bb-Ricardo:development Sep 9, 2026
1 check passed
@marcinpsk
marcinpsk deleted the feature/dell-serial-from-service-tag branch September 10, 2026 06:05
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