Skip to content

Commit 80c6fe5

Browse files
authored
Check power state before issuing power off for ipmi: (#417)
2 parents a460d7e + a890365 commit 80c6fe5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/ipmi/ipmi.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ func (i *Ipmi) PowerOnForce(ctx context.Context) (status bool, err error) {
247247

248248
// PowerOff power off the machine via bmc
249249
func (i *Ipmi) PowerOff(ctx context.Context) (status bool, err error) {
250+
if on, err := i.IsOn(ctx); err == nil && !on {
251+
return true, nil
252+
}
250253
output, err := i.run(ctx, []string{"chassis", "power", "off"})
251254
if strings.Contains(output, "Chassis Power Control: Down/Off") {
252255
return true, err

0 commit comments

Comments
 (0)