Skip to content

Commit

Permalink
feat: support oem field of thermal and fan
Browse files Browse the repository at this point in the history
  • Loading branch information
haoli committed Jun 3, 2022
1 parent 10cd4c3 commit ea4c0d1
Show file tree
Hide file tree
Showing 3 changed files with 1,367 additions and 0 deletions.
75 changes: 75 additions & 0 deletions oem/hpe/hpe.go
Original file line number Diff line number Diff line change
@@ -0,0 1,75 @@
//
// SPDX-License-Identifier: BSD-3-Clause
//

package hpe

import (
"encoding/json"

"github.com/stmcginnis/gofish/redfish"
)

func FromThermal(thermal redfish.Thermal) (Thermal, error) {
oem := ThermalOem{}

json.Unmarshal(thermal.Oem, &oem)

fans := make([]Fan, 0, len(thermal.Fans))

for _, f := range thermal.Fans {
fan, err := FromFan(f)
if err != nil {
return Thermal{}, err
}

fans = append(fans, fan)
}

return Thermal{
Thermal: thermal,
Fans: fans,
Oem: oem,
}, nil
}

func FromFan(fan redfish.Fan) (Fan, error) {
oem := FanOem{}

json.Unmarshal(fan.Oem, &oem)

return Fan{
Fan: fan,
Oem: oem,
}, nil
}

type Fan struct {
redfish.Fan
Oem FanOem
}

type FanOem struct {
Hpe struct {
OdataContext string `json:"@odata.context"`
OdataType string `json:"@odata.type"`
Location string `json:"Location"`
Redundant bool `json:"Redundant"`
HotPluggable bool `json:"HotPluggable"`
} `json:"Hpe"`
}

type Thermal struct {
redfish.Thermal
Fans []Fan
Oem ThermalOem
}

type ThermalOem struct {
Hpe struct {
OdataContext string `json:"@odata.context"`
OdataType string `json:"@odata.type"`
ThermalConfiguration string `json:"ThermalConfiguration"`
FanPercentMinimum int `json:"FanPercentMinimum"`
} `json:"Hpe"`
}
Loading

0 comments on commit ea4c0d1

Please sign in to comment.