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 { ...@@ -14,12 +14,13 @@ type Builder struct {
} }
type config struct { type config struct {
DiskName string `mapstructure:"vmdk_name"` DiskName string `mapstructure:"vmdk_name"`
ISOUrl string `mapstructure:"iso_url"` ISOUrl string `mapstructure:"iso_url"`
VMName string `mapstructure:"vm_name"` VMName string `mapstructure:"vm_name"`
OutputDir string `mapstructure:"output_directory"` OutputDir string `mapstructure:"output_directory"`
HTTPDir string `mapstructure:"http_directory"` HTTPDir string `mapstructure:"http_directory"`
BootCommand []string `mapstructure:"boot_command"` BootCommand []string `mapstructure:"boot_command"`
BootWait uint `mapstructure:"boot_wait"`
} }
func (b *Builder) Prepare(raw interface{}) (err error) { func (b *Builder) Prepare(raw interface{}) (err error) {
......
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
// //
// Produces: // Produces:
// http_port int - The port the HTTP server started on. // http_port int - The port the HTTP server started on.
type stepHTTPServer struct{ type stepHTTPServer struct {
l net.Listener l net.Listener
} }
......
...@@ -5,21 +5,24 @@ import ( ...@@ -5,21 +5,24 @@ import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"os/exec" "os/exec"
"time"
) )
// This step runs the created virtual machine. // This step runs the created virtual machine.
// //
// Uses: // Uses:
// config *config
// ui packer.Ui // ui packer.Ui
// vmx_path string // vmx_path string
// //
// Produces: // Produces:
// <nothing> // <nothing>
type stepRun struct{ type stepRun struct {
vmxPath string vmxPath string
} }
func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction { func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
config := state["config"].(*config)
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
vmxPath := state["vmx_path"].(string) vmxPath := state["vmx_path"].(string)
...@@ -35,6 +38,12 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction { ...@@ -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 // Set the VMX path so that we know we started the machine
s.vmxPath = vmxPath 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 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