Skip to content

Commit 469f63b

Browse files
committed
Add Drive.EnvironmentMetrics() accessor
We added EnvironmentMetrics objects, but did not provide a way to fetch them from the links of a Drive. This adds a Drive function to retrieve the EnvironmentMetrics when available. Signed-off-by: Sean McGinnis <[email protected]>
1 parent ca10211 commit 469f63b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

redfish/drive.go

+11
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,17 @@ func (drive *Drive) Endpoints() ([]*Endpoint, error) {
473473
return common.GetObjects[Endpoint](drive.GetClient(), drive.endpoints)
474474
}
475475

476+
// EnvironmentMetrics gets the environment metrics for this drive.
477+
// If no metrics are available the EnvironmentMetrics reference will be nil but
478+
// no error will be returned unless it was due to a problem fetching the data.
479+
func (drive *Drive) EnvironmentMetrics() (*EnvironmentMetrics, error) {
480+
if drive.environmentMetrics == "" {
481+
return nil, nil
482+
}
483+
484+
return GetEnvironmentMetrics(drive.GetClient(), drive.environmentMetrics)
485+
}
486+
476487
// Volumes references the Volumes that this drive is associated with.
477488
func (drive *Drive) Volumes() ([]*Volume, error) {
478489
return common.GetObjects[Volume](drive.GetClient(), drive.volumes)

0 commit comments

Comments
 (0)