builder/vmware: Add a boot wait in seconds
This commit is contained in:
parent
009b509138
commit
429ff62128
|
@ -14,12 +14,13 @@ type Builder struct {
|
|||
}
|
||||
|
||||
type config struct {
|
||||
DiskName string `mapstructure:"vmdk_name"`
|
||||
ISOUrl string `mapstructure:"iso_url"`
|
||||
VMName string `mapstructure:"vm_name"`
|
||||
OutputDir string `mapstructure:"output_directory"`
|
||||
HTTPDir string `mapstructure:"http_directory"`
|
||||
DiskName string `mapstructure:"vmdk_name"`
|
||||
ISOUrl string `mapstructure:"iso_url"`
|
||||
VMName string `mapstructure:"vm_name"`
|
||||
OutputDir string `mapstructure:"output_directory"`
|
||||
HTTPDir string `mapstructure:"http_directory"`
|
||||
BootCommand []string `mapstructure:"boot_command"`
|
||||
BootWait uint `mapstructure:"boot_wait"`
|
||||
}
|
||||
|
||||
func (b *Builder) Prepare(raw interface{}) (err error) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
//
|
||||
// Produces:
|
||||
// http_port int - The port the HTTP server started on.
|
||||
type stepHTTPServer struct{
|
||||
type stepHTTPServer struct {
|
||||
l net.Listener
|
||||
}
|
||||
|
||||
|
|
|
@ -5,21 +5,24 @@ import (
|
|||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
// This step runs the created virtual machine.
|
||||
//
|
||||
// Uses:
|
||||
// config *config
|
||||
// ui packer.Ui
|
||||
// vmx_path string
|
||||
//
|
||||
// Produces:
|
||||
// <nothing>
|
||||
type stepRun struct{
|
||||
type stepRun struct {
|
||||
vmxPath string
|
||||
}
|
||||
|
||||
func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
|
||||
config := state["config"].(*config)
|
||||
ui := state["ui"].(packer.Ui)
|
||||
vmxPath := state["vmx_path"].(string)
|
||||
|
||||
|
@ -35,6 +38,12 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
|
|||
// Set the VMX path so that we know we started the machine
|
||||
s.vmxPath = vmxPath
|
||||
|
||||
// Wait the wait amount
|
||||
if config.BootWait > 0 {
|
||||
ui.Say(fmt.Sprintf("Waiting %d seconds for boot...", config.BootWait))
|
||||
time.Sleep(config.BootWait * time.Second)
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue