fix(inspur): fix PSU section regex when PCIE section precedes Network
The PSU regex used "RESTful Network" as its end anchor, but in standard Inspur component.log layout the PCIE Device section sits between PSU and Network Adapter. The lazy [\s\S]*? captured across the PCIE error block, producing invalid JSON and silently dropping all PSU data. Changed anchor to RESTful (?:PCIE|Network) — matches whichever section immediately follows PSU in a given archive. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
6
internal/parser/vendors/inspur/component.go
vendored
6
internal/parser/vendors/inspur/component.go
vendored
@@ -250,7 +250,7 @@ type PSURESTInfo struct {
|
||||
|
||||
func parsePSUInfo(text string, hw *models.HardwareConfig) {
|
||||
// Find RESTful PSU info section
|
||||
re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful Network`)
|
||||
re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful (?:PCIE|Network)`)
|
||||
match := re.FindStringSubmatch(text)
|
||||
if match == nil {
|
||||
return
|
||||
@@ -880,7 +880,7 @@ func parseDiskBackplaneSensors(text string) []models.SensorReading {
|
||||
}
|
||||
|
||||
func parsePSUSummarySensors(text string) []models.SensorReading {
|
||||
re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful Network`)
|
||||
re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful (?:PCIE|Network)`)
|
||||
match := re.FindStringSubmatch(text)
|
||||
if match == nil {
|
||||
return nil
|
||||
@@ -1028,7 +1028,7 @@ func extractComponentFirmware(text string, hw *models.HardwareConfig) {
|
||||
// Skip extracting from component.log to avoid duplicates
|
||||
|
||||
// Extract PSU firmware from RESTful PSU info
|
||||
rePSU := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful Network`)
|
||||
rePSU := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful (?:PCIE|Network)`)
|
||||
if match := rePSU.FindStringSubmatch(text); match != nil {
|
||||
jsonStr := strings.ReplaceAll(match[1], "\n", "")
|
||||
var psuInfo PSURESTInfo
|
||||
|
||||
Reference in New Issue
Block a user