From 0e46b2151831512a2b7d0119e81e954556ed8ac7 Mon Sep 17 00:00:00 2001 From: Matt Vandermeulen Date: Tue, 15 Oct 2024 13:53:18 -0300 Subject: [PATCH] oem/smc: replace getters with direct members for top level oem data --- oem/smc/drive.go | 27 ++++++--------------------- oem/smc/drive_test.go | 4 ++-- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/oem/smc/drive.go b/oem/smc/drive.go index c143e93e..9013910b 100644 --- a/oem/smc/drive.go +++ b/oem/smc/drive.go @@ -18,9 +18,9 @@ type Drive struct { redfish.Drive // Fields from the SMC OEM section - temperature int - percentageDriveLifeUsed int - driveFunctional bool + Temperature int + PercentageDriveLifeUsed int + DriveFunctional bool // indicateTarget is the uri to hit to change the light state indicateTarget string @@ -53,9 +53,9 @@ func FromDrive(drive *redfish.Drive) (Drive, error) { return smcDrive, err } - smcDrive.temperature = t.Oem.Supermicro.Temperature - smcDrive.percentageDriveLifeUsed = t.Oem.Supermicro.PercentageDriveLifeUsed - smcDrive.driveFunctional = t.Oem.Supermicro.DriveFunctional + smcDrive.Temperature = t.Oem.Supermicro.Temperature + smcDrive.PercentageDriveLifeUsed = t.Oem.Supermicro.PercentageDriveLifeUsed + smcDrive.DriveFunctional = t.Oem.Supermicro.DriveFunctional // We check both the SmcDriveIndicate and the DriveIndicate targets // in the Oem sections - certain models and bmc firmwares will mix @@ -68,21 +68,6 @@ func FromDrive(drive *redfish.Drive) (Drive, error) { return smcDrive, nil } -// Temperature returns the OEM provided temperature for the drive -func (d Drive) Temperature() int { - return d.temperature -} - -// PercentageDriveLifeUsed returns the OEM provided drive life estimate as a percentage used -func (d Drive) PercentageDriveLifeUsed() int { - return d.percentageDriveLifeUsed -} - -// Functional returns the OEM provided flag that suggests whether a drive is functional or not -func (d Drive) Functional() bool { - return d.driveFunctional -} - // Indicate will set the indicator light activity, true for on, false for off func (d Drive) Indicate(active bool) error { // Return a common error to let the user try falling back on the normal gofish path diff --git a/oem/smc/drive_test.go b/oem/smc/drive_test.go index e2d2f349..0a6fb010 100644 --- a/oem/smc/drive_test.go +++ b/oem/smc/drive_test.go @@ -57,8 +57,8 @@ func TestSmcDriveOem(t *testing.T) { t.Fatalf("error getting oem info from drive: %v", err) } - if smcDrive.Temperature() != 33 { - t.Errorf("unexpected oem drive temerature: %d", smcDrive.Temperature()) + if smcDrive.Temperature != 33 { + t.Errorf("unexpected oem drive temerature: %d", smcDrive.Temperature) } if smcDrive.indicateTarget != "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.22/Actions/Oem/Drive.Indicate" {