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

17 g update for bios #294

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions redfish/provider/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ func (p powerOperator) PowerOperation(resetType string, maximumWaitTime int64, c
tflog.Error(p.ctx, fmt.Sprintf("Failed to identify system: %s", err))
return "", fmt.Errorf("failed to identify system: %w", err)
}
system.Entity.SetETag("")

var targetPowerState redfish.PowerState

Expand Down
20 changes: 18 additions & 2 deletions redfish/provider/resource_redfish_bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,13 @@ func (r *BiosResource) updateRedfishDellBiosAttributes(ctx context.Context, serv
return nil, diags
}

attrsPayload, diagsAttr := getBiosAttrsToPatch(ctx, plan, attributes)
// check device is 17G or not
isGenerationSeventeenAndAbove, err := isServerGenerationSeventeenAndAbove(service)
if err != nil {
diags.AddError("Error retrieving the server generation", err.Error())
return nil, diags
}
attrsPayload, diagsAttr := getBiosAttrsToPatch(ctx, plan, attributes, isGenerationSeventeenAndAbove)
diags.Append(diagsAttr...)
if diags.HasError() {
return nil, diags
Expand Down Expand Up @@ -376,6 +382,11 @@ func (r *BiosResource) updateRedfishDellBiosAttributes(ctx context.Context, serv

tflog.Info(ctx, "rebooting the server completed successfully")
tflog.Info(ctx, "Waiting for the bios config job to finish")

// Below 17G device returns location as /redfish/v1/TaskService/Taks/JOB_ID for same GET call return status as 200 with all the job status.
// where as 17G device returns location as /redfish/v1/TaskService/TaskMonitors/JOB_ID for same GET call return no content hence
// we are replacing TaskMonitors to Taks.
biosTaskURI = strings.Replace(biosTaskURI, "TaskMonitors", "Tasks", 1)
// wait for the bios config job to finish
err = common.WaitForTaskToFinish(service, biosTaskURI, intervalBiosConfigJobCheckTime, biosConfigJobTimeout)
if err != nil {
Expand Down Expand Up @@ -455,13 +466,18 @@ func copyBiosAttributes(bios *redfish.Bios, attributes map[string]string) error
return nil
}

func getBiosAttrsToPatch(ctx context.Context, d *models.Bios, attributes map[string]string) (map[string]interface{}, diag.Diagnostics) {
// nolint: revive
func getBiosAttrsToPatch(ctx context.Context, d *models.Bios, attributes map[string]string, isSeventeenGen bool) (map[string]interface{}, diag.Diagnostics) {
var diags diag.Diagnostics
attrs := make(map[string]string)
attrsToPatch := make(map[string]interface{})
diags.Append(d.Attributes.ElementsAs(ctx, &attrs, true)...)

for key, newVal := range attrs {
if isSeventeenGen && strings.Contains(key, "AcPwrRcvry") {
diags.AddError(fmt.Sprintf("%s Configuration is not supported by 17G device", key), fmt.Sprintf("BIOS attribute %s not found", key))
continue
}
oldVal, ok := attributes[key]
if !ok {
diags.AddError("There was an issue while creating/updating bios attriutes", fmt.Sprintf("BIOS attribute %s not found", key))
Expand Down
Loading
Loading