forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thermal.go
75 lines (59 loc) · 1.31 KB
/
thermal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// SPDX-License-Identifier: BSD-3-Clause
//
package hpe
import (
"encoding/json"
"github.com/stmcginnis/gofish/redfish"
)
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"`
}
func FromThermal(thermal *redfish.Thermal) (Thermal, error) {
oem := ThermalOem{}
_ = json.Unmarshal(thermal.Oem, &oem)
fans := make([]Fan, 0, len(thermal.Fans))
for i := range thermal.Fans {
fan, err := FromFan(&thermal.Fans[i])
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
}