raid: parse storcli64/storcli2's actual per-slot drive JSON shape
RAID Controller Management showed "No drives detected" for a live
SAS3808-iMR controller even though storcli64 clearly enumerates its
drives. Root cause: the "eall/sall show all J" drive-listing parser
(collector/raid.go and its webui/raid_mgmt.go duplicate) assumed
drives are reported as a single "Drive Information" array, but real
storcli64/storcli2 output nests each drive under its own dynamically
named key ("Drive /c0/e69/s0", paired with a "... - Detailed
Information" key) — confirmed against a live techdump/storcli64-drives.json
capture. The assumed shape was never actually produced by the tool, so
this affected every storcli64/storcli2 controller, not just Tri-Mode
ones (the storcli2 fallback added in b7f015c never got a chance to
mask it in practice, since storcli2 itself reports zero controllers on
this hardware — a separate, unrelated tool-side gap).
Both parsers now read "Response Data" as a raw key map and pull drives
from either shape, so older storcli output using the array form still
works alongside the real per-slot form.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
2d84ddb577
commit
4e306ff78c
@@ -47,3 +47,38 @@ func TestParseStorcli2DriveInformationEmptyOrMalformed(t *testing.T) {
|
||||
t.Fatalf("empty Controllers should return nil, got %#v", all)
|
||||
}
|
||||
}
|
||||
|
||||
// TestParseStorcliResponseDataDrivesPerSlotKeys regression-tests against a
|
||||
// live SAS3808-iMR "storcli64 /call/eall/sall show all J" dump: "Response
|
||||
// Data" has no "Drive Information" array at all, only per-slot keys like
|
||||
// "Drive /c0/e69/s0" (plus a paired "... - Detailed Information" key that
|
||||
// must be skipped). This is what made "RAID Controller Management" show
|
||||
// "No drives detected" for a controller storcli64 could clearly see.
|
||||
func TestParseStorcliResponseDataDrivesPerSlotKeys(t *testing.T) {
|
||||
raw := []byte(`{
|
||||
"Controllers": [
|
||||
{
|
||||
"Command Status": {"Status": "Success"},
|
||||
"Response Data": {
|
||||
"Drive /c0/e69/s0": [
|
||||
{"EID:Slt": "69:0", "State": "JBOD", "Size": "447.130 GB", "Model": "SAMSUNG MZ7L3480HCHQ-00B7C"}
|
||||
],
|
||||
"Drive /c0/e69/s0 - Detailed Information": {
|
||||
"Drive /c0/e69/s0 State": {"Shield Counter": 0}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}`)
|
||||
|
||||
all, _, free := parseStorcli2DriveInformation(raw)
|
||||
if len(all) != 1 {
|
||||
t.Fatalf("all=%d want 1 (%#v)", len(all), all)
|
||||
}
|
||||
if all[0].Model != "SAMSUNG MZ7L3480HCHQ-00B7C" || all[0].Slot != "69:0" {
|
||||
t.Fatalf("all[0]=%#v want model/slot populated", all[0])
|
||||
}
|
||||
if len(free) != 1 {
|
||||
t.Fatalf("free=%d want 1 (JBOD is a free drive)", len(free))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user