From 55882a65c721f91ef83913c76c1b05ac31eb2a13 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 16 Jul 2013 11:05:47 -0700 Subject: [PATCH] builder/vmware: error if guest IP is blank [GH-189] --- CHANGELOG.md | 1 + builder/vmware/guest_ip.go | 5 +++++ builder/vmware/ssh.go | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cab28e1c1..a9943dfd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ BUG FIXES: place. [GH-152] * virtualbox: "paused" doesn't mean the VM is stopped, improving shutdown detection. +* vmware: error if guest IP could not be detected. [GH-189] ## 0.1.5 (July 7, 2013) diff --git a/builder/vmware/guest_ip.go b/builder/vmware/guest_ip.go index e54d37d2e..5d1428e10 100644 --- a/builder/vmware/guest_ip.go +++ b/builder/vmware/guest_ip.go @@ -1,6 +1,7 @@ package vmware import ( + "errors" "fmt" "io/ioutil" "os" @@ -68,5 +69,9 @@ func (f *DHCPLeaseGuestLookup) GuestIP() (string, error) { } } + if curIp == "" { + return "", errors.New("IP not found for MAC in DHCP leases") + } + return curIp, nil } diff --git a/builder/vmware/ssh.go b/builder/vmware/ssh.go index 66d477e68..e2de12eb2 100644 --- a/builder/vmware/ssh.go +++ b/builder/vmware/ssh.go @@ -47,6 +47,11 @@ func sshAddress(state map[string]interface{}) (string, error) { return "", fmt.Errorf("IP lookup failed: %s", err) } + if ipAddress == "" { + log.Println("IP is blank, no IP yet.") + return "", errors.New("IP is blank") + } + log.Printf("Detected IP: %s", ipAddress) return fmt.Sprintf("%s:%d", ipAddress, config.SSHPort), nil }