diff --git a/pkg/hhfab/cmdvlab.go b/pkg/hhfab/cmdvlab.go index 21474e9c..cfa28427 100644 --- a/pkg/hhfab/cmdvlab.go +++ b/pkg/hhfab/cmdvlab.go @@ -170,10 +170,15 @@ func DoSwitchPower(ctx context.Context, workDir, cacheDir, name string, action s if err != nil { return fmt.Errorf("failed to load PDU config: %w", err) } + return c.VLABPower(ctx, name, action, pduConf) } -func DoSwitchReinstall(ctx context.Context, workDir, cacheDir, name string) error { +func DoSwitchReinstall(ctx context.Context, workDir, cacheDir, _ string) error { + _, _, err := loadVLABForHelpers(ctx, workDir, cacheDir) + if err != nil { + return err + } // TODO: Implement reinstall logic return nil } diff --git a/pkg/hhfab/vlabhelpers.go b/pkg/hhfab/vlabhelpers.go index 27d2cfef..48f64198 100644 --- a/pkg/hhfab/vlabhelpers.go +++ b/pkg/hhfab/vlabhelpers.go @@ -276,7 +276,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) - if err := netio.ControlOutlet(pduIP, creds.User, creds.Password, outletID, action); err != nil { + 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) } } diff --git a/pkg/pdu-mgt/netio/netio.go b/pkg/pdu-mgt/netio/netio.go index 4fb5c5d6..f5248e4a 100644 --- a/pkg/pdu-mgt/netio/netio.go +++ b/pkg/pdu-mgt/netio/netio.go @@ -76,13 +76,10 @@ func GetStatus(pduIP, username, password string) (*NetioResponse, error) { return &netioResp, nil } -func ControlOutlet(pduIP, username, password string, outletID int, action string) error { +func ControlOutlet(ctx context.Context, pduIP, username, password string, outletID int, action string) error { url := fmt.Sprintf("http://%s/netio.json", pduIP) data := fmt.Sprintf(`{"Outputs":[{"ID":%d,"Action":%d}]}`, outletID, actionMap[action]) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - req, err := http.NewRequestWithContext(ctx, "POST", url, strings.NewReader(data)) if err != nil { return fmt.Errorf("failed to create request: %w", err)