Skip to content

Commit

Permalink
Updated devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcburns committed Nov 30, 2023
1 parent d73562b commit ebab84a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mcr.microsoft.com/devcontainers/go:1-1.21-bullseye
RUN apt update
RUN apt install ipmitool -y

30 changes: 4 additions & 26 deletions bmc/sel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"time"

"github.com/bmc-toolbox/bmclib/v2/internal"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
)
Expand All @@ -22,13 +21,7 @@ type systemEventLogProviders struct {
systemEventLogProvider SystemEventLog
}

type SystemEventLogEntries []SystemEventLogEntry

type SystemEventLogEntry struct {
ID int32
Values []string
Raw string
}
type SystemEventLogEntries [][]string

func clearSystemEventLog(ctx context.Context, timeout time.Duration, s []systemEventLogProviders) (metadata Metadata, err error) {
var metadataLocal Metadata
Expand Down Expand Up @@ -80,7 +73,6 @@ func ClearSystemEventLogFromInterfaces(ctx context.Context, timeout time.Duratio
}

func getSystemEventLog(ctx context.Context, timeout time.Duration, s []systemEventLogProviders) (sel SystemEventLogEntries, metadata Metadata, err error) {
var selLocal SystemEventLogEntries
var metadataLocal Metadata

for _, elem := range s {
Expand All @@ -97,33 +89,19 @@ func getSystemEventLog(ctx context.Context, timeout time.Duration, s []systemEve
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

selRawEntries, selErr := elem.systemEventLogProvider.GetSystemEventLog(ctx)
sel, selErr := elem.systemEventLogProvider.GetSystemEventLog(ctx)
if selErr != nil {
err = multierror.Append(err, errors.WithMessagef(selErr, "provider: %v", elem.name))
continue
}

for i, v := range selRawEntries {

// In most cases, the first value is the ID, but not always
k, err := internal.ParseInt32(v[0])
if err != nil {
k = int32(i)
}

selLocal = append(selLocal, SystemEventLogEntry{
ID: k,
Values: v,
})
}

metadataLocal.SuccessfulProvider = elem.name
return selLocal, metadataLocal, nil
return sel, metadataLocal, nil
}

}

return selLocal, metadataLocal, multierror.Append(err, errors.New("failed to get System Event Log"))
return nil, metadataLocal, multierror.Append(err, errors.New("failed to get System Event Log"))
}

func GetSystemEventLogFromInterfaces(ctx context.Context, timeout time.Duration, generic []interface{}) (sel SystemEventLogEntries, metadata Metadata, err error) {
Expand Down
10 changes: 0 additions & 10 deletions internal/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package internal

import (
"fmt"
"unicode"
)

Expand All @@ -22,12 +21,3 @@ func StringInSlice(str string, sl []string) bool {
}
return false
}

func ParseInt32(i32 string) (int32, error) {
var i int32
_, err := fmt.Sscanf(i32, "%d", &i)
if err != nil {
return 0, err
}
return i, nil
}

0 comments on commit ebab84a

Please sign in to comment.