Commit 429ff621 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/vmware: Add a boot wait in seconds

parent 009b5091
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment