Skip to content

Commit

Permalink
Added the ability to parse paradise events (#59)
Browse files Browse the repository at this point in the history
Paradise OpenBMC events are json where the Events field is a single
object. For other hardware, the Events field is an array.

This commit adds the ability to parse the Events field as a single object, in addition to the existing parser that parses Events as an array.

CASMHMS-6208
  • Loading branch information
shunr-hpe authored May 31, 2024
1 parent dafb9c0 commit 1007818
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.32.0
2.33.0
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Removed - for now removed features
Fixed - for any bug fixes
Security - in case of vulnerabilities
-->
## [2.33.0] - 2024-05-28

### Added

- CASMHMS-6208 - Handle Foxconn Paradise OpenBmc power events

## [2.32.0] - 2024-05-07

### Added
Expand Down
14 changes: 12 additions & 2 deletions cmd/hmcollector/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,18 @@ func unmarshalEvents(bodyBytes []byte) (events hmcollector.Events, err error) {
} else {
var evObjs []map[string]interface{}
if e = json.Unmarshal(evBytes, &evObjs); e != nil {
marshalErr(evBytes, e)
return
// Try parsing the bytes as a single event object
// Paradise BMCs return an object instead of an array of objects for the Events field
var singleEvObj map[string]interface{}
if e2 := json.Unmarshal(evBytes, &singleEvObj); e2 != nil {
// return the original parse error
marshalErr(evBytes, e)
return
} else {
// convert the result to an array
evObjs = make([]map[string]interface{}, 1)
evObjs[0] = singleEvObj
}
}
for _, ev := range evObjs {
s, ok := ev["OriginOfCondition"].(string)
Expand Down

0 comments on commit 1007818

Please sign in to comment.