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

SEL capture support #151

Closed
wants to merge 3 commits into from
Closed
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
25 changes: 0 additions & 25 deletions .devcontainer/devcontainer.json

This file was deleted.

474 changes: 439 additions & 35 deletions api/v1/diagnostic.pb.go

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion api/v1/diagnostic.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import "api/v1/common.proto";
service Diagnostic {
rpc Screenshot (ScreenshotRequest) returns (ScreenshotResponse);
rpc ClearSystemEventLog (ClearSystemEventLogRequest) returns (ClearSystemEventLogResponse);
rpc SystemEventLog (SystemEventLogRequest) returns (SystemEventLogResponse);
rpc SystemEventLogRaw (SystemEventLogRawRequest) returns (SystemEventLogRawResponse);
}

message ScreenshotRequest {
Expand All @@ -29,4 +31,29 @@ message ClearSystemEventLogRequest {

message ClearSystemEventLogResponse {
string task_id = 1;
}
}

message SystemEventLogRequest {
v1.Authn authn = 1;
v1.Vendor vendor = 2;
}

message SystemEventLogEntry {
string id = 1;
string timestamp = 2;
string description = 3;
string message = 4;
}

message SystemEventLogResponse {
repeated SystemEventLogEntry events = 1;
}

message SystemEventLogRawRequest {
v1.Authn authn = 1;
v1.Vendor vendor = 2;
}

message SystemEventLogRawResponse {
string log = 1;
}
42 changes: 42 additions & 0 deletions api/v1/diagnostic.validator.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions api/v1/diagnostic_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,13 @@ func ClearSystemEventLog(ctx context.Context, client v1.DiagnosticClient, taskCl
}
return statusResp, nil
}

// SystemEventLog retrieves the System Event Log of the server.
func SystemEventLog(ctx context.Context, client v1.DiagnosticClient, request *v1.SystemEventLogRequest) (*v1.SystemEventLogResponse, error) {
return client.SystemEventLog(ctx, request)
}

// SystemEventLogRaw retrieves the System Event Log of the server.
func SystemEventLogRaw(ctx context.Context, client v1.DiagnosticClient, request *v1.SystemEventLogRawRequest) (*v1.SystemEventLogRawResponse, error) {
return client.SystemEventLogRaw(ctx, request)
}
92 changes: 92 additions & 0 deletions cmd/sel.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,100 @@ var (
logger.Info("resp", "resp", []interface{}{resp})
},
}

getSystemEventLogcommand = &cobra.Command{
Use: "selget",
Short: "Get the System Event Log",
Long: `Get the System Event Log of the target BMC.
Includes the following information:
ID, Timestamp, Description, Message`,
Run: func(cmd *cobra.Command, args []string) {
var opts []grpc.DialOption
ctx := context.Background()

logger := defaultLogger(logLevel)

opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.Dial("localhost:"+port, opts...)
if err != nil {
logger.Error(err, "fail to dial server")
os.Exit(1)
}
defer conn.Close()
client := v1.NewDiagnosticClient(conn)

resp, err := v1Client.SystemEventLog(ctx, client, &v1.SystemEventLogRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Host: &v1.Host{
Host: bmcaddress,
},
Username: bmcuser,
Password: bmcpass,
},
},
},
Vendor: &v1.Vendor{
Name: bmcvendor,
},
})
if err != nil {
logger.Error(err, "error calling")
os.Exit(1)
}

logger.Info("resp", "resp", []interface{}{resp})
},
}

getSystemEventLogRawcommand = &cobra.Command{
Use: "selgetraw",
Short: "Get the Raw System Event Log",
Long: `Get the Raw System Event Log of the target BMC`,
Run: func(cmd *cobra.Command, args []string) {
var opts []grpc.DialOption
ctx := context.Background()

logger := defaultLogger(logLevel)

opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.Dial("localhost:"+port, opts...)
if err != nil {
logger.Error(err, "fail to dial server")
os.Exit(1)
}
defer conn.Close()
client := v1.NewDiagnosticClient(conn)

resp, err := v1Client.SystemEventLogRaw(ctx, client, &v1.SystemEventLogRawRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Host: &v1.Host{
Host: bmcaddress,
},
Username: bmcuser,
Password: bmcpass,
},
},
},
Vendor: &v1.Vendor{
Name: bmcvendor,
},
})
if err != nil {
logger.Error(err, "error calling")
os.Exit(1)
}

logger.Info("resp", "resp", []interface{}{resp})
},
}
)

func init() {
diagnosticCmd.AddCommand(clearSystemEventLogcommand)
diagnosticCmd.AddCommand(getSystemEventLogcommand)
diagnosticCmd.AddCommand(getSystemEventLogRawcommand)
}
Loading
Loading