From eacae832ad7ec5e9f9bc8b5a3146365f49f20f8b Mon Sep 17 00:00:00 2001 From: notogawa Date: Mon, 11 Aug 2014 16:18:12 +0900 Subject: [PATCH] Fixes #1334, Add power on retry to ESXi Driver. --- builder/vmware/iso/driver_esx5.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/builder/vmware/iso/driver_esx5.go b/builder/vmware/iso/driver_esx5.go index c422e20c9..600990ff1 100644 --- a/builder/vmware/iso/driver_esx5.go +++ b/builder/vmware/iso/driver_esx5.go @@ -56,7 +56,21 @@ func (d *ESX5Driver) IsRunning(string) (bool, error) { } func (d *ESX5Driver) Start(vmxPathLocal string, headless bool) error { - return d.sh("vim-cmd", "vmsvc/power.on", d.vmId) + for i := 0; i < 20; i++ { + err := d.sh("vim-cmd", "vmsvc/power.on", d.vmId) + if err != nil { + return err + } + time.Sleep((time.Duration(i) * time.Second) + 1) + running, err := d.IsRunning(vmxPathLocal) + if err != nil { + return err + } + if running { + return nil + } + } + return errors.New("Retry limit exceeded") } func (d *ESX5Driver) Stop(vmxPathLocal string) error {