From 7ff781b25877fc1fa713d94918136e0fe61ecdec Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sat, 3 May 2014 00:25:58 +0900 Subject: [PATCH 1/2] Revert the way to retrieve vm ip in VMware ESXi Driver --- builder/vmware/iso/driver_esx5.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/builder/vmware/iso/driver_esx5.go b/builder/vmware/iso/driver_esx5.go index 8fbba7106..c99376a66 100644 --- a/builder/vmware/iso/driver_esx5.go +++ b/builder/vmware/iso/driver_esx5.go @@ -174,18 +174,35 @@ func (d *ESX5Driver) SSHAddress(state multistep.StateBag) (string, error) { return address.(string), nil } - r, err := d.run(nil, "vim-cmd", "vmsvc/get.guest", d.vmId, " | grep -m 1 ipAddress | awk -F'\"' '{print $2}'") + r, err := d.esxcli("network", "vm", "list") if err != nil { return "", err } - ipAddress := strings.TrimRight(r, "\n") + record, err := r.find("Name", config.VMName) + if err != nil { + return "", err + } + wid := record["WorldID"] + if wid == "" { + return "", errors.New("VM WorldID not found") + } + + r, err = d.esxcli("network", "vm", "port", "list", "-w", wid) + if err != nil { + return "", err + } + + record, err = r.read() + if err != nil { + return "", err + } - if ipAddress == "" { + if record["IPAddress"] == "0.0.0.0" { return "", errors.New("VM network port found, but no IP address") } - address := fmt.Sprintf("%s:%d", ipAddress, config.SSHPort) + address := fmt.Sprintf("%s:%d", record["IPAddress"], config.SSHPort) state.Put("vm_address", address) return address, nil } From c3257fd674177fd52cf35b986c98e7300149567f Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sat, 3 May 2014 00:27:42 +0900 Subject: [PATCH 2/2] website: Document that the Remote ESXi Driver supports ESXi 5.1 and above, and needs to enable GuestIPHack --- website/source/docs/builders/vmware-iso.html.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website/source/docs/builders/vmware-iso.html.markdown b/website/source/docs/builders/vmware-iso.html.markdown index 1276d2ead..ce3359140 100644 --- a/website/source/docs/builders/vmware-iso.html.markdown +++ b/website/source/docs/builders/vmware-iso.html.markdown @@ -323,6 +323,16 @@ In addition to using the desktop products of VMware locally to build virtual machines, Packer can use a remote VMware Hypervisor to build the virtual machine. +
+Note: Packer supports ESXi 5.1 and above. +
+ +Before using a remote vSphere Hypervisor, you need to enable GuestIPHack by running the following command: + +``` +esxcli system settings advanced set -o /Net/GuestIPHack -i 1 +``` + When using a remote VMware Hypervisor, the builder still downloads the ISO and various files locally, and uploads these to the remote machine. Packer currently uses SSH to communicate to the ESXi machine rather than