From cd7d3812ea2d23a0e7ae63ef72bd1c943fb7d21d Mon Sep 17 00:00:00 2001 From: DanHam Date: Mon, 2 Jul 2018 13:19:41 +0100 Subject: [PATCH] ESXi: Fix failure to get VM IP when `displayName` differs from `vm_name` The value in the Name field returned by 'esxcli network vm list' actually returns the VMs `displayName`. As such, we need to match against `displayName` to discover the VMs 'WorldID'. 'WorldId' is ultimately used/needed as an argument in the command that returns the VMs IP. --- builder/vmware/iso/driver_esx5.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builder/vmware/iso/driver_esx5.go b/builder/vmware/iso/driver_esx5.go index b3eb8c078..bfeee8d24 100644 --- a/builder/vmware/iso/driver_esx5.go +++ b/builder/vmware/iso/driver_esx5.go @@ -389,7 +389,13 @@ func (d *ESX5Driver) CommHost(state multistep.StateBag) (string, error) { return "", err } - record, err := r.find("Name", config.VMName) + // The value in the Name field returned by 'esxcli network vm list' + // corresponds directly to the value of displayName set in the VMX file + var displayName string + if v, ok := state.GetOk("display_name"); ok { + displayName = v.(string) + } + record, err := r.find("Name", displayName) if err != nil { return "", err }