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

feature: support pass apply time when set BIOS Attr #172

Merged
merged 1 commit into from
May 12, 2022
Merged
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
35 changes: 35 additions & 0 deletions redfish/bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,41 @@ func (bios *Bios) AllowedAttributeUpdateApplyTimes() []common.ApplyTime {
return bios.settingsApplyTimes
}

// UpdateBiosAttributesApplyAt is used to update attribute values and set apply time together
func (bios *Bios) UpdateBiosAttributesApplyAt(attrs BiosAttributes, applyTime common.ApplyTime) error {
payload := make(map[string]interface{})

// Get a representation of the object's original state so we can find what
// to update.
original := new(Bios)
err := original.UnmarshalJSON(bios.rawData)
if err != nil {
return err
}

for key := range attrs {
if original.Attributes[key] != attrs[key] {
payload[key] = attrs[key]
}
}

// If there are any allowed updates, try to send updates to the system and
// return the result.
if len(payload) > 0 {
data := map[string]interface{}{"Attributes": payload}
if applyTime != "" {
data["@Redfish.SettingsApplyTime"] = map[string]string{"ApplyTime": string(applyTime)}
}
resp, err := bios.Client.Patch(bios.settingsTarget, data)
if err != nil {
return err
}
defer resp.Body.Close()
}

return nil
}

// UpdateBiosAttributes is used to update attribute values.
func (bios *Bios) UpdateBiosAttributes(attrs BiosAttributes) error {
payload := make(map[string]interface{})
Expand Down