fix: stops structured values being stringified into component names - #544
Conversation
get_string_or_none() is the shared parser for every name and label the check_redfish
source builds. It str()-ed whatever it was given, so a value that is not a string
was turned into its Python repr and concatenated into the name.
Dell iDRAC returns the `location` of a storage enclosure, storage controller or
physical drive as a nested Oem object rather than a string:
{'Oem': {'Dell': {'@odata.type': '#DellLocation.v1_2_0.DellLocation', ...}}}
The inventory item was then named "BP_PSV 0:1 {'Oem': {'Dell': {'@odata.type': '#Del",
NetBox storing the first 64 characters of it. The name is unreadable and the location
it was meant to carry is lost.
get_string_or_none() now returns None for dict/list/set/tuple, so an unusable value is
dropped instead of being pasted into the name. Scalars are untouched: the helper has
many callers which pass ints (core counts, slot numbers, port counts) and rely on them
stringifying.
On the inventory item path this is a data quality problem rather than a churn problem:
the alphabetical fallback in update_all_items() still matches the item, so it is not
duplicated, the name is simply unusable.
Tests cover the helper contract and drive the real update_storage_enclosure(), including
a plain string location, which must still be kept, and two enclosures, which must not be
merged onto one name once the unusable location is dropped.
|
Merged, thanks. Confirmed the |
|
Do you have an example redfish inventory where a Dell server returns the location as an object/dict? |
|
Traced it through both projects. In Redfish,
So the guard is right for the older producer and harmless otherwise, but the durable fix is on the check_redfish side: map |
Hi @bb-Ricardo I would agree that it would be better suited not here most likely |
get_string_or_none() is the shared parser for every name and label the check_redfish source builds. It str()-ed whatever it was given, so a value that is not a string was turned into its Python repr and concatenated into the name.
Dell iDRAC returns the
locationof a storage enclosure, storage controller or physical drive as a nested Oem object rather than a string:The inventory item was then named
NetBox storing the first 64 characters of it. The name is unreadable and the location it was meant to carry is lost.
get_string_or_none() now returns None for dict/list/set/tuple, so an unusable value is dropped instead of being pasted into the name. Scalars are untouched: the helper has many callers which pass ints (core counts, slot numbers, port counts) and rely on them stringifying.
added [tool.pytest.ini_options] to pyproject.toml, same as in #541 so it can drop when that merges. make_source() helper can move to conftest as well at that point.