diff --git a/svc-aggregation/system/addcompute.go b/svc-aggregation/system/addcompute.go index 017ac87e1..d55e14315 100644 --- a/svc-aggregation/system/addcompute.go +++ b/svc-aggregation/system/addcompute.go @@ -117,6 +117,20 @@ func (e *ExternalInterface) addCompute(ctx context.Context, taskID, targetURI, p "Password": saveSystem.Password, } + // This call will patch the EventService in order to set ServiceEnabled property true + // this property should be enabled to get the events + pluginContactRequest.DeviceInfo = getSystemBody + pluginContactRequest.OID = "/redfish/v1/EventService" + pluginContactRequest.DeviceUUID = saveSystem.DeviceUUID + pluginContactRequest.HTTPMethodType = http.MethodPatch + + body, _, getResponse, err = contactPlugin(ctx, pluginContactRequest, "error while trying to enable event service") + if getResponse.StatusCode != http.StatusOK && getResponse.StatusCode != http.StatusNotFound { + errMsg := fmt.Sprintf("error while trying to enable event service. got the status code: %v %v", getResponse.StatusCode, err) + l.LogWithFields(ctx).Error(errMsg) + return common.GeneralError(getResponse.StatusCode, getResponse.StatusMessage, errMsg, getResponse.MsgArgs, taskInfo), "", nil + } + //Discover Systems collection this will be moved to a function later if needed pluginContactRequest.DeviceInfo = getSystemBody pluginContactRequest.OID = "/redfish/v1/Systems" diff --git a/svc-aggregation/system/addcompute_test.go b/svc-aggregation/system/addcompute_test.go index f5908dfe4..e118e33d5 100644 --- a/svc-aggregation/system/addcompute_test.go +++ b/svc-aggregation/system/addcompute_test.go @@ -211,7 +211,8 @@ func mockContactClientForDuplicate(ctx context.Context, url, method, token strin Body: ioutil.NopCloser(bytes.NewBufferString(body)), }, nil - } else if strings.Contains(url, "/ODIM/v1/validate") || url == "https://localhost:9091/ODIM/v1/Sessions" || url == host+"/ODIM/v1/Sessions" { + } else if strings.Contains(url, "/ODIM/v1/validate") || url == "https://localhost:9091/ODIM/v1/Sessions" || + url == host+"/ODIM/v1/Sessions" || url == host+"/ODIM/v1/EventService" { body := `{"MessageId": "` + response.Success + `"}` if bData.UserName == "incorrectusername" || bytes.Compare(bData.Password, []byte("incorrectPassword")) == 0 { return &http.Response{ diff --git a/svc-aggregation/system/reset_test.go b/svc-aggregation/system/reset_test.go index ad785c37e..cd3d4753d 100644 --- a/svc-aggregation/system/reset_test.go +++ b/svc-aggregation/system/reset_test.go @@ -276,6 +276,13 @@ func mockContactClient(ctx context.Context, url, method, token string, odataID s StatusCode: http.StatusOK, Body: ioutil.NopCloser(bytes.NewBufferString(body)), }, nil + } else if url == host+"/ODIM/v1/EventService" { + body := `{"MessageId": "` + response.Success + `"}` + return &http.Response{ + StatusCode: http.StatusOK, + Body: ioutil.NopCloser(bytes.NewBufferString(body)), + }, nil + } else if strings.Contains(url, "/ODIM/v1/Registries") { return &http.Response{ StatusCode: http.StatusNotFound,