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

Handle LogService v1.3.0 ClearLog payload #346

Merged
merged 1 commit into from
May 23, 2024
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
24 changes: 24 additions & 0 deletions redfish/logservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"strings"

"github.com/stmcginnis/gofish/common"
)
Expand Down Expand Up @@ -241,6 +242,29 @@ func (logservice *LogService) FilteredEntries(options ...common.FilterOption) ([
// ClearLog shall delete all entries found in the Entries collection for this
// Log Service.
func (logservice *LogService) ClearLog() error {
err := logservice.Post(logservice.clearLogTarget, struct{}{})
if err == nil {
return nil
}

// As of LogService 1.3.0, need to pass the LogEntryCollection etag. If our first attempt failed, try that.
entryCollection := &struct {
ETag string `json:"@odata.etag"`
}{}

retryErr := logservice.Get(logservice.GetClient(), logservice.entries, entryCollection)
if retryErr == nil {
payload := struct {
LogEntriesETag string
}{LogEntriesETag: strings.Trim(entryCollection.ETag, "\"")}

retryErr = logservice.Post(logservice.clearLogTarget, payload)
if retryErr == nil {
return nil
}
}

// Fall back to broken implementation to workaround vendor bug
t := struct {
Action string
}{
Expand Down