Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pau-hedgehog committed Dec 12, 2024
1 parent 78e215e commit 7617a54
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 6 additions & 1 deletion pkg/hhfab/cmdvlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion pkg/hhfab/vlabhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/pdu-mgt/netio/netio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7617a54

Please sign in to comment.