2014-11-10 12:16:02 -06:00
|
|
|
package xenserver
|
|
|
|
|
|
|
|
import (
|
2014-12-08 09:34:48 -06:00
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
2014-11-10 12:16:02 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
type stepBootWait struct{}
|
|
|
|
|
|
|
|
func (self *stepBootWait) Run(state multistep.StateBag) multistep.StepAction {
|
2014-12-08 09:34:48 -06:00
|
|
|
client := state.Get("client").(XenAPIClient)
|
|
|
|
config := state.Get("config").(config)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
|
|
|
instance, _ := client.GetVMByUuid(state.Get("instance_uuid").(string))
|
|
|
|
ui.Say("Unpausing VM " + state.Get("instance_uuid").(string))
|
|
|
|
instance.Unpause()
|
|
|
|
|
|
|
|
if int64(config.BootWait) > 0 {
|
|
|
|
ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait))
|
2014-12-09 08:56:21 -06:00
|
|
|
err := InterruptibleWait{Timeout: config.BootWait}.Wait(state)
|
|
|
|
if err != nil {
|
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
2014-12-08 09:34:48 -06:00
|
|
|
}
|
|
|
|
return multistep.ActionContinue
|
2014-11-10 12:16:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *stepBootWait) Cleanup(state multistep.StateBag) {}
|