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

enable event service in case if the property set to false while adding server #51

Merged
merged 2 commits into from
Jun 20, 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
14 changes: 14 additions & 0 deletions svc-aggregation/system/addcompute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion svc-aggregation/system/addcompute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
7 changes: 7 additions & 0 deletions svc-aggregation/system/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down