-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support oem field of thermal and fan
- Loading branch information
haoli
committed
Jun 3, 2022
1 parent
10cd4c3
commit ea4c0d1
Showing
3 changed files
with
1,367 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"` | ||
} |
Oops, something went wrong.