Skip to content

Commit

Permalink
Add method to get metrics from PowerSupply (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
smiller248 authored Dec 5, 2024
1 parent a4003e8 commit cca588b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions redfish/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ type PowerSupply struct {
// member within the collection. For services supporting Redfish v1.6 or
// higher, this value shall be the zero-based array index.
MemberID string `json:"MemberId"`
// The link to the power supply metrics resource associated with this power supply.
metrics string
// Model shall contain the model information as defined
// by the manufacturer for the associated power supply.
Model string
Expand Down Expand Up @@ -412,6 +414,7 @@ func (powersupply *PowerSupply) UnmarshalJSON(b []byte) error {
var t struct {
temp
Assembly common.Link
Metrics common.Link
Redundancy common.Links
}

Expand All @@ -423,6 +426,7 @@ func (powersupply *PowerSupply) UnmarshalJSON(b []byte) error {
// Extract the links to other entities for later
*powersupply = PowerSupply(t.temp)
powersupply.assembly = t.Assembly.String()
powersupply.metrics = t.Metrics.String()
powersupply.redundancy = t.Redundancy.ToStrings()

// This is a read/write object, so we need to save the raw object data for later
Expand All @@ -439,6 +443,14 @@ func (powersupply *PowerSupply) Assembly() (*Assembly, error) {
return GetAssembly(powersupply.GetClient(), powersupply.assembly)
}

// Metrics gets the metrics associated with this power supply.
func (powersupply *PowerSupply) Metrics() (*PowerSupplyUnitMetrics, error) {
if powersupply.metrics == "" {
return nil, nil
}
return GetPowerSupplyUnitMetrics(powersupply.GetClient(), powersupply.metrics)
}

// Redundancy gets the endpoints at the other end of the link.
func (powersupply *PowerSupply) Redundancy() ([]*Redundancy, error) {
return common.GetObjects[Redundancy](powersupply.GetClient(), powersupply.redundancy)
Expand Down

0 comments on commit cca588b

Please sign in to comment.