Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to get metrics from PowerSupply #389

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading