Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e3c256d4i support #357

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
asrock: Add tests
ofaurax committed Oct 30, 2023
commit e63714c6a454eb7114ef85edc1294bda4b8adb42
3 changes: 2 additions & 1 deletion providers/asrockrack/mock_test.go
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ func mockASRockBMC() *httptest.Server {
// fw update endpoints - in order of invocation
handler.HandleFunc("/api/maintenance/flash", bmcFirmwareUpgrade)
handler.HandleFunc("/api/maintenance/firmware", bmcFirmwareUpgrade)
handler.HandleFunc("/api/maintenance/firmware/firmware", bmcFirmwareUpgrade)
handler.HandleFunc("/api/maintenance/firmware/verification", bmcFirmwareUpgrade)
handler.HandleFunc("/api/maintenance/firmware/upgrade", bmcFirmwareUpgrade)
handler.HandleFunc("/api/maintenance/firmware/flash-progress", bmcFirmwareUpgrade)
@@ -211,7 +212,7 @@ func bmcFirmwareUpgrade(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)

// 2. upload firmware
case "/api/maintenance/firmware":
case "/api/maintenance/firmware", "/api/maintenance/firmware/firmware":

// validate flash mode set
if !fwUpgradeState.FlashModeSet {

Unchanged files with check annotations Beta

device.Metadata = map[string]string{}
err = a.fruAttributes(ctx, &device)
if err != nil {
return errors.Wrap(err, "failed to get model in step 0/4")

Check warning on line 71 in providers/asrockrack/firmware.go

Codecov / codecov/patch

providers/asrockrack/firmware.go#L71

Added line #L71 was not covered by tests
}
// 1. set the device to flash mode - prepares the flash
fwEndpoint := "api/maintenance/firmware"
// E3C256D4ID-NL calls a different endpoint for firmware upload
if strings.EqualFold(device.Model, "E3C256D4ID-NL") {
fwEndpoint = "api/maintenance/firmware/firmware"

Check warning on line 86 in providers/asrockrack/firmware.go

Codecov / codecov/patch

providers/asrockrack/firmware.go#L86

Added line #L86 was not covered by tests
}
a.log.V(2).WithValues("step", "2/4").Info("upload BMC firmware image to " + fwEndpoint)
err = a.uploadFirmware(ctx, fwEndpoint, reader, fileSize)
switch progress.State {
case 0:
return constants.FirmwareInstallRunning, nil
case 1: // "Flashing To be done"
return constants.FirmwareInstallQueued, nil

Check warning on line 164 in providers/asrockrack/firmware.go

Codecov / codecov/patch

providers/asrockrack/firmware.go#L163-L164

Added lines #L163 - L164 were not covered by tests
case 2:
return constants.FirmwareInstallComplete, nil
default:
pConfig := &preserveConfig{}
// preserve config is needed by e3c256d4i
if strings.EqualFold(device.Model, "E3C256D4ID-NL") {
pConfig = &preserveConfig{PreserveConfig: 1}

Check warning on line 193 in providers/asrockrack/helpers.go

Codecov / codecov/patch

providers/asrockrack/helpers.go#L193

Added line #L193 was not covered by tests
}
payload, err := json.Marshal(pConfig)
if err != nil {
return err

Check warning on line 198 in providers/asrockrack/helpers.go

Codecov / codecov/patch

providers/asrockrack/helpers.go#L198

Added line #L198 was not covered by tests
}
headers := map[string]string{"Content-Type": "application/json"}