From 47a56e1435c5003f2cdb77b4374c5e83edb62154 Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Thu, 12 Oct 2023 12:19:05 +0200 Subject: [PATCH] updateservice/StartUpdate: adds the StartUpdate target (#286) as defined in the spec, https://www.dmtf.org/sites/default/files/standards/documents/DSP0268_2023.1.html#updateservice-1113 --- redfish/updateservice.go | 10 +++++++ redfish/updateservice_test.go | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/redfish/updateservice.go b/redfish/updateservice.go index ee4dd24d..b63527e1 100644 --- a/redfish/updateservice.go +++ b/redfish/updateservice.go @@ -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 @@ -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 { @@ -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 diff --git a/redfish/updateservice_test.go b/redfish/updateservice_test.go index d91129cc..d2ea9782 100644 --- a/redfish/updateservice_test.go +++ b/redfish/updateservice_test.go @@ -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") + }) +}