forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththermalmetrics.go
128 lines (113 loc) · 6.14 KB
/
thermalmetrics.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"github.com/stmcginnis/gofish/common"
)
// HeaterSummary shall contain properties that describe the heater metrics summary for the subsystem.
type HeaterSummary struct {
// TotalPrePowerOnHeatingTimeSeconds shall contain the total number of seconds all the heaters in the thermal
// subsystem were active while the respective devices they heat were powered off.
TotalPrePowerOnHeatingTimeSeconds int
// TotalRuntimeHeatingTimeSeconds shall contain the total number of seconds all the heaters in the thermal
// subsystem were active while the respective devices they heat were powered on.
TotalRuntimeHeatingTimeSeconds int
}
// TemperatureSummary shall contain properties that describe temperature sensor for a subsystem.
type TemperatureSummary struct {
// Ambient shall contain the temperature, in degree Celsius units, for the ambient temperature of this subsystem.
// The value of the DataSourceUri property, if present, shall reference a resource of type Sensor with the
// ReadingType property containing the value 'Temperature'.
Ambient SensorExcerpt
// Exhaust shall contain the temperature, in degree Celsius units, for the exhaust temperature of this subsystem.
// The value of the DataSourceUri property, if present, shall reference a resource of type Sensor with the
// ReadingType property containing the value 'Temperature'.
Exhaust SensorExcerpt
// Intake shall contain the temperature, in degree Celsius units, for the intake temperature of this subsystem. The
// value of the DataSourceUri property, if present, shall reference a resource of type Sensor with the ReadingType
// property containing the value 'Temperature'.
Intake SensorExcerpt
// Internal shall contain the temperature, in degree Celsius units, for the internal temperature of this subsystem.
// The value of the DataSourceUri property, if present, shall reference a resource of type Sensor with the
// ReadingType property containing the value 'Temperature'.
Internal SensorExcerpt
}
// ThermalMetrics shall represent the thermal metrics of a chassis for a Redfish implementation.
type ThermalMetrics struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataEtag is the odata etag.
ODataEtag string `json:"@odata.etag"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// AirFlowCubicMetersPerMinute shall contain the rate of air flow, in cubic meters per minute units, between the
// air intake and the air exhaust of this chassis. The value of the DataSourceUri property, if present, shall
// reference a resource of type Sensor with the ReadingType property containing the value 'AirFlowCMM'.
AirFlowCubicMetersPerMinute SensorExcerpt
// DeltaPressurekPa shall contain the pressure, in kilopascal units, for the difference in pressure between the air
// intake and the air exhaust of this chassis. The value of the DataSourceUri property, if present, shall reference
// a resource of type Sensor with the ReadingType property containing the value 'PressurekPa'.
DeltaPressurekPa SensorExcerpt
// Description provides a description of this resource.
Description string
// EnergykWh shall contain the total energy, in kilowatt-hour units, for the thermal subsystem. The value shall
// include the total energy consumption of devices involved in thermal management of the chassis, such as fans,
// pumps, and heaters. The value of the DataSourceUri property, if present, shall reference a resource of type
// Sensor with the ReadingType property containing the value 'EnergykWh'.
EnergykWh SensorEnergykWhExcerpt
// HeaterSummary shall contain the summary of heater metrics for this subsystem.
HeaterSummary HeaterSummary
// Oem shall contain the OEM extensions. All values for properties that this object contains shall conform to the
// Redfish Specification-described requirements.
OEM json.RawMessage `json:"Oem"`
// PowerWatts shall contain the power, in watt units, for the thermal subsystem. The value shall include the total
// power consumption of devices involved in thermal management of the chassis, such as fans, pumps, and heaters.
// The value of the DataSourceUri property, if present, shall reference a resource of type Sensor with the
// ReadingType property containing the value 'Power'.
PowerWatts SensorPowerExcerpt
// TemperatureReadingsCelsius shall contain the temperatures, in degree Celsius units, for this subsystem. The
// value of the DataSourceUri property, if present, shall reference a resource of type Sensor with the ReadingType
// property containing the value 'Temperature'.
TemperatureReadingsCelsius []SensorArrayExcerpt
TemperatureReadingsCelsiusCount int `json:"[email protected]"`
// TemperatureSummaryCelsius shall contain the temperature sensor readings for this subsystem.
TemperatureSummaryCelsius TemperatureSummary
resetMetricsTarget string
}
// UnmarshalJSON unmarshals a ThermalMetrics object from the raw JSON.
func (thermalmetrics *ThermalMetrics) UnmarshalJSON(b []byte) error {
type temp ThermalMetrics
var t struct {
temp
Actions struct {
ResetMetrics struct {
Target string
} `json:"#ThermalMetrics.ResetMetrics"`
}
}
err := json.Unmarshal(b, &t)
if err != nil {
return err
}
*thermalmetrics = ThermalMetrics(t.temp)
// Extract the links to other entities for later
thermalmetrics.resetMetricsTarget = t.Actions.ResetMetrics.Target
return nil
}
// ResetMetrics resets the summary metrics related to this equipment.
func (thermalmetrics *ThermalMetrics) ResetMetrics() error {
return thermalmetrics.Post(thermalmetrics.resetMetricsTarget, nil)
}
// GetThermalMetrics will get a ThermalMetrics instance from the service.
func GetThermalMetrics(c common.Client, uri string) (*ThermalMetrics, error) {
return common.GetObject[ThermalMetrics](c, uri)
}
// ListReferencedThermalMetricss gets the collection of ThermalMetrics from
// a provided reference.
func ListReferencedThermalMetrics(c common.Client, link string) ([]*ThermalMetrics, error) {
return common.GetCollectionObjects[ThermalMetrics](c, link)
}