Skip to content

Commit a890365

Browse files
Check power state before issuing power off for ipmi:
Some implementations of ipmi, Dell for example, will error out if a machine is already off and an ipmitool power off command is issued. Error is "Command not supported in present state". Checking the power state before issuing the power off command is also done in other ipmitool commands. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent a460d7e commit a890365

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)