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

updateservice: add the StartUpdate target #286

Merged
merged 1 commit into from
Oct 12, 2023
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
10 changes: 10 additions & 0 deletions redfish/updateservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type UpdateService struct {
TransferProtocol []string
// UpdateServiceTarget indicates where theupdate image is to be applied.
UpdateServiceTarget string
// StartUpdateTarget is the endpoint which starts updating images that have been previously
// invoked using an OperationApplyTime value of OnStartUpdateRequest.
StartUpdateTarget string
// OemActions contains all the vendor specific actions. It is vendor responsibility to parse this field accordingly
OemActions json.RawMessage
// Oem shall contain the OEM extensions. All values for properties that
Expand All @@ -55,6 +58,12 @@ func (updateService *UpdateService) UnmarshalJSON(b []byte) error {
Target string
} `json:"#UpdateService.SimpleUpdate"`

// This action starts updating all images that have been previously
// invoked using an OperationApplyTime value of OnStartUpdateRequest.
StartUpdate struct {
Target string
} `json:"#UpdateService.StartUpdate"`

Oem json.RawMessage // OEM actions will be stored here
}
var t struct {
Expand All @@ -75,6 +84,7 @@ func (updateService *UpdateService) UnmarshalJSON(b []byte) error {
updateService.SoftwareInventory = t.SoftwareInventory.String()
updateService.TransferProtocol = t.Actions.SimpleUpdate.AllowableValues
updateService.UpdateServiceTarget = t.Actions.SimpleUpdate.Target
updateService.StartUpdateTarget = t.Actions.StartUpdate.Target
updateService.OemActions = t.Actions.Oem
updateService.rawData = b

Expand Down
51 changes: 51 additions & 0 deletions redfish/updateservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,54 @@ func TestUpdateService(t *testing.T) {
assertMessage(t, result.UpdateServiceTarget, "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate")
})
}

var startUpdateBody = `{
"@odata.type": "#UpdateService.v1_8_0.UpdateService",
"@odata.id": "/redfish/v1/UpdateService",
"Id": "UpdateService",
"Name": "Update Service",
"Description": "Service for updating firmware and includes inventory of firmware",
"Status": {
"State": "Enabled",
"Health": "OK",
"HealthRollup": "OK"
},
"ServiceEnabled": true,
"MultipartHttpPushUri": "/redfish/v1/UpdateService/upload",
"FirmwareInventory": {
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory"
},
"Actions": {
"Oem": {},
"#UpdateService.SimpleUpdate": {
"target": "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate",
"@Redfish.ActionInfo": "/redfish/v1/UpdateService/SimpleUpdateActionInfo"
},
"#UpdateService.StartUpdate": {
"target": "/redfish/v1/UpdateService/Actions/UpdateService.StartUpdate"
}
},
"Oem": {}
}
}`

func TestUpdateServiceStartUpdate(t *testing.T) {
var result UpdateService
assertMessage := func(t testing.TB, got string, want string) {
t.Helper()
if got != want {
t.Errorf("got %s, want %s", got, want)
}
}

t.Run("Check UpdateService.StartUpdate field", func(t *testing.T) {
c := &common.TestClient{}
result.SetClient(c)

err := json.NewDecoder(strings.NewReader(startUpdateBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertMessage(t, result.StartUpdateTarget, "/redfish/v1/UpdateService/Actions/UpdateService.StartUpdate")
})
}