fix(redfish): support composed G894 inventory
This commit is contained in:
1 parent
ab53914d0a
commit
3ac19f37b8
6 files changed
+536
-12
No files matched your search
@@ -77,6 +77,10 @@ Deduplication priority:
|
||||
| 2 | `bdf` |
|
||||
| 3 | keep records separate |
|
||||
|
||||
A serial repeated across records with different canonical BDFs is not usable as a deduplication
|
||||
identity for those records; preserve the distinct devices and retain the reported serial as source
|
||||
data.
|
||||
|
||||
## Raw payloads
|
||||
|
||||
`raw_payloads` is authoritative for replayable sources.
|
||||
|
||||
@@ -136,6 +136,16 @@ snapshot-aware vendor decisions should live in profile analysis hooks, not in `r
|
||||
GPU and storage replay executors should consume the resolved analysis plan directly, not a raw
|
||||
`AnalysisDirectives` struct, so the boundary between planning and execution stays explicit.
|
||||
|
||||
Multi-system platforms must not treat the first `Systems.Members` entry as the host. Live probe,
|
||||
discovery, and replay select the host system from structural signals (CPU inventory,
|
||||
`ProcessorSummary`, BIOS, boot data, and the conventional `Self` identifier). Replay uses that host
|
||||
for board/BIOS identity, while CPU, memory, storage, volumes, and storage controllers are aggregated
|
||||
across all system members. This preserves both server inventory and composed accelerator inventory
|
||||
such as `Systems/HGX_Baseboard_0`. Chassis linked from a system are included even when the BMC omits
|
||||
them from the top-level `Chassis` collection. Standard Redfish `Chassis/*/Sensors` collections are
|
||||
replayed alongside legacy threshold/thermal/power sources. Server PSUs prefer the host system's
|
||||
linked chassis, falling back to all chassis only when that source is empty.
|
||||
|
||||
Profile matching and acquisition tuning must be regression-tested against repo-owned compact
|
||||
fixtures under `internal/collector/redfishprofile/testdata/`, derived from representative
|
||||
raw-export snapshots, for at least MSI and Supermicro shapes.
|
||||
|
||||
@@ -2150,3 +2150,31 @@ not modified.
|
||||
- The component's transition timeline is read from Event Logs filtered by
|
||||
`component_ref`.
|
||||
- `status`, `status_changed_at`, and `error_description` stay in the tables.
|
||||
|
||||
---
|
||||
|
||||
## ADL-074 — Multi-system Redfish replay separates host identity from composed inventory
|
||||
|
||||
**Date:** 2026-09-28
|
||||
**Context:** GIGABYTE G894-SD3-AAX7 exposes `Systems/HGX_Baseboard_0` before
|
||||
`Systems/Self`. The former describes the NVIDIA HGX accelerator subsystem; the latter contains
|
||||
the server's Xeon CPUs, DDR5 DIMMs, NVMe storage, BIOS, and OEM identity. Treating the first
|
||||
collection member as the server produced zero CPUs/storage and hid the host memory.
|
||||
|
||||
**Decision:** Live probe, discovery, and replay select the host system from structural host signals
|
||||
rather than collection order. Board, BIOS, and server-level identity come from that selected host.
|
||||
CPU, memory, storage, volumes, and storage controllers are aggregated across every discovered
|
||||
system member and deduplicated where the model has a stable identity. System-linked chassis are
|
||||
added even when absent from the top-level chassis collection. Standard `Chassis/*/Sensors`
|
||||
resources are parsed in addition to legacy sensor paths, and network-controller model signals take
|
||||
precedence over generic NVIDIA GPU hints. Host-linked chassis are preferred for server PSUs. When
|
||||
a BMC repeats one NIC serial across different canonical BDFs, the BDF conflict makes that serial
|
||||
unusable for deduplication and the physical functions remain distinct. Canonical BDFs may be
|
||||
recovered from AMI PCIeFunction IDs shaped as `domain_bus_device_function` when explicit BDF fields
|
||||
are absent.
|
||||
|
||||
**Consequences:**
|
||||
- Composed systems retain both host and accelerator inventory.
|
||||
- `Systems.Members` ordering no longer changes normalized results.
|
||||
- Existing single-system snapshots keep their previous behavior.
|
||||
- Replay remains deterministic and the existing raw export can be re-analyzed without recollection.
|
||||
@@ -105,7 +105,7 @@ func (c *RedfishConnector) Probe(ctx context.Context, req Request) (*ProbeResult
|
||||
return nil, fmt.Errorf("redfish service root: %w", err)
|
||||
}
|
||||
systemPaths := c.discoverMemberPaths(ctx, client, req, baseURL, "/redfish/v1/Systems", "/redfish/v1/Systems/1")
|
||||
primarySystem := firstNonEmptyPath(systemPaths, "/redfish/v1/Systems/1")
|
||||
primarySystem := c.selectHostSystemPath(ctx, client, req, baseURL, systemPaths, "/redfish/v1/Systems/1")
|
||||
systemDoc, err := c.getJSON(ctx, client, req, baseURL, primarySystem)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("redfish system: %w", err)
|
||||
@@ -158,8 +158,9 @@ func (c *RedfishConnector) Collect(ctx context.Context, req Request, emit Progre
|
||||
}
|
||||
|
||||
systemPaths := c.discoverMemberPaths(discoveryCtx, snapshotClient, req, baseURL, "/redfish/v1/Systems", "/redfish/v1/Systems/1")
|
||||
primarySystem := firstNonEmptyPath(systemPaths, "/redfish/v1/Systems/1")
|
||||
primarySystem := c.selectHostSystemPath(discoveryCtx, snapshotClient, req, baseURL, systemPaths, "/redfish/v1/Systems/1")
|
||||
chassisPaths := c.discoverMemberPaths(discoveryCtx, snapshotClient, req, baseURL, "/redfish/v1/Chassis", "/redfish/v1/Chassis/1")
|
||||
chassisPaths = c.appendSystemLinkedChassisPaths(discoveryCtx, snapshotClient, req, baseURL, systemPaths, chassisPaths)
|
||||
managerPaths := c.discoverMemberPaths(discoveryCtx, snapshotClient, req, baseURL, "/redfish/v1/Managers", "/redfish/v1/Managers/1")
|
||||
primaryChassis := firstNonEmptyPath(chassisPaths, "/redfish/v1/Chassis/1")
|
||||
primaryManager := firstNonEmptyPath(managerPaths, "/redfish/v1/Managers/1")
|
||||
@@ -516,6 +517,43 @@ func firstNonEmptyPath(paths []string, fallback string) string {
|
||||
return fallback
|
||||
}
|
||||
|
||||
func (c *RedfishConnector) selectHostSystemPath(ctx context.Context, client *http.Client, req Request, baseURL string, paths []string, fallback string) string {
|
||||
bestPath := ""
|
||||
bestScore := -1
|
||||
for _, path := range paths {
|
||||
path = strings.TrimSpace(path)
|
||||
if path == "" {
|
||||
continue
|
||||
}
|
||||
doc, err := c.getJSON(ctx, client, req, baseURL, path)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
processorDocs, _ := c.getCollectionMembers(ctx, client, req, baseURL, joinPath(path, "/Processors"))
|
||||
score := redfishHostSystemScore(path, doc, processorDocs)
|
||||
if score > bestScore {
|
||||
bestPath = path
|
||||
bestScore = score
|
||||
}
|
||||
}
|
||||
if bestPath != "" {
|
||||
return bestPath
|
||||
}
|
||||
return firstNonEmptyPath(paths, fallback)
|
||||
}
|
||||
|
||||
func (c *RedfishConnector) appendSystemLinkedChassisPaths(ctx context.Context, client *http.Client, req Request, baseURL string, systemPaths, chassisPaths []string) []string {
|
||||
out := append([]string{}, chassisPaths...)
|
||||
for _, systemPath := range systemPaths {
|
||||
doc, err := c.getJSON(ctx, client, req, baseURL, systemPath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
out = append(out, redfishLinkRefs(doc, "Links", "Chassis")...)
|
||||
}
|
||||
return dedupeRedfishPaths(out)
|
||||
}
|
||||
|
||||
func isRedfishHostPoweredOn(state string) bool {
|
||||
switch strings.ToLower(strings.TrimSpace(state)) {
|
||||
case "on", "poweringon":
|
||||
@@ -2488,6 +2526,28 @@ func sanitizeRedfishBDF(bdf string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func redfishBDFFromResourceID(id string) string {
|
||||
parts := strings.Split(strings.TrimSpace(id), "_")
|
||||
if len(parts) != 4 {
|
||||
return ""
|
||||
}
|
||||
values := make([]uint64, len(parts))
|
||||
for i, part := range parts {
|
||||
if part == "" {
|
||||
return ""
|
||||
}
|
||||
value, err := strconv.ParseUint(part, 16, 16)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
values[i] = value
|
||||
}
|
||||
if values[1] > 0xff || values[2] > 0x1f || values[3] > 7 {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%04x:%02x:%02x.%x", values[0], values[1], values[2], values[3])
|
||||
}
|
||||
|
||||
func shouldCrawlPath(path string) bool {
|
||||
if path == "" {
|
||||
return false
|
||||
@@ -3786,7 +3846,10 @@ func enrichNICFromPCIe(nic *models.NetworkAdapter, pcieDoc map[string]interface{
|
||||
}
|
||||
for _, fn := range functionDocs {
|
||||
if strings.TrimSpace(nic.BDF) == "" {
|
||||
nic.BDF = sanitizeRedfishBDF(asString(fn["FunctionId"]))
|
||||
nic.BDF = firstNonEmpty(
|
||||
sanitizeRedfishBDF(asString(fn["FunctionId"])),
|
||||
redfishBDFFromResourceID(asString(fn["Id"])),
|
||||
)
|
||||
}
|
||||
if nic.VendorID == 0 {
|
||||
nic.VendorID = asHexOrInt(fn["VendorId"])
|
||||
@@ -4891,6 +4954,14 @@ func shouldSkipGenericGPUDuplicate(existing []models.GPU, candidate models.GPU)
|
||||
if normalizeRedfishIdentityField(candidate.SerialNumber) != "" || strings.TrimSpace(candidate.BDF) != "" {
|
||||
return false
|
||||
}
|
||||
if candidate.VendorID != 0 || candidate.DeviceID != 0 {
|
||||
for _, gpu := range existing {
|
||||
if gpu.VendorID == candidate.VendorID && gpu.DeviceID == candidate.DeviceID &&
|
||||
(normalizeRedfishIdentityField(gpu.SerialNumber) != "" || strings.TrimSpace(gpu.BDF) != "") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
slot := strings.TrimSpace(candidate.Slot)
|
||||
model := strings.TrimSpace(candidate.Model)
|
||||
if slot == "" || model == "" {
|
||||
@@ -5130,6 +5201,11 @@ func looksLikeGPU(doc map[string]interface{}, functionDocs []map[string]interfac
|
||||
asString(doc["Model"]),
|
||||
asString(doc["Manufacturer"]),
|
||||
}, " "))
|
||||
for _, hint := range []string{"connectx", "network controller", "ethernet", "infiniband", "supernic", "aspeed graphics"} {
|
||||
if strings.Contains(modelText, hint) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
gpuHints := []string{"gpu", "nvidia", "tesla", "a100", "h100", "l40", "rtx", "radeon", "instinct"}
|
||||
for _, hint := range gpuHints {
|
||||
if strings.Contains(modelText, hint) {
|
||||
@@ -5531,7 +5607,11 @@ func dedupeNetworkAdapters(items []models.NetworkAdapter) []models.NetworkAdapte
|
||||
idx := -1
|
||||
if serialKey != "" {
|
||||
if existing, ok := bySerial[serialKey]; ok {
|
||||
idx = existing
|
||||
existingBDF := strings.TrimSpace(out[existing].BDF)
|
||||
candidateBDF := strings.TrimSpace(item.BDF)
|
||||
if existingBDF == "" || candidateBDF == "" || strings.EqualFold(existingBDF, candidateBDF) {
|
||||
idx = existing
|
||||
}
|
||||
}
|
||||
}
|
||||
if idx < 0 && slotModelKey != "" {
|
||||
|
||||
@@ -37,8 +37,9 @@ func ReplayRedfishFromRawPayloads(rawPayloads map[string]any, emit ProgressFn) (
|
||||
|
||||
systemPaths := r.discoverMemberPaths("/redfish/v1/Systems", "/redfish/v1/Systems/1")
|
||||
chassisPaths := r.discoverMemberPaths("/redfish/v1/Chassis", "/redfish/v1/Chassis/1")
|
||||
chassisPaths = r.appendSystemLinkedChassisPaths(systemPaths, chassisPaths)
|
||||
managerPaths := r.discoverMemberPaths("/redfish/v1/Managers", "/redfish/v1/Managers/1")
|
||||
primarySystem := firstPathOrDefault(systemPaths, "/redfish/v1/Systems/1")
|
||||
primarySystem := r.selectHostSystemPath(systemPaths, "/redfish/v1/Systems/1")
|
||||
primaryChassis := firstPathOrDefault(chassisPaths, "/redfish/v1/Chassis/1")
|
||||
primaryManager := firstPathOrDefault(managerPaths, "/redfish/v1/Managers/1")
|
||||
|
||||
@@ -70,18 +71,33 @@ func ReplayRedfishFromRawPayloads(rawPayloads map[string]any, emit ProgressFn) (
|
||||
if emit != nil {
|
||||
emit(Progress{Status: "running", Progress: 55, Message: "Redfish snapshot: replay CPU/RAM/Storage..."})
|
||||
}
|
||||
processors := r.collectProcessors(primarySystem)
|
||||
memory := r.collectMemory(primarySystem)
|
||||
storageDevices := r.collectStorage(primarySystem, analysisPlan)
|
||||
storageVolumes := r.collectStorageVolumes(primarySystem, analysisPlan)
|
||||
var processors []models.CPU
|
||||
var memory []models.MemoryDIMM
|
||||
var storageDevices []models.Storage
|
||||
var storageVolumes []models.StorageVolume
|
||||
var storageControllers []models.PCIeDevice
|
||||
for _, systemPath := range systemPaths {
|
||||
processors = append(processors, r.collectProcessors(systemPath)...)
|
||||
memory = append(memory, r.collectMemory(systemPath)...)
|
||||
storageDevices = append(storageDevices, r.collectStorage(systemPath, analysisPlan)...)
|
||||
storageVolumes = append(storageVolumes, r.collectStorageVolumes(systemPath, analysisPlan)...)
|
||||
storageControllers = append(storageControllers, r.collectStorageControllers(systemPath)...)
|
||||
}
|
||||
processors = dedupeReplayCPUs(processors)
|
||||
storageDevices = dedupeStorage(storageDevices)
|
||||
storageVolumes = dedupeStorageVolumes(storageVolumes)
|
||||
|
||||
if emit != nil {
|
||||
emit(Progress{Status: "running", Progress: 80, Message: "Redfish snapshot: replay network/BMC..."})
|
||||
}
|
||||
psus := r.collectPSUs(chassisPaths)
|
||||
psuChassisPaths := dedupeRedfishPaths(redfishLinkRefs(systemDoc, "Links", "Chassis"))
|
||||
psus := r.collectPSUs(psuChassisPaths)
|
||||
if len(psus) == 0 {
|
||||
psus = r.collectPSUs(chassisPaths)
|
||||
}
|
||||
licenses := r.collectLicenses()
|
||||
pcieDevices := r.collectPCIeDevices(systemPaths, chassisPaths)
|
||||
pcieDevices = append(pcieDevices, r.collectStorageControllers(primarySystem)...)
|
||||
pcieDevices = dedupePCIeDevices(append(pcieDevices, storageControllers...))
|
||||
boardInfo := parseBoardInfoWithFallback(systemDoc, chassisDoc, fruDoc)
|
||||
applyBoardInfoFallbackFromDocs(&boardInfo, boardFallbackDocs)
|
||||
|
||||
@@ -89,6 +105,7 @@ func ReplayRedfishFromRawPayloads(rawPayloads map[string]any, emit ProgressFn) (
|
||||
gpus = r.collectGPUsFromProcessors(systemPaths, chassisPaths, gpus, analysisPlan)
|
||||
nics := r.collectNICs(chassisPaths)
|
||||
r.enrichNICsFromNetworkInterfaces(&nics, systemPaths)
|
||||
standardSensors := r.collectStandardSensors(chassisPaths)
|
||||
thresholdSensors := r.collectThresholdSensors(chassisPaths)
|
||||
thermalSensors := r.collectThermalSensors(chassisPaths)
|
||||
powerSensors := r.collectPowerSensors(chassisPaths)
|
||||
@@ -117,7 +134,7 @@ func ReplayRedfishFromRawPayloads(rawPayloads map[string]any, emit ProgressFn) (
|
||||
SourceTimezone: sourceTimezone,
|
||||
Events: append(append(append(append(append(append(make([]models.Event, 0, len(discreteEvents)+len(healthEvents)+len(driveFetchWarningEvents)+len(logEntryEvents)+len(sensorHintEvents)+2), healthEvents...), discreteEvents...), driveFetchWarningEvents...), logEntryEvents...), sensorHintEvents...), bmcManagementEvent...),
|
||||
FRU: assemblyFRU,
|
||||
Sensors: dedupeSensorReadings(append(append(thresholdSensors, thermalSensors...), powerSensors...)),
|
||||
Sensors: dedupeSensorReadings(append(append(append(standardSensors, thresholdSensors...), thermalSensors...), powerSensors...)),
|
||||
RawPayloads: cloneRawPayloads(rawPayloads),
|
||||
Hardware: &models.HardwareConfig{
|
||||
BoardInfo: boardInfo,
|
||||
@@ -609,6 +626,42 @@ func (r redfishSnapshotReader) collectThresholdSensors(chassisPaths []string) []
|
||||
return out
|
||||
}
|
||||
|
||||
func (r redfishSnapshotReader) collectStandardSensors(chassisPaths []string) []models.SensorReading {
|
||||
var out []models.SensorReading
|
||||
for _, chassisPath := range chassisPaths {
|
||||
docs, err := r.getCollectionMembers(joinPath(chassisPath, "/Sensors"))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
for _, doc := range docs {
|
||||
if sensor, ok := parseThresholdSensor(doc); ok {
|
||||
out = append(out, sensor)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func dedupeReplayCPUs(items []models.CPU) []models.CPU {
|
||||
if len(items) <= 1 {
|
||||
return items
|
||||
}
|
||||
out := make([]models.CPU, 0, len(items))
|
||||
seen := make(map[string]struct{}, len(items))
|
||||
for _, item := range items {
|
||||
key := normalizeRedfishIdentityField(item.SerialNumber)
|
||||
if key == "" {
|
||||
key = fmt.Sprintf("socket:%d|model:%s|cores:%d|threads:%d", item.Socket, strings.ToLower(strings.TrimSpace(item.Model)), item.Cores, item.Threads)
|
||||
}
|
||||
if _, ok := seen[key]; ok {
|
||||
continue
|
||||
}
|
||||
seen[key] = struct{}{}
|
||||
out = append(out, item)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func parseThresholdSensor(doc map[string]interface{}) (models.SensorReading, bool) {
|
||||
if len(doc) == 0 {
|
||||
return models.SensorReading{}, false
|
||||
@@ -1219,6 +1272,99 @@ func (r redfishSnapshotReader) discoverMemberPaths(collectionPath, fallbackPath
|
||||
return nil
|
||||
}
|
||||
|
||||
// selectHostSystemPath chooses the server/host ComputerSystem independently of
|
||||
// collection order. Composed accelerator platforms can expose an HGX system
|
||||
// before the host system, while CPU, BIOS, and server identity live on another
|
||||
// member such as Systems/Self.
|
||||
func (r redfishSnapshotReader) selectHostSystemPath(paths []string, fallback string) string {
|
||||
bestPath := ""
|
||||
bestScore := -1
|
||||
for _, path := range paths {
|
||||
path = strings.TrimSpace(path)
|
||||
if path == "" {
|
||||
continue
|
||||
}
|
||||
doc, err := r.getJSON(path)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
processorDocs, _ := r.getCollectionMembers(joinPath(path, "/Processors"))
|
||||
score := redfishHostSystemScore(path, doc, processorDocs)
|
||||
if score > bestScore {
|
||||
bestPath = path
|
||||
bestScore = score
|
||||
}
|
||||
}
|
||||
if bestPath != "" {
|
||||
return bestPath
|
||||
}
|
||||
return firstPathOrDefault(paths, fallback)
|
||||
}
|
||||
|
||||
func (r redfishSnapshotReader) appendSystemLinkedChassisPaths(systemPaths, chassisPaths []string) []string {
|
||||
out := append([]string{}, chassisPaths...)
|
||||
for _, systemPath := range systemPaths {
|
||||
doc, err := r.getJSON(systemPath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
out = append(out, redfishLinkRefs(doc, "Links", "Chassis")...)
|
||||
}
|
||||
return dedupeRedfishPaths(out)
|
||||
}
|
||||
|
||||
func dedupeRedfishPaths(paths []string) []string {
|
||||
out := make([]string, 0, len(paths))
|
||||
seen := make(map[string]struct{}, len(paths))
|
||||
for _, path := range paths {
|
||||
path = normalizeRedfishPath(path)
|
||||
if path == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := seen[path]; ok {
|
||||
continue
|
||||
}
|
||||
seen[path] = struct{}{}
|
||||
out = append(out, path)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func redfishHostSystemScore(path string, doc map[string]interface{}, processorDocs []map[string]interface{}) int {
|
||||
score := 0
|
||||
if strings.EqualFold(lastRedfishPathSegment(path), "self") {
|
||||
score += 25
|
||||
}
|
||||
if summary, ok := doc["ProcessorSummary"].(map[string]interface{}); ok && asInt(summary["Count"]) > 0 {
|
||||
score += 80
|
||||
}
|
||||
if redfishLinkedPath(doc, "Bios") != "" {
|
||||
score += 40
|
||||
}
|
||||
if _, ok := doc["Boot"].(map[string]interface{}); ok {
|
||||
score += 20
|
||||
}
|
||||
if strings.TrimSpace(asString(doc["HostName"])) != "" {
|
||||
score += 10
|
||||
}
|
||||
for _, processor := range processorDocs {
|
||||
processorType := strings.TrimSpace(asString(processor["ProcessorType"]))
|
||||
if processorType == "" || strings.EqualFold(processorType, "CPU") || strings.EqualFold(processorType, "General") {
|
||||
score += 100
|
||||
break
|
||||
}
|
||||
}
|
||||
return score
|
||||
}
|
||||
|
||||
func lastRedfishPathSegment(path string) string {
|
||||
path = strings.Trim(strings.TrimSpace(path), "/")
|
||||
if idx := strings.LastIndex(path, "/"); idx >= 0 {
|
||||
return path[idx+1:]
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func (r redfishSnapshotReader) getLinkedPCIeFunctions(doc map[string]interface{}) []map[string]interface{} {
|
||||
if links, ok := doc["Links"].(map[string]interface{}); ok {
|
||||
if refs, ok := links["PCIeFunctions"].([]interface{}); ok && len(refs) > 0 {
|
||||
|
||||
@@ -944,6 +944,183 @@ func TestReplayRedfishFromRawPayloads_CollectsThermalAndPowerSensors(t *testing.
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayRedfishFromRawPayloads_G894ComposedSystems(t *testing.T) {
|
||||
raw := map[string]any{
|
||||
"redfish_tree": map[string]interface{}{
|
||||
"/redfish/v1": map[string]interface{}{
|
||||
"Systems": map[string]interface{}{"@odata.id": "/redfish/v1/Systems"},
|
||||
"Chassis": map[string]interface{}{"@odata.id": "/redfish/v1/Chassis"},
|
||||
"Managers": map[string]interface{}{"@odata.id": "/redfish/v1/Managers"},
|
||||
},
|
||||
"/redfish/v1/Systems": map[string]interface{}{
|
||||
"Members": []interface{}{
|
||||
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/HGX_Baseboard_0"},
|
||||
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self"},
|
||||
},
|
||||
},
|
||||
"/redfish/v1/Systems/HGX_Baseboard_0": map[string]interface{}{
|
||||
"Manufacturer": "NVIDIA",
|
||||
"Model": "P2312-C00",
|
||||
"Processors": map[string]interface{}{"@odata.id": "/redfish/v1/Systems/HGX_Baseboard_0/Processors"},
|
||||
"Memory": map[string]interface{}{"@odata.id": "/redfish/v1/Systems/HGX_Baseboard_0/Memory"},
|
||||
},
|
||||
"/redfish/v1/Systems/HGX_Baseboard_0/Processors": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/HGX_Baseboard_0/Processors/GPU_0"}},
|
||||
},
|
||||
"/redfish/v1/Systems/HGX_Baseboard_0/Processors/GPU_0": map[string]interface{}{
|
||||
"Id": "GPU_0", "ProcessorType": "GPU", "Model": "NVIDIA B300",
|
||||
},
|
||||
"/redfish/v1/Systems/HGX_Baseboard_0/Memory": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/HGX_Baseboard_0/Memory/GPU_0_DRAM_0"}},
|
||||
},
|
||||
"/redfish/v1/Systems/HGX_Baseboard_0/Memory/GPU_0_DRAM_0": map[string]interface{}{
|
||||
"Id": "GPU_0_DRAM_0", "CapacityMiB": 275040, "MemoryDeviceType": "HBM",
|
||||
"Status": map[string]interface{}{"Health": "OK", "State": "Enabled"},
|
||||
},
|
||||
"/redfish/v1/Systems/Self": map[string]interface{}{
|
||||
"Manufacturer": "Giga Computing",
|
||||
"Model": "G894-SD3-AAX7-000",
|
||||
"SerialNumber": "GQG8NO012A0003",
|
||||
"ProcessorSummary": map[string]interface{}{"Count": 2},
|
||||
"Bios": map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Bios"},
|
||||
"Processors": map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Processors"},
|
||||
"Memory": map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Memory"},
|
||||
"Storage": map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Storage"},
|
||||
"Links": map[string]interface{}{
|
||||
"Chassis": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/Self"}},
|
||||
},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Bios": map[string]interface{}{"Version": "F09"},
|
||||
"/redfish/v1/Systems/Self/Processors": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Processors/CPU0"}},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Processors/CPU0": map[string]interface{}{
|
||||
"Id": "CPU0", "ProcessorType": "CPU", "Model": "Intel(R) Xeon(R) 6767P", "TotalCores": 64, "TotalThreads": 128,
|
||||
"Status": map[string]interface{}{"Health": "OK", "State": "Enabled"},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Memory": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Memory/DIMM_P0_A0"}},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Memory/DIMM_P0_A0": map[string]interface{}{
|
||||
"Id": "DIMM_P0_A0", "DeviceLocator": "DIMM_P0_A0", "CapacityMiB": 65536, "MemoryDeviceType": "DDR5",
|
||||
"Status": map[string]interface{}{"Health": "OK", "State": "Enabled"},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Storage": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Storage/StorageUnit_0"}},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Storage/StorageUnit_0": map[string]interface{}{
|
||||
"Id": "StorageUnit_0",
|
||||
"Drives": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Storage/StorageUnit_0/Drives/NVMe0"}},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Storage/StorageUnit_0/Drives/NVMe0": map[string]interface{}{
|
||||
"Id": "NVMe0", "Name": "NVMe0", "Model": "SOLIDIGM SB5PH27X019T", "SerialNumber": "BTCP517506EQ1P9AGN",
|
||||
"CapacityBytes": int64(1920383410176), "MediaType": "SSD", "Protocol": "NVMe",
|
||||
"Status": map[string]interface{}{"Health": "OK", "State": "Enabled"},
|
||||
},
|
||||
"/redfish/v1/Chassis": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/HGX_Chassis_0"}},
|
||||
},
|
||||
"/redfish/v1/Chassis/HGX_Chassis_0": map[string]interface{}{"Id": "HGX_Chassis_0"},
|
||||
"/redfish/v1/Chassis/Self": map[string]interface{}{"Id": "Self"},
|
||||
"/redfish/v1/Chassis/Self/PowerSubsystem/PowerSupplies": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/Self/PowerSubsystem/PowerSupplies/230"}},
|
||||
},
|
||||
"/redfish/v1/Chassis/Self/PowerSubsystem/PowerSupplies/230": map[string]interface{}{
|
||||
"Id": "230", "Name": "PS1_Status", "Status": map[string]interface{}{"Health": "OK", "State": "Enabled"},
|
||||
},
|
||||
"/redfish/v1/Chassis/HGX_Chassis_0/Sensors": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/HGX_Chassis_0/Sensors/Inlet_0"}},
|
||||
},
|
||||
"/redfish/v1/Chassis/HGX_Chassis_0/Sensors/Inlet_0": map[string]interface{}{
|
||||
"Id": "Inlet_0", "Name": "Inlet Temperature", "Reading": 23.5, "ReadingType": "Temperature", "ReadingUnits": "Cel",
|
||||
"Status": map[string]interface{}{"Health": "OK", "State": "Enabled"},
|
||||
},
|
||||
"/redfish/v1/Managers": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Managers/Self"}},
|
||||
},
|
||||
"/redfish/v1/Managers/Self": map[string]interface{}{"Id": "Self"},
|
||||
},
|
||||
}
|
||||
|
||||
got, err := ReplayRedfishFromRawPayloads(raw, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("replay failed: %v", err)
|
||||
}
|
||||
if got.Hardware.BoardInfo.ProductName != "G894-SD3-AAX7-000" {
|
||||
t.Fatalf("expected host board identity, got %#v", got.Hardware.BoardInfo)
|
||||
}
|
||||
if len(got.Hardware.CPUs) != 1 || got.Hardware.CPUs[0].Model != "Intel(R) Xeon(R) 6767P" {
|
||||
t.Fatalf("expected host CPU, got %#v", got.Hardware.CPUs)
|
||||
}
|
||||
if len(got.Hardware.Memory) != 2 {
|
||||
t.Fatalf("expected host DDR5 and HGX HBM, got %#v", got.Hardware.Memory)
|
||||
}
|
||||
if len(got.Hardware.Storage) != 1 || got.Hardware.Storage[0].SerialNumber != "BTCP517506EQ1P9AGN" {
|
||||
t.Fatalf("expected host NVMe drive, got %#v", got.Hardware.Storage)
|
||||
}
|
||||
if len(got.Sensors) != 1 || got.Sensors[0].Name != "Inlet Temperature" {
|
||||
t.Fatalf("expected standard Redfish sensor, got %#v", got.Sensors)
|
||||
}
|
||||
if len(got.Hardware.PowerSupply) != 1 || got.Hardware.PowerSupply[0].Slot != "PSU230" {
|
||||
t.Fatalf("expected PSU from system-linked chassis missing from Chassis collection, got %#v", got.Hardware.PowerSupply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectHostSystemPath(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
paths []string
|
||||
tree map[string]interface{}
|
||||
fallback string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "composed accelerator before host",
|
||||
paths: []string{"/redfish/v1/Systems/HGX_Baseboard_0", "/redfish/v1/Systems/Self"},
|
||||
tree: map[string]interface{}{
|
||||
"/redfish/v1/Systems/HGX_Baseboard_0": map[string]interface{}{"Model": "P2312-C00"},
|
||||
"/redfish/v1/Systems/HGX_Baseboard_0/Processors": map[string]interface{}{"Members": []interface{}{}},
|
||||
"/redfish/v1/Systems/Self": map[string]interface{}{
|
||||
"ProcessorSummary": map[string]interface{}{"Count": 2},
|
||||
"Bios": map[string]interface{}{"@odata.id": "/redfish/v1/Systems/Self/Bios"},
|
||||
},
|
||||
"/redfish/v1/Systems/Self/Processors": map[string]interface{}{"Members": []interface{}{}},
|
||||
},
|
||||
want: "/redfish/v1/Systems/Self",
|
||||
},
|
||||
{
|
||||
name: "structural host beats empty self",
|
||||
paths: []string{"/redfish/v1/Systems/Self", "/redfish/v1/Systems/node"},
|
||||
tree: map[string]interface{}{
|
||||
"/redfish/v1/Systems/Self": map[string]interface{}{},
|
||||
"/redfish/v1/Systems/Self/Processors": map[string]interface{}{"Members": []interface{}{}},
|
||||
"/redfish/v1/Systems/node": map[string]interface{}{"ProcessorSummary": map[string]interface{}{"Count": 2}},
|
||||
"/redfish/v1/Systems/node/Processors": map[string]interface{}{
|
||||
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/node/Processors/CPU0"}},
|
||||
},
|
||||
"/redfish/v1/Systems/node/Processors/CPU0": map[string]interface{}{"ProcessorType": "CPU"},
|
||||
},
|
||||
want: "/redfish/v1/Systems/node",
|
||||
},
|
||||
{
|
||||
name: "missing documents retain collection fallback",
|
||||
paths: []string{"/redfish/v1/Systems/1"},
|
||||
tree: map[string]interface{}{},
|
||||
fallback: "/redfish/v1/Systems/fallback",
|
||||
want: "/redfish/v1/Systems/1",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := redfishSnapshotReader{tree: tt.tree}
|
||||
if got := r.selectHostSystemPath(tt.paths, tt.fallback); got != tt.want {
|
||||
t.Fatalf("selectHostSystemPath() = %q, want %q", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnrichNICFromPCIeFunctions(t *testing.T) {
|
||||
nic := parseNIC(map[string]interface{}{
|
||||
"Id": "1",
|
||||
@@ -3360,6 +3537,47 @@ func TestDedupeNetworkAdapters_MergesBySlotAndKeepsRicherData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupeNetworkAdapters_KeepsRepeatedSerialOnDistinctBDFs(t *testing.T) {
|
||||
in := []models.NetworkAdapter{
|
||||
{Slot: "Offboard_3", Model: "ConnectX-8", SerialNumber: "1951026575233", BDF: "0000:7a:00.0", Present: true},
|
||||
{Slot: "Offboard_4", Model: "ConnectX-8", SerialNumber: "1951026575233", BDF: "0000:97:00.0", Present: true},
|
||||
}
|
||||
|
||||
out := dedupeNetworkAdapters(in)
|
||||
if len(out) != 2 {
|
||||
t.Fatalf("expected distinct physical NICs despite repeated BMC serial, got %#v", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupeNetworkAdapters_MergesRepeatedSerialOnSameBDF(t *testing.T) {
|
||||
in := []models.NetworkAdapter{
|
||||
{Slot: "HGX_ConnectX_0", Model: "ConnectX-8", SerialNumber: "1951026575233", BDF: "0000:7a:00.0", Present: true},
|
||||
{Slot: "Offboard_3", Model: "ConnectX-8", SerialNumber: "1951026575233", BDF: "0000:7a:00.0", Firmware: "40.47.2526", Present: true},
|
||||
}
|
||||
|
||||
out := dedupeNetworkAdapters(in)
|
||||
if len(out) != 1 || out[0].Firmware != "40.47.2526" {
|
||||
t.Fatalf("expected duplicate views of the same BDF to merge, got %#v", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRedfishBDFFromResourceID(t *testing.T) {
|
||||
tests := []struct {
|
||||
id string
|
||||
want string
|
||||
}{
|
||||
{id: "00_7A_00_00", want: "0000:7a:00.0"},
|
||||
{id: "0001_65_1F_07", want: "0001:65:1f.7"},
|
||||
{id: "00_65_20_00", want: ""},
|
||||
{id: "CPU0", want: ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := redfishBDFFromResourceID(tt.id); got != tt.want {
|
||||
t.Fatalf("redfishBDFFromResourceID(%q) = %q, want %q", tt.id, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupePCIeDevices_MergesByLooseKeyAndKeepsBDF(t *testing.T) {
|
||||
in := []models.PCIeDevice{
|
||||
{
|
||||
@@ -3884,6 +4102,44 @@ func TestLooksLikeGPU_NVSwitchExcluded(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLooksLikeGPU_ConnectXExcluded(t *testing.T) {
|
||||
doc := map[string]interface{}{
|
||||
"Id": "ConnectX_0",
|
||||
"Name": "PCIe Device",
|
||||
"Model": "Nvidia ConnectX8 XDR IB/800GBE for Nvidia B300 NVL8 Umbriel System",
|
||||
"Manufacturer": "NVIDIA",
|
||||
"DeviceType": "SingleFunction",
|
||||
}
|
||||
if looksLikeGPU(doc, nil) {
|
||||
t.Fatal("ConnectX network adapter should not be classified as a GPU")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLooksLikeGPU_ASPEEDDisplayExcluded(t *testing.T) {
|
||||
doc := map[string]interface{}{
|
||||
"Id": "00_55_00",
|
||||
"Name": "ASPEED Graphics Family",
|
||||
"Model": "ASPEED Graphics Family",
|
||||
"Manufacturer": "ASPEED Technology, Inc.",
|
||||
}
|
||||
functionDocs := []map[string]interface{}{{"ClassCode": "0x030000", "DeviceClass": "DisplayController"}}
|
||||
if looksLikeGPU(doc, functionDocs) {
|
||||
t.Fatal("ASPEED BMC display controller should not be classified as a compute GPU")
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldSkipGenericGPUDuplicate_MatchesVendorDeviceIdentity(t *testing.T) {
|
||||
existing := []models.GPU{{
|
||||
Model: "NVIDIA B300 SXM6 AC", VendorID: 0x10de, DeviceID: 0x3182, SerialNumber: "GPU-SN-1",
|
||||
}}
|
||||
candidate := models.GPU{
|
||||
Slot: "GB110 [B300 SXM6 AC]", Model: "GB110 [B300 SXM6 AC]", VendorID: 0x10de, DeviceID: 0x3182,
|
||||
}
|
||||
if !shouldSkipGenericGPUDuplicate(existing, candidate) {
|
||||
t.Fatal("expected identity-equivalent host PCIe GPU view to be skipped")
|
||||
}
|
||||
}
|
||||
|
||||
// TestLooksLikeGPU_ResolvesVendorDeviceIDWhenModelTextMissing covers xFusion
|
||||
// BMCs (e.g. G5500 V7) whose PCIeDevice doc and linked PCIeFunction leave
|
||||
// Name/Model/Manufacturer/ClassCode empty but expose raw VendorId/DeviceId
|
||||
|
||||
Reference in new issue
Block a user