From 9e3a681a00e18c551394c9ef6fdc2db9bc32cc8c Mon Sep 17 00:00:00 2001 From: Pau Capdevila Date: Tue, 31 Dec 2024 10:09:53 +0100 Subject: [PATCH] remove soft-reset mode rename reload mode to reboot Signed-off-by: Pau Capdevila --- cmd/hhfab/main.go | 14 +++++++------- pkg/hhfab/vlabhelpers.go | 19 +++++-------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/cmd/hhfab/main.go b/cmd/hhfab/main.go index cfcaf66e..7f78e89f 100644 --- a/cmd/hhfab/main.go +++ b/cmd/hhfab/main.go @@ -873,16 +873,16 @@ func Run(ctx context.Context) error { }, &cli.StringFlag{ Name: "mode", - Usage: "restart mode: reload, soft-reset, or hard-reset", - Value: "reload", + Usage: "restart mode: reboot or hard-reset", + Value: "reboot", }, &cli.StringFlag{ Name: "username", - Usage: "required for reload mode (if empty, user is prompted)", + Usage: "required for reboot mode (if empty, user is prompted)", }, &cli.StringFlag{ Name: "password", - Usage: "required for reload mode (if empty, user is prompted)", + Usage: "required for reboot mode (if empty, user is prompted)", }, yesFlag, }, @@ -896,7 +896,7 @@ func Run(ctx context.Context) error { } mode := c.String("mode") - validModes := map[string]bool{"reload": true, "soft-reset": true, "hard-reset": true} + validModes := map[string]bool{"reboot": true, "hard-reset": true} if !validModes[mode] { return fmt.Errorf("invalid mode: %s", mode) //nolint:goerr113 } @@ -907,7 +907,7 @@ func Run(ctx context.Context) error { username := c.String("username") password := c.String("password") - if mode == "reload" && (username == "" || password == "") { + if mode == "reboot" && (username == "" || password == "") { fmt.Print("Enter username: ") if _, err := fmt.Scanln(&username); err != nil { return fmt.Errorf("failed to read username: %w", err) @@ -921,7 +921,7 @@ func Run(ctx context.Context) error { fmt.Println() if username == "" || password == "" { - return fmt.Errorf("credentials required for reload mode") //nolint:goerr113 + return fmt.Errorf("credentials required for reboot mode") //nolint:goerr113 } } diff --git a/pkg/hhfab/vlabhelpers.go b/pkg/hhfab/vlabhelpers.go index 4dea4ee4..14294cab 100644 --- a/pkg/hhfab/vlabhelpers.go +++ b/pkg/hhfab/vlabhelpers.go @@ -321,17 +321,16 @@ func (c *Config) SwitchReinstall(ctx context.Context, name, mode, user, password cmd.Stdin = os.Stdin var args []string - if mode == "reload" { + if mode == "reboot" { args = []string{sw.Name, user, password} } - if mode == "soft-reset" || mode == "hard-reset" { + if mode == "hard-reset" { args = []string{sw.Name} } if verbose { - _, err := exec.LookPath("byobu") - if err == nil { - // byobu exists, use it to run the command + if _, err := exec.LookPath("byobu"); err == nil && name == AllSwitches { + // use byobu to show progress in separate tabs byobuCmd := fmt.Sprintf("byobu new-window -d -n %s '%s %s'", sw.Name, cmdName, strings.Join(args, " ")) cmd = exec.CommandContext(ctx, "sh", "-c", byobuCmd) cmd.Stdout = os.Stdout @@ -371,14 +370,6 @@ func (c *Config) SwitchReinstall(ctx context.Context, name, mode, user, password _ = c.VLABPower(ctx, sw.Name, "CYCLE", pduConf) } } - - if mode == "soft-reset" { - for _, sw := range targets { - time.Sleep(1 * time.Second) - slog.Info("Executing soft-reset on", "switch", sw.Name+"...") - _ = hhfctl.SwitchPowerReset(ctx, sw.Name) - } - } wg.Wait() if len(errs) > 0 { @@ -459,7 +450,7 @@ func (c *Config) VLABPower(ctx context.Context, name string, action string, pduC continue } - slog.Info("Performing power", "action", action, "on switch", swName, "psu", psuName) + slog.Debug("Performing power", "action", action, "on switch", swName, "psu", psuName) if err := netio.ControlOutlet(ctx, pduIP, creds.User, creds.Password, outletID, action); err != nil { return fmt.Errorf("failed to power %s switch %s %s: %w", action, swName, psuName, err) }