Make boot_wait interruptible

This commit is contained in:
Cheng Sun 2014-12-09 14:56:21 +00:00
parent ba7c5ddcd2
commit c75b4555cc

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"time"
) )
type stepBootWait struct{} type stepBootWait struct{}
@ -20,7 +19,11 @@ func (self *stepBootWait) Run(state multistep.StateBag) multistep.StepAction {
if int64(config.BootWait) > 0 { if int64(config.BootWait) > 0 {
ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait)) ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait))
time.Sleep(config.BootWait) err := InterruptibleWait{Timeout: config.BootWait}.Wait(state)
if err != nil {
ui.Error(err.Error())
return multistep.ActionHalt
}
} }
return multistep.ActionContinue return multistep.ActionContinue
} }