Skip to content

Commit 7ad458e

Browse files
committed
cli: support additional endpoints for BMC dump
Signed-off-by: Lucas Bremgartner <lucas.bremgartner@futurfusion.io>
1 parent 80ebc3b commit 7ad458e

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

internal/cli/cmds/provisioning/server_bmc.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package provisioning
33
import (
44
"encoding/json"
55
"fmt"
6+
"os"
7+
"strings"
68

79
"github.com/spf13/cobra"
810

@@ -379,7 +381,9 @@ func (c *cmdServerBMCLogEntries) run(cmd *cobra.Command, args []string) error {
379381
type cmdServerBMCDump struct {
380382
ocClient *client.OperationsCenterClient
381383

382-
flagTrace bool
384+
flagEndpoints []string
385+
flagEndpointFile string
386+
flagTrace bool
383387
}
384388

385389
func (c *cmdServerBMCDump) Command() *cobra.Command {
@@ -394,6 +398,8 @@ func (c *cmdServerBMCDump) Command() *cobra.Command {
394398
instead of stopping the dump.
395399
`
396400

401+
cmd.Flags().StringSliceVar(&c.flagEndpoints, "endpoint", nil, "additional BMC endpoint(s) to dump alongside the predefined set")
402+
cmd.Flags().StringVar(&c.flagEndpointFile, "endpoint-file", "", "file with additional BMC endpoints to dump, one per line")
397403
cmd.Flags().BoolVar(&c.flagTrace, "trace", false, "include additional opaque trace information (e.g. HTTP headers)")
398404

399405
cmd.PreRunE = c.validateArgsAndFlags
@@ -415,7 +421,25 @@ func (c *cmdServerBMCDump) validateArgsAndFlags(cmd *cobra.Command, args []strin
415421
func (c *cmdServerBMCDump) run(cmd *cobra.Command, args []string) error {
416422
name := args[0]
417423

418-
dump, err := c.ocClient.GetServerBMCDump(cmd.Context(), name, c.flagTrace)
424+
endpoints := c.flagEndpoints
425+
426+
if c.flagEndpointFile != "" {
427+
content, err := os.ReadFile(c.flagEndpointFile)
428+
if err != nil {
429+
return fmt.Errorf("Failed to read endpoint file %q: %w", c.flagEndpointFile, err)
430+
}
431+
432+
for _, line := range strings.Split(string(content), "\n") {
433+
line = strings.TrimSpace(line)
434+
if line == "" || strings.HasPrefix(line, "#") {
435+
continue
436+
}
437+
438+
endpoints = append(endpoints, line)
439+
}
440+
}
441+
442+
dump, err := c.ocClient.GetServerBMCDump(cmd.Context(), name, endpoints, c.flagTrace)
419443
if err != nil {
420444
return err
421445
}

0 commit comments

Comments
 (0)