Skip to content

Commit

Permalink
Streamline the IsOn() method
Browse files Browse the repository at this point in the history
This fixes the IsOn() method to return false if the host is powered off,
the previous implementation would return an error if the host is powered
off.
  • Loading branch information
Joel Rebello committed Apr 7, 2020
1 parent 529832c commit 290a963
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion providers/dell/idrac8/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ func (i *IDrac8) IsOn() (status bool, err error) {
if err != nil {
return false, fmt.Errorf("%v: %v", err, output)
}

if strings.Contains(output, "Server power status: ON") {
return true, err
return true, nil
}

if strings.Contains(output, "Server power status: OFF") {
return false, nil
}

return status, fmt.Errorf(output)
Expand Down
7 changes: 6 additions & 1 deletion providers/dell/idrac9/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ func (i *IDrac9) IsOn() (status bool, err error) {
if err != nil {
return false, fmt.Errorf("%v: %v", err, output)
}

if strings.Contains(output, "Server power status: ON") {
return true, err
return true, nil
}

if strings.Contains(output, "Server power status: OFF") {
return false, nil
}

return status, fmt.Errorf(output)
Expand Down
8 changes: 7 additions & 1 deletion providers/hp/ilo/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ func (i *Ilo) IsOn() (status bool, err error) {
if err != nil {
return false, fmt.Errorf("%v: %v", err, output)
}

if strings.Contains(output, "currently: On") {
return true, err
return true, nil
}

if strings.Contains(output, "currently: Off") {
return true, nil
}

return status, fmt.Errorf(output)
}

Expand Down

0 comments on commit 290a963

Please sign in to comment.