diff --git a/bmc/firmware.go b/bmc/firmware.go index d36ed6cb..82fecd85 100644 --- a/bmc/firmware.go +++ b/bmc/firmware.go @@ -7,15 +7,23 @@ import ( bmclibErrs "github.com/bmc-toolbox/bmclib/errors" - "github.com/pkg/errors" - "github.com/hashicorp/go-multierror" + "github.com/pkg/errors" ) // FirmwareInstaller defines an interface to install firmware updates type FirmwareInstaller interface { // FirmwareInstall uploads firmware update payload to the BMC returning the task ID - FirmwareInstall(ctx context.Context, component, applyAt string, forceInstall bool, reader io.Reader) (jobID string, err error) + // + // parameters: + // component - the component slug for the component update being installed. + // applyAt - one of "Immediate", "OnReset". + // forceInstall - purge the install task queued/scheduled firmware install BMC task (if any). + // reader - the io.reader to the firmware update file. + // + // return values: + // taskID - A taskID is returned if the update process on the BMC returns an identifier for the update process. + FirmwareInstall(ctx context.Context, component, applyAt string, forceInstall bool, reader io.Reader) (taskID string, err error) } // firmwareInstallerProvider is an internal struct to correlate an implementation/provider and its name @@ -24,17 +32,8 @@ type firmwareInstallerProvider struct { FirmwareInstaller } -// FirmwareInstall uploads and initiates firmware update for the component -// -// parameters: -// component - the component slug for the component update being installed -// applyAt - one of "Immediate", "OnReset" -// forceInstall - purge the install task queued/scheduled firmware install BMC task (if any) -// reader - the io.reader to the firmware update file -// -// return values: -// taskID - A taskID is returned if the update process on the BMC returns an identifier for the update process -func FirmwareInstall(ctx context.Context, component, applyAt string, forceInstall bool, reader io.Reader, generic []firmwareInstallerProvider) (taskID string, metadata Metadata, err error) { +// firmwareInstall uploads and initiates firmware update for the component +func firmwareInstall(ctx context.Context, component, applyAt string, forceInstall bool, reader io.Reader, generic []firmwareInstallerProvider) (taskID string, metadata Metadata, err error) { var metadataLocal Metadata Loop: for _, elem := range generic { @@ -86,11 +85,20 @@ func FirmwareInstallFromInterfaces(ctx context.Context, component, applyAt strin ) } - return FirmwareInstall(ctx, component, applyAt, forceInstall, reader, implementations) + return firmwareInstall(ctx, component, applyAt, forceInstall, reader, implementations) } // FirmwareInstallVerifier defines an interface to check firmware install status type FirmwareInstallVerifier interface { + // FirmwareInstallStatus returns the status of the firmware install process. + // + // parameters: + // component (optional) - the component slug for the component update being installed. + // installVersion (required) - the version this method should check is installed. + // taskID (optional) - the task identifier. + // + // return values: + // status - returns one of the FirmwareInstall statuses (see devices/constants.go). FirmwareInstallStatus(ctx context.Context, component, installVersion, taskID string) (status string, err error) } @@ -100,15 +108,8 @@ type firmwareInstallVerifierProvider struct { FirmwareInstallVerifier } -// FirmwareInstallStatus returns the status of the firmware install process -// -// parameters: -// component (optional) - the component slug for the component update being installed -// taskID (optional) - the task identifier -// -// return values: -// status - returns one of the FirmwareInstall statuses (see devices/constants.go) -func FirmwareInstallStatus(ctx context.Context, component, installVersion, taskID string, generic []firmwareInstallVerifierProvider) (status string, metadata Metadata, err error) { +// firmwareInstallStatus returns the status of the firmware install process +func firmwareInstallStatus(ctx context.Context, component, installVersion, taskID string, generic []firmwareInstallVerifierProvider) (status string, metadata Metadata, err error) { var metadataLocal Metadata Loop: for _, elem := range generic { @@ -160,5 +161,5 @@ func FirmwareInstallStatusFromInterfaces(ctx context.Context, component, install ) } - return FirmwareInstallStatus(ctx, component, installVersion, taskID, implementations) + return firmwareInstallStatus(ctx, component, installVersion, taskID, implementations) } diff --git a/bmc/firmware_test.go b/bmc/firmware_test.go index ba75d1f5..26e11cf0 100644 --- a/bmc/firmware_test.go +++ b/bmc/firmware_test.go @@ -51,7 +51,7 @@ func TestFirmwareInstall(t *testing.T) { } ctx, cancel := context.WithTimeout(context.Background(), tc.ctxTimeout) defer cancel() - taskID, metadata, err := FirmwareInstall(ctx, tc.component, tc.applyAt, tc.forceInstall, tc.reader, []firmwareInstallerProvider{{tc.providerName, &testImplementation}}) + taskID, metadata, err := firmwareInstall(ctx, tc.component, tc.applyAt, tc.forceInstall, tc.reader, []firmwareInstallerProvider{{tc.providerName, &testImplementation}}) if tc.returnError != nil { assert.ErrorIs(t, err, tc.returnError) return @@ -146,7 +146,7 @@ func TestFirmwareInstallStatus(t *testing.T) { } ctx, cancel := context.WithTimeout(context.Background(), tc.ctxTimeout) defer cancel() - taskID, metadata, err := FirmwareInstallStatus(ctx, tc.component, tc.installVersion, tc.taskID, []firmwareInstallVerifierProvider{{tc.providerName, &testImplementation}}) + taskID, metadata, err := firmwareInstallStatus(ctx, tc.component, tc.installVersion, tc.taskID, []firmwareInstallVerifierProvider{{tc.providerName, &testImplementation}}) if tc.returnError != nil { assert.ErrorIs(t, err, tc.returnError) return diff --git a/bmc/inventory.go b/bmc/inventory.go index c8391dd2..b93dd66f 100644 --- a/bmc/inventory.go +++ b/bmc/inventory.go @@ -21,8 +21,8 @@ type inventoryGetterProvider struct { InventoryGetter } -// Inventory returns hardware and firmware inventory -func Inventory(ctx context.Context, generic []inventoryGetterProvider) (device *devices.Device, metadata Metadata, err error) { +// inventory returns hardware and firmware inventory +func inventory(ctx context.Context, generic []inventoryGetterProvider) (device *devices.Device, metadata Metadata, err error) { var metadataLocal Metadata Loop: for _, elem := range generic { @@ -74,5 +74,5 @@ func GetInventoryFromInterfaces(ctx context.Context, generic []interface{}) (dev ) } - return Inventory(ctx, implementations) + return inventory(ctx, implementations) } diff --git a/bmc/inventory_test.go b/bmc/inventory_test.go index e0e18368..7e5f705f 100644 --- a/bmc/inventory_test.go +++ b/bmc/inventory_test.go @@ -46,7 +46,7 @@ func TestInventory(t *testing.T) { } ctx, cancel := context.WithTimeout(context.Background(), tc.ctxTimeout) defer cancel() - device, metadata, err := Inventory(ctx, []inventoryGetterProvider{{tc.providerName, &testImplementation}}) + device, metadata, err := inventory(ctx, []inventoryGetterProvider{{tc.providerName, &testImplementation}}) if tc.returnError != nil { assert.ErrorIs(t, err, tc.returnError) return diff --git a/bmc/postcode.go b/bmc/postcode.go index fd266bed..cd7c50b4 100644 --- a/bmc/postcode.go +++ b/bmc/postcode.go @@ -23,8 +23,8 @@ type postCodeGetterProvider struct { PostCodeGetter } -// PostCode returns the device BIOS/UEFI POST code -func PostCode(ctx context.Context, generic []postCodeGetterProvider) (status string, code int, metadata Metadata, err error) { +// postCode returns the device BIOS/UEFI POST code +func postCode(ctx context.Context, generic []postCodeGetterProvider) (status string, code int, metadata Metadata, err error) { var metadataLocal Metadata Loop: for _, elem := range generic { @@ -76,5 +76,5 @@ func GetPostCodeInterfaces(ctx context.Context, generic []interface{}) (status s ) } - return PostCode(ctx, implementations) + return postCode(ctx, implementations) } diff --git a/bmc/postcode_test.go b/bmc/postcode_test.go index 257f695d..63b1f48d 100644 --- a/bmc/postcode_test.go +++ b/bmc/postcode_test.go @@ -47,7 +47,7 @@ func TestPostCode(t *testing.T) { } ctx, cancel := context.WithTimeout(context.Background(), tc.ctxTimeout) defer cancel() - status, code, metadata, err := PostCode(ctx, []postCodeGetterProvider{{tc.providerName, &testImplementation}}) + status, code, metadata, err := postCode(ctx, []postCodeGetterProvider{{tc.providerName, &testImplementation}}) if tc.returnError != nil { assert.ErrorIs(t, err, tc.returnError) return diff --git a/providers/asrockrack/firmware.go b/providers/asrockrack/firmware.go index c5fd9f02..0ac74860 100644 --- a/providers/asrockrack/firmware.go +++ b/providers/asrockrack/firmware.go @@ -14,8 +14,6 @@ import ( bmclibErrs "github.com/bmc-toolbox/bmclib/errors" ) - - // FirmwareInstall uploads and initiates firmware update for the component func (a *ASRockRack) FirmwareInstall(ctx context.Context, component, applyAt string, forceInstall bool, reader io.Reader) (jobID string, err error) { var size int64 @@ -118,10 +116,7 @@ func (a *ASRockRack) firmwareInstallBIOS(ctx context.Context, reader io.Reader, // firmwareUpdateBMCStatus returns the BMC firmware install status func (a *ASRockRack) firmwareUpdateBMCStatus(ctx context.Context, installVersion string) (status string, err error) { - os.Setenv("BMCLIB_LOG_LEVEL", "trace") - defer os.Unsetenv("BMCLIB_LOG_LEVEL") - endpoint := "api/maintenance/firmware/flash-progress" - p, progressErr := a.flashProgress(ctx, endpoint) + p, progressErr := a.flashProgress(ctx, "api/maintenance/firmware/flash-progress") if progressErr != nil { installed, versionErr := a.versionInstalled(ctx, devices.SlugBMC, installVersion) if err != nil { @@ -160,11 +155,7 @@ func (a *ASRockRack) firmwareUpdateBMCStatus(ctx context.Context, installVersion // firmwareUpdateBIOSStatus returns the BIOS firmware install status func (a *ASRockRack) firmwareUpdateBIOSStatus(ctx context.Context, installVersion string) (status string, err error) { - os.Setenv("BMCLIB_LOG_LEVEL", "trace") - defer os.Unsetenv("BMCLIB_LOG_LEVEL") - - endpoint := "api/asrr/maintenance/BIOS/flash-progress" - p, progressErr := a.flashProgress(ctx, endpoint) + p, progressErr := a.flashProgress(ctx, "api/asrr/maintenance/BIOS/flash-progress") if progressErr != nil { installed, versionErr := a.versionInstalled(ctx, devices.SlugBIOS, installVersion) if versionErr != nil { @@ -223,7 +214,6 @@ func (a *ASRockRack) versionInstalled(ctx context.Context, component, version st } if strings.EqualFold(installed, version) { - fmt.Println("YEP!") return true, nil } diff --git a/providers/asrockrack/helpers.go b/providers/asrockrack/helpers.go index 512c854a..4f00a5a5 100644 --- a/providers/asrockrack/helpers.go +++ b/providers/asrockrack/helpers.go @@ -138,9 +138,7 @@ var ( ) func (a *ASRockRack) listUsers(ctx context.Context) ([]*UserAccount, error) { - endpoint := "api/settings/users" - - resp, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + resp, statusCode, err := a.queryHTTPS(ctx, "api/settings/users", "GET", nil, nil, 0) if err != nil { return nil, err } @@ -184,9 +182,7 @@ func (a *ASRockRack) createUpdateUser(ctx context.Context, account *UserAccount) // at this point all logged in sessions are terminated // and no logins are permitted func (a *ASRockRack) setFlashMode(ctx context.Context) error { - endpoint := "api/maintenance/flash" - - _, statusCode, err := a.queryHTTPS(ctx, endpoint, "PUT", nil, nil, 0) + _, statusCode, err := a.queryHTTPS(ctx, "api/maintenance/flash", "PUT", nil, nil, 0) if err != nil { return err } @@ -262,9 +258,7 @@ func (a *ASRockRack) uploadFirmware(ctx context.Context, endpoint string, fwRead // 3. Verify uploaded firmware file - to be invoked after uploadFirmware() func (a *ASRockRack) verifyUploadedFirmware(ctx context.Context) error { - endpoint := "api/maintenance/firmware/verification" - - _, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + _, statusCode, err := a.queryHTTPS(ctx, "api/maintenance/firmware/verification", "GET", nil, nil, 0) if err != nil { return err } @@ -322,9 +316,7 @@ func (a *ASRockRack) flashProgress(ctx context.Context, endpoint string) (*upgra // Query firmware information from the BMC func (a *ASRockRack) firmwareInfo(ctx context.Context) (*firmwareInfo, error) { - endpoint := "api/asrr/fw-info" - - resp, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + resp, statusCode, err := a.queryHTTPS(ctx, "api/asrr/fw-info", "GET", nil, nil, 0) if err != nil { return nil, err } @@ -344,9 +336,7 @@ func (a *ASRockRack) firmwareInfo(ctx context.Context) (*firmwareInfo, error) { // Query BIOS/UEFI POST code information from the BMC func (a *ASRockRack) postCodeInfo(ctx context.Context) (*biosPOSTCode, error) { - endpoint := "/api/asrr/getbioscode" - - resp, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + resp, statusCode, err := a.queryHTTPS(ctx, "/api/asrr/getbioscode", "GET", nil, nil, 0) if err != nil { return nil, err } @@ -366,9 +356,7 @@ func (a *ASRockRack) postCodeInfo(ctx context.Context) (*biosPOSTCode, error) { // Query the inventory info endpoint func (a *ASRockRack) inventoryInfo(ctx context.Context) ([]*component, error) { - endpoint := "api/asrr/inventory_info" - - resp, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + resp, statusCode, err := a.queryHTTPS(ctx, "api/asrr/inventory_info", "GET", nil, nil, 0) if err != nil { return nil, err } @@ -388,9 +376,7 @@ func (a *ASRockRack) inventoryInfo(ctx context.Context) ([]*component, error) { // Query the fru info endpoint func (a *ASRockRack) fruInfo(ctx context.Context) ([]*fru, error) { - endpoint := "api/fru" - - resp, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + resp, statusCode, err := a.queryHTTPS(ctx, "api/fru", "GET", nil, nil, 0) if err != nil { return nil, err } @@ -436,9 +422,7 @@ func (a *ASRockRack) fruInfo(ctx context.Context) ([]*fru, error) { // Query the sensors endpoint func (a *ASRockRack) sensors(ctx context.Context) ([]*sensor, error) { - endpoint := "api/sensors" - - resp, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + resp, statusCode, err := a.queryHTTPS(ctx, "api/sensors", "GET", nil, nil, 0) if err != nil { return nil, err } @@ -519,9 +503,7 @@ func (a *ASRockRack) upgradeBIOS(ctx context.Context) error { // Returns the chassis status object which includes the power state func (a *ASRockRack) chassisStatusInfo(ctx context.Context) (*chassisStatus, error) { - endpoint := "/api/chassis-status" - - resp, statusCode, err := a.queryHTTPS(ctx, endpoint, "GET", nil, nil, 0) + resp, statusCode, err := a.queryHTTPS(ctx, "/api/chassis-status", "GET", nil, nil, 0) if err != nil { return nil, err } @@ -573,9 +555,7 @@ func (a *ASRockRack) httpsLogin(ctx context.Context) error { // Close ends the BMC session func (a *ASRockRack) httpsLogout(ctx context.Context) error { - urlEndpoint := "api/session" - - _, statusCode, err := a.queryHTTPS(ctx, urlEndpoint, "DELETE", nil, nil, 0) + _, statusCode, err := a.queryHTTPS(ctx, "api/session", "DELETE", nil, nil, 0) if err != nil { return fmt.Errorf("Error logging out: " + err.Error()) } diff --git a/providers/redfish/firmware.go b/providers/redfish/firmware.go index dced2b6a..e1098040 100644 --- a/providers/redfish/firmware.go +++ b/providers/redfish/firmware.go @@ -3,6 +3,7 @@ package redfish import ( "bytes" "context" + "encoding/json" "fmt" "io" "mime/multipart" @@ -20,16 +21,16 @@ import ( bmclibErrs "github.com/bmc-toolbox/bmclib/errors" ) -var ( - FirmwareApplyAt = []string{ +// SupportedFirmwareApplyAtValues returns the supported redfish firmware applyAt values +func SupportedFirmwareApplyAtValues() []string { + return []string{ devices.FirmwareApplyImmediate, devices.FirmwareApplyOnReset, } - FirmwareDownloadProtocols = []string{"HTTP", "NFS", "CIFS", "TFTP", "HTTPS"} -) +} // FirmwareInstall uploads and initiates the firmware install process -func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, forceInstall bool, reader io.Reader) (jobID string, err error) { +func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, forceInstall bool, reader io.Reader) (taskID string, err error) { // validate firmware update mechanism is supported err = c.firmwareUpdateCompatible(ctx) if err != nil { @@ -37,8 +38,8 @@ func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, f } // validate applyAt parameter - if !stringInSlice(applyAt, FirmwareApplyAt) { - return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, "invalid applyAt parameter: %s"+applyAt) + if !stringInSlice(applyAt, SupportedFirmwareApplyAtValues()) { + return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, "invalid applyAt parameter: "+applyAt) } // list redfish firmware install task if theres one present @@ -61,9 +62,19 @@ func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, f } } - updateParameters := []byte( - fmt.Sprintf(`{"Targets": [], "@Redfish.OperationApplyTime": "%s", "Oem": {}}`, applyAt), - ) + updateParameters, err := json.Marshal(struct { + Targets []string `json:"Targets"` + RedfishOpApplyTime string `json:"@Redfish.OperationApplyTime"` + Oem struct{} `json:"Oem"` + }{ + []string{}, + applyAt, + struct{}{}, + }) + + if err != nil { + return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error()) + } payload := map[string]io.Reader{ "UpdateParameters": bytes.NewReader(updateParameters), @@ -72,11 +83,11 @@ func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, f resp, err := c.runRequestWithMultipartPayload(http.MethodPost, "/redfish/v1/UpdateService/MultipartUpload", payload) if err != nil { - return jobID, errors.Wrap(bmclibErrs.ErrFirmwareUpload, err.Error()) + return "", errors.Wrap(bmclibErrs.ErrFirmwareUpload, err.Error()) } if resp.StatusCode != http.StatusAccepted { - return jobID, errors.Wrap( + return "", errors.Wrap( bmclibErrs.ErrFirmwareUpload, "non 202 status code returned: "+strconv.Itoa(resp.StatusCode), ) @@ -85,10 +96,10 @@ func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, f // The response contains a location header pointing to the task URI // Location: /redfish/v1/TaskService/Tasks/JID_467696020275 if strings.Contains(resp.Header.Get("Location"), "JID_") { - jobID = strings.Split(resp.Header.Get("Location"), "JID_")[1] + taskID = strings.Split(resp.Header.Get("Location"), "JID_")[1] } - return jobID, nil + return taskID, nil } // FirmwareInstallStatus returns the status of the firmware install task queued diff --git a/providers/redfish/firmware_test.go b/providers/redfish/firmware_test.go index 2074913a..6b35244c 100644 --- a/providers/redfish/firmware_test.go +++ b/providers/redfish/firmware_test.go @@ -2,10 +2,13 @@ package redfish import ( "context" + "fmt" + "io" "io/ioutil" "log" "net/http" "os" + "path/filepath" "strings" "testing" @@ -29,7 +32,7 @@ func multipartUpload(w http.ResponseWriter, r *http.Request) { expected := []string{ `Content-Disposition: form-data; name="UpdateParameters"`, `Content-Type: application/json`, - `{"Targets": [], "@Redfish.OperationApplyTime": "OnReset", "Oem": {}}`, + `{"Targets":[],"@Redfish.OperationApplyTime":"OnReset","Oem":{}}`, `Content-Disposition: form-data; name="UpdateFile"; filename="test.bin"`, `Content-Type: application/octet-stream`, `HELLOWORLD`, @@ -37,6 +40,7 @@ func multipartUpload(w http.ResponseWriter, r *http.Request) { for _, want := range expected { if !strings.Contains(string(body), want) { + fmt.Println(string(body)) log.Fatal("expected value not in multipartUpload payload: " + string(want)) } } @@ -45,30 +49,83 @@ func multipartUpload(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusAccepted) } -func Test_FirmwareUpload(t *testing.T) { +func Test_FirmwareInstall(t *testing.T) { // curl -Lv -s -k -u root:calvin \ // -F 'UpdateParameters={"Targets": [], "@Redfish.OperationApplyTime": "OnReset", "Oem": {}};type=application/json' \ // -F'foo.bin=@/tmp/dummyfile;application/octet-stream' // https://192.168.1.1/redfish/v1/UpdateService/MultipartUpload --trace-ascii /dev/stdout - err := ioutil.WriteFile("/tmp/test.bin", []byte(`HELLOWORLD`), 0600) + + tmpdir := t.TempDir() + binPath := filepath.Join(tmpdir, "test.bin") + err := os.WriteFile(binPath, []byte(`HELLOWORLD`), 0600) if err != nil { t.Fatal(err) } - fh, err := os.Open("/tmp/test.bin") + fh, err := os.Open(binPath) if err != nil { - t.Fatalf("%s -> %s", err.Error(), "/tmp/test.bin") + t.Fatalf("%s -> %s", err.Error(), binPath) } - _, err = mockClient.FirmwareInstall(context.TODO(), "", "invalid", false, fh) - assert.ErrorIs(t, err, bmclibErrs.ErrFirmwareInstall) + defer os.Remove(binPath) - jobID, err := mockClient.FirmwareInstall(context.TODO(), "", devices.FirmwareApplyOnReset, false, fh) - if err != nil { - t.Fatal("err in FirmwareUpload" + err.Error()) + tests := []struct { + component string + applyAt string + forceInstall bool + reader io.Reader + expectTaskID string + expectErr error + expectErrSubStr string + testName string + }{ + { + devices.SlugBIOS, + "invalidApplyAt", + false, + nil, + "", + bmclibErrs.ErrFirmwareInstall, + "invalid applyAt parameter", + "applyAt parameter invalid", + }, + { + devices.SlugBIOS, + devices.FirmwareApplyOnReset, + false, + fh, + "467696020275", + bmclibErrs.ErrFirmwareInstall, + "task for BIOS firmware install present", + "task ID exists", + }, + { + devices.SlugBIOS, + devices.FirmwareApplyOnReset, + true, + fh, + "467696020275", + nil, + "task for BIOS firmware install present", + "task created (previous task purged with force)", + }, + } + + for _, tc := range tests { + t.Run(tc.testName, func(t *testing.T) { + taskID, err := mockClient.FirmwareInstall(context.TODO(), tc.component, tc.applyAt, tc.forceInstall, tc.reader) + if tc.expectErr != nil { + assert.ErrorIs(t, err, tc.expectErr) + if tc.expectErrSubStr != "" { + assert.True(t, strings.Contains(err.Error(), tc.expectErrSubStr)) + } + } else { + assert.Nil(t, err) + assert.Equal(t, tc.expectTaskID, taskID) + } + }) } - assert.Equal(t, "467696020275", jobID) } func Test_firmwareUpdateCompatible(t *testing.T) { diff --git a/providers/redfish/inventory.go b/providers/redfish/inventory.go index d8e91bfa..6e3593d8 100644 --- a/providers/redfish/inventory.go +++ b/providers/redfish/inventory.go @@ -62,7 +62,7 @@ func (c *Conn) DeviceVendorModel(ctx context.Context) (vendor, model string, err return vendor, model, bmclibErrs.ErrRedfishSystemOdataID } -func (c *Conn) Inventory(ctx context.Context) (device *devices.Device, err error) { +func (c *Conn) GetInventory(ctx context.Context) (device *devices.Device, err error) { // initialize inventory object inv := &inventory{conn: c.conn} // TODO: this can soft fail @@ -408,7 +408,6 @@ func (i *inventory) collectBIOS(sys *redfish.ComputerSystem, device *devices.Dev return err } - //bios.Attributes.String("SystemCpldVersion") device.BIOS = &devices.BIOS{ Description: bios.Description, Firmware: &devices.Firmware{ @@ -492,9 +491,6 @@ func (i *inventory) collectStorageControllers(sys *redfish.ComputerSystem, devic Model: controller.PartNumber, Serial: controller.SerialNumber, SpeedGbps: int64(controller.SpeedGbps), - // SupportedControllerProtocols: join(controller.SupportedControllerProtocols), - // SupportedDeviceProtocols: join(controller.SupportedDeviceProtocols), - // SupportedRAIDTypes: join(controller.SupportedRAIDTypes), Status: &devices.Status{ Health: string(controller.Status.Health), State: string(controller.Status.State), diff --git a/providers/redfish/redfish_test.go b/providers/redfish/redfish_test.go index bcddd429..e7d9c81f 100644 --- a/providers/redfish/redfish_test.go +++ b/providers/redfish/redfish_test.go @@ -10,7 +10,7 @@ import ( "os" "testing" - "github.com/sirupsen/logrus" + "github.com/go-logr/logr" ) const ( @@ -70,8 +70,7 @@ func TestMain(m *testing.M) { log.Fatal(err) } - l := logrus.New() - l.Level = logrus.DebugLevel + mockClient.Log = logr.Discard() os.Exit(m.Run()) }