Skip to content

Commit

Permalink
Add ability to get RedundancySet for Power (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
pereztr5 authored Jul 29, 2024
1 parent 1758adc commit c4e27dc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions redfish/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ func (power *Power) PowerSupplyReset(memberID string, resetType ResetType) error
return power.Post(power.powerSupplyResetTarget, t)
}

// RedundancySet returns the []PowerSupply in the target redundancy group based on the
// memberID. The memberID is the ID for the redundancy group from the list of .Redundancy
// from /redfish/v1/Chassis/{id}/Power
func (power *Power) RedundancySet(memberID int) []PowerSupply {
var powerSupplies []PowerSupply
if len(power.Redundancy) >= memberID+1 {
for _, psLink := range power.Redundancy[memberID].redundancySet {
for i := range power.PowerSupplies {
if power.PowerSupplies[i].ODataID == psLink {
powerSupplies = append(powerSupplies, power.PowerSupplies[i])
}
}
}
}

return powerSupplies
}

// GetPower will get a Power instance from the service.
func GetPower(c common.Client, uri string) (*Power, error) {
return common.GetObject[Power](c, uri)
Expand Down

0 comments on commit c4e27dc

Please sign in to comment.