Skip to content

Commit

Permalink
Get model name from fruAttibutes
Browse files Browse the repository at this point in the history
  • Loading branch information
ofaurax committed Oct 27, 2023
1 parent 844e950 commit c72e483
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions providers/asrockrack/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,32 @@ func (a *ASRockRack) FirmwareInstallStatus(ctx context.Context, installVersion,
func (a *ASRockRack) firmwareInstallBMC(ctx context.Context, reader io.Reader, fileSize int64) error {
var err error

// 0. take the model so that we use a different endpoint on E3C256D4ID-NL
device := common.NewDevice()
device.Metadata = map[string]string{}
err = a.fruAttributes(ctx, &device)
if err != nil {
a.log.V(2).WithValues("step", "0/4").Info("failed to get model, err: " + err.Error())
a.log.V(2).WithValues("step", "0/4").Info("continue with default endpoint")
}

// 1. set the device to flash mode - prepares the flash
// Beware: this locks some capabilities, e.g. the access to fruAttributes
a.log.V(2).WithValues("step", "1/4").Info("set device to flash mode, takes a minute...")
err = a.setFlashMode(ctx)
if err != nil {
return errors.Wrap(err, "failed in step 1/4 - set device to flash mode")
}

// 2. upload firmware image file
a.log.V(2).WithValues("step", "2/4").Info("upload BMC firmware image")
err = a.uploadFirmware(ctx, "api/maintenance/firmware", reader, fileSize)
fw_endpoint := "api/maintenance/firmware"
if device.Model == "E3C256D4ID-NL" {
fw_endpoint = "api/maintenance/firmware/firmware"
}
a.log.V(2).WithValues("step", "2/4").Info("upload BMC firmware image to " + fw_endpoint)
err = a.uploadFirmware(ctx, fw_endpoint, reader, fileSize)
if err != nil {
// Try the special URL for e3c256d4i
a.log.V(2).WithValues("step", "2/4").Info("Try alternate URL")
// Restart reader from start
_, _ = reader.(*os.File).Seek(0, io.SeekStart)
err2 := a.uploadFirmware(ctx, "api/maintenance/firmware/firmware", reader, fileSize)
if err2 != nil {
a.log.V(2).WithValues("step", "2/4").Info("Alternate URL err:" + err2.Error())
// if also in err, report first error
return errors.Wrap(err2, "failed in step 2/4 - upload BMC firmware image")
}
return errors.Wrap(err, "failed in step 2/4 - upload BMC firmware image")
}

// 3. BMC to verify the uploaded file
Expand Down

0 comments on commit c72e483

Please sign in to comment.