Feature/dell serial from service tag - #551
Merged
semx merged 2 commits intoSep 9, 2026
Merged
Conversation
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
force-pushed
the
feature/dell-serial-from-service-tag
branch
from
September 9, 2026 17:06
d4f3171 to
c710d0e
Compare
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Dell iDRAC reports the system board PPID (e.g.
CNEXAMPLE00001) asComputerSystem.SerialNumber, so the device serial written to NetBox is the PPID.The Service Tag (e.g.
ABC1234) is whatdmidecode -s system-serial-numberreports, 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 theservice_tagcustom field, so NetBox disagreed with every other system about the machine's serial.Fix
New option
dell_serial_from_service_tag, bool, defaultfalse, 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_serialcustom field. Without a usable SKU the serial stays the system serial, so nothing is lost.Supporting changes
Device matching is extracted from
apply()intofind_device_object()and now also matches by Service Tag. The order ismeta.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:
update_device()stores it (viaget_string_or_none), so a padded serial never matched the stored one.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_idis 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 probesget_by_id()with an invalid id.Generated file
settings-example.iniis regenerated withnetbox-sync.py -g