From 39eb9b74976f6b985ebe55de01bdbbf71c4a7aea Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 23 Jun 2013 18:17:38 -0700 Subject: [PATCH] builder/vmware: Try SSH handshake multiple times --- builder/vmware/step_wait_for_ssh.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/builder/vmware/step_wait_for_ssh.go b/builder/vmware/step_wait_for_ssh.go index f3a8d1916..b0551ccf1 100644 --- a/builder/vmware/step_wait_for_ssh.go +++ b/builder/vmware/step_wait_for_ssh.go @@ -113,6 +113,8 @@ func (s *stepWaitForSSH) waitForSSH(state map[string]interface{}) (packer.Commun ui := state["ui"].(packer.Ui) vmxPath := state["vmx_path"].(string) + handshakeAttempts := 0 + ui.Say("Waiting for SSH to become available...") var comm packer.Communicator var nc net.Conn @@ -160,6 +162,14 @@ func (s *stepWaitForSSH) waitForSSH(state map[string]interface{}) (packer.Commun comm, err = ssh.New(nc, sshConfig) if err != nil { + log.Printf("SSH handshake err: %s", err) + + handshakeAttempts += 1 + if handshakeAttempts < 10 { + // Try to connect via SSH a handful of times + continue + } + return nil, err }