diff --git a/providers/asrockrack/firmware.go b/providers/asrockrack/firmware.go index 817f6273..24bd2973 100644 --- a/providers/asrockrack/firmware.go +++ b/providers/asrockrack/firmware.go @@ -24,6 +24,10 @@ const ( // bmc client interface implementations methods func (a *ASRockRack) FirmwareInstallSteps(ctx context.Context, component string) ([]constants.FirmwareInstallStep, error) { + if err := a.supported(ctx); err != nil { + return nil, bmclibErrs.NewErrUnsupportedHardware(err.Error()) + } + switch strings.ToUpper(component) { case common.SlugBMC: return []constants.FirmwareInstallStep{ diff --git a/providers/dell/firmware.go b/providers/dell/firmware.go index f311ea73..47ca86de 100644 --- a/providers/dell/firmware.go +++ b/providers/dell/firmware.go @@ -17,14 +17,10 @@ import ( "github.com/stmcginnis/gofish/redfish" ) -var ( - ErrUnsupportedHardware = errors.New("hardware not supported") -) - // bmc client interface implementations methods func (c *Conn) FirmwareInstallSteps(ctx context.Context, component string) ([]constants.FirmwareInstallStep, error) { if err := c.deviceSupported(ctx); err != nil { - return nil, errors.Wrap(ErrUnsupportedHardware, err.Error()) + return nil, bmcliberrs.NewErrUnsupportedHardware(err.Error()) } return []constants.FirmwareInstallStep{ @@ -35,7 +31,7 @@ func (c *Conn) FirmwareInstallSteps(ctx context.Context, component string) ([]co func (c *Conn) FirmwareInstallUploadAndInitiate(ctx context.Context, component string, file *os.File) (taskID string, err error) { if err := c.deviceSupported(ctx); err != nil { - return "", errors.Wrap(ErrUnsupportedHardware, err.Error()) + return "", bmcliberrs.NewErrUnsupportedHardware(err.Error()) } // // expect atleast 5 minutes left in the deadline to proceed with the upload @@ -102,7 +98,7 @@ func (c *Conn) checkQueueability(component string, tasks []*redfish.Task) error // FirmwareTaskStatus returns the status of a firmware related task queued on the BMC. func (c *Conn) FirmwareTaskStatus(ctx context.Context, kind constants.FirmwareInstallStep, component, taskID, installVersion string) (state constants.TaskState, status string, err error) { if err := c.deviceSupported(ctx); err != nil { - return "", "", errors.Wrap(ErrUnsupportedHardware, err.Error()) + return "", "", bmcliberrs.NewErrUnsupportedHardware(err.Error()) } // Dell jobs are turned into Redfish tasks on the idrac diff --git a/providers/supermicro/firmware.go b/providers/supermicro/firmware.go index e4a7c8ca..2deebd32 100644 --- a/providers/supermicro/firmware.go +++ b/providers/supermicro/firmware.go @@ -26,6 +26,7 @@ var ( "X11DPT-B", "X11SSE-F", "X12STH-SYS", + "X12SPO-NTF", } errUploadTaskIDExpected = errors.New("expected an firmware upload taskID") diff --git a/providers/supermicro/supermicro.go b/providers/supermicro/supermicro.go index ec22e08a..2ba88d33 100644 --- a/providers/supermicro/supermicro.go +++ b/providers/supermicro/supermicro.go @@ -160,18 +160,24 @@ func (c *Client) Open(ctx context.Context) (err error) { return errors.Wrap(bmclibErrs.ErrLoginFailed, strconv.Itoa(status)) } + // called after a session was opened but further login dependencies failed + closeWithError := func(ctx context.Context, err error) error { + _ = c.Close(ctx) + return err + } + if !bytes.Contains(body, []byte(`url_redirect.cgi?url_name=mainmenu`)) && !bytes.Contains(body, []byte(`url_redirect.cgi?url_name=topmenu`)) { - return errors.Wrap(bmclibErrs.ErrLoginFailed, "unexpected response contents") + return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, "unexpected response contents")) } contentsTopMenu, status, err := c.serviceClient.query(ctx, "cgi/url_redirect.cgi?url_name=topmenu", http.MethodGet, nil, nil, 0) if err != nil { - return errors.Wrap(bmclibErrs.ErrLoginFailed, err.Error()) + return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, err.Error())) } if status != 200 { - return errors.Wrap(bmclibErrs.ErrLoginFailed, strconv.Itoa(status)) + return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, strconv.Itoa(status))) } // Note: older firmware version on the X11s don't use a CSRF token @@ -183,11 +189,11 @@ func (c *Client) Open(ctx context.Context) (err error) { c.bmc, err = c.bmcQueryor(ctx) if err != nil { - return errors.Wrap(bmclibErrs.ErrLoginFailed, err.Error()) + return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, err.Error())) } if err := c.serviceClient.redfishSession(ctx); err != nil { - return errors.Wrap(bmclibErrs.ErrLoginFailed, err.Error()) + return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, err.Error())) } return nil @@ -257,7 +263,7 @@ func (c *Client) bmcQueryor(ctx context.Context) (bmcQueryor, error) { model := strings.ToLower(queryor.deviceModel()) if !strings.HasPrefix(model, "x12") && !strings.HasPrefix(model, "x11") { - return nil, errors.Wrap(ErrModelUnsupported, model) + return nil, errors.Wrap(ErrModelUnsupported, "expected one of X11* or X12*, got:"+model) } return queryor, nil