diff --git a/providers/redfish/firmware.go b/providers/redfish/firmware.go index 25b75e6a..22ac4b52 100644 --- a/providers/redfish/firmware.go +++ b/providers/redfish/firmware.go @@ -62,26 +62,25 @@ func (c *Conn) FirmwareInstall(ctx context.Context, component, applyAt string, f return "", errors.Wrap(errInsufficientCtxTimeout, " "+time.Until(ctxDeadline).String()) } - // TODO; uncomment once obmc support is implemented for tasks // list redfish firmware install task if theres one present - // task, err := c.GetFirmwareInstallTaskQueued(ctx, component) - // if err != nil { - // return "", err - // } - // - // if task != nil { - // msg := fmt.Sprintf("task for %s firmware install present: %s", component, task.ID) - // c.Log.V(2).Info("warn", msg) - // - // if forceInstall { - // err = c.purgeQueuedFirmwareInstallTask(ctx, component) - // if err != nil { - // return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error()) - // } - // } else { - // return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, msg) - // } - // } + task, err := c.GetFirmwareInstallTaskQueued(ctx, component) + if err != nil { + return "", err + } + + if task != nil { + msg := fmt.Sprintf("task for %s firmware install present: %s", component, task.ID) + c.Log.V(2).Info("warn", msg) + + if forceInstall { + err = c.purgeQueuedFirmwareInstallTask(ctx, component) + if err != nil { + return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, err.Error()) + } + } else { + return "", errors.Wrap(bmclibErrs.ErrFirmwareInstall, msg) + } + } // override the gofish HTTP client timeout, // since the context timeout is set at Open() and is at a lower value than required for this operation. diff --git a/providers/redfish/firmware_test.go b/providers/redfish/firmware_test.go index db12a501..2550330e 100644 --- a/providers/redfish/firmware_test.go +++ b/providers/redfish/firmware_test.go @@ -112,17 +112,17 @@ func TestFirmwareInstall(t *testing.T) { "invalid applyAt parameter", "applyAt parameter invalid", }, - //{ - // common.SlugBIOS, - // constants.FirmwareApplyOnReset, - // false, - // true, - // fh, - // "467696020275", - // bmclibErrs.ErrFirmwareInstall, - // "task for BIOS firmware install present", - // "task ID exists", - //}, + { + common.SlugBIOS, + constants.FirmwareApplyOnReset, + false, + true, + fh, + "467696020275", + bmclibErrs.ErrFirmwareInstall, + "task for BIOS firmware install present", + "task ID exists", + }, { common.SlugBIOS, constants.FirmwareApplyOnReset, diff --git a/providers/redfish/tasks.go b/providers/redfish/tasks.go index 4a5390bb..02b7dcae 100644 --- a/providers/redfish/tasks.go +++ b/providers/redfish/tasks.go @@ -43,6 +43,7 @@ func (c *Conn) GetFirmwareInstallTaskQueued(ctx context.Context, component strin case strings.Contains(vendor, constants.Dell): task, err = c.getDellFirmwareInstallTaskScheduled(component) default: + // TODO: correctly get an update task if there is one, using redfish API //task, err = c.redfishwrapper.Tasks(ctx) }