feat(exporter): collect and export storage.vendor_id/device_id (contract v2.13)
Add PCI Vendor ID / Device ID to hardware.storage[] per the updated Reanimator ingest contract, mirroring the existing pcie_devices[] fields. Populated for Redfish-collected NVMe drives (live + TSR replay, via linked PCIeFunctions) and for Inspur (from asset.json's own PcieInfo[], joined by PcieSlot). Also fixes canonicalDevicesForExport dropping the fields when converting Storage into the canonical HardwareDevice list used by the actual export path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
063587958e
commit
399eca5f49
@@ -813,6 +813,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
continue
|
||||
}
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, driveDoc, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, driveDoc)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(driveDoc, supplementalDocs...))
|
||||
}
|
||||
if len(driveDocs) == 0 {
|
||||
@@ -821,6 +822,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
continue
|
||||
}
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, driveDoc, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, driveDoc)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(driveDoc, supplementalDocs...))
|
||||
}
|
||||
}
|
||||
@@ -846,6 +848,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
continue
|
||||
}
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, driveDoc, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, driveDoc)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(driveDoc, supplementalDocs...))
|
||||
}
|
||||
continue
|
||||
@@ -857,6 +860,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
continue
|
||||
}
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, member, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, member)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(member, supplementalDocs...))
|
||||
}
|
||||
|
||||
@@ -868,6 +872,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
for _, driveDoc := range driveDocs {
|
||||
if looksLikeDrive(driveDoc) && !isVirtualStorageDrive(driveDoc) {
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, driveDoc, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, driveDoc)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(driveDoc, supplementalDocs...))
|
||||
}
|
||||
}
|
||||
@@ -890,6 +895,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
}) {
|
||||
if looksLikeDrive(driveDoc) && !isVirtualStorageDrive(driveDoc) {
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, driveDoc, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, driveDoc)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(driveDoc, supplementalDocs...))
|
||||
}
|
||||
}
|
||||
@@ -922,6 +928,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
continue
|
||||
}
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, driveDoc, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, driveDoc)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(driveDoc, supplementalDocs...))
|
||||
}
|
||||
}
|
||||
@@ -934,6 +941,7 @@ func (c *RedfishConnector) collectStorage(ctx context.Context, client *http.Clie
|
||||
continue
|
||||
}
|
||||
supplementalDocs := c.getLinkedSupplementalDocs(ctx, client, req, baseURL, driveDoc, "DriveMetrics", "EnvironmentMetrics", "Metrics")
|
||||
supplementalDocs = append(supplementalDocs, c.getLinkedPCIeFunctions(ctx, client, req, baseURL, driveDoc)...)
|
||||
out = append(out, parseDriveWithSupplementalDocs(driveDoc, supplementalDocs...))
|
||||
}
|
||||
}
|
||||
@@ -3495,11 +3503,27 @@ func parseDriveWithSupplementalDocs(doc map[string]interface{}, supplementalDocs
|
||||
|
||||
storageType := classifyStorageType(doc)
|
||||
|
||||
// Drive resources rarely carry PCI Vendor/Device IDs directly; a linked
|
||||
// PCIeFunction document (passed here as part of supplementalDocs, e.g. via
|
||||
// getLinkedPCIeFunctions) usually does for NVMe drives.
|
||||
vendorID := asHexOrInt(doc["VendorId"])
|
||||
deviceID := asHexOrInt(doc["DeviceId"])
|
||||
for _, sd := range supplementalDocs {
|
||||
if vendorID == 0 {
|
||||
vendorID = asHexOrInt(sd["VendorId"])
|
||||
}
|
||||
if deviceID == 0 {
|
||||
deviceID = asHexOrInt(sd["DeviceId"])
|
||||
}
|
||||
}
|
||||
|
||||
slot := normalizeRAIDDriveSlot(firstNonEmpty(asString(doc["Id"]), asString(doc["Name"])))
|
||||
return models.Storage{
|
||||
Slot: slot,
|
||||
Type: storageType,
|
||||
Model: firstNonEmpty(asString(doc["Model"]), asString(doc["Name"])),
|
||||
VendorID: vendorID,
|
||||
DeviceID: deviceID,
|
||||
SizeGB: sizeGB,
|
||||
SerialNumber: findFirstNormalizedStringByKeys(doc, "SerialNumber"),
|
||||
Manufacturer: asString(doc["Manufacturer"]),
|
||||
|
||||
Reference in New Issue
Block a user