From 8689301d68daf63aeacdbef8a498da3dca7ca74e Mon Sep 17 00:00:00 2001 From: "Jason A. Beranek" Date: Tue, 16 Sep 2014 22:00:52 -0500 Subject: [PATCH 1/2] builder/vmware-esxi: Ignore localhost for VNC lookup [GH-1480] Adds logic to ESXi driver VNC Address function to ignore listen addresses that bind to localhost (127.0.0.1), this allows certain default ports to be available on ESXi for VNC connections --- builder/vmware/iso/driver_esx5.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/builder/vmware/iso/driver_esx5.go b/builder/vmware/iso/driver_esx5.go index 6f35f5272..e80a313b3 100644 --- a/builder/vmware/iso/driver_esx5.go +++ b/builder/vmware/iso/driver_esx5.go @@ -151,6 +151,8 @@ func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint, error) { var vncPort uint //Process ports ESXi is listening on to determine which are available + //This process does best effort to detect ports that are unavailable, + //it will ignore any ports listened to by only localhost r, err := d.esxcli("network", "ip", "connection", "list") if err != nil { err = fmt.Errorf("Could not retrieve network information for ESXi: %v", err) @@ -161,10 +163,11 @@ func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint, error) { for record, err := r.read(); record != nil && err == nil; record, err = r.read() { if record["State"] == "LISTEN" { splitAddress := strings.Split(record["LocalAddress"], ":") - log.Print(splitAddress) - port := splitAddress[len(splitAddress)-1] - log.Printf("ESXi Listening on: %s", port) - listenPorts[port] = true + if splitAddress[0] != "127.0.0.1" { + port := splitAddress[len(splitAddress)-1] + log.Printf("ESXi listening on address %s, port %s unavailable for VNC", record["LocalAddress"], port) + listenPorts[port] = true + } } } From 58a50e05130d480fc9539beac208d1ef2d3c161b Mon Sep 17 00:00:00 2001 From: "Jason A. Beranek" Date: Tue, 16 Sep 2014 22:16:22 -0500 Subject: [PATCH 2/2] website: document vmware-esxi VNC requirements --- website/source/docs/builders/vmware-iso.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/source/docs/builders/vmware-iso.html.markdown b/website/source/docs/builders/vmware-iso.html.markdown index aeb4c4335..73beea129 100644 --- a/website/source/docs/builders/vmware-iso.html.markdown +++ b/website/source/docs/builders/vmware-iso.html.markdown @@ -342,6 +342,11 @@ ISO and various files locally, and uploads these to the remote machine. Packer currently uses SSH to communicate to the ESXi machine rather than the vSphere API. At some point, the vSphere API may be used. +Packer also requires VNC to issue boot commands during a build, +which may be disabled on some remote VMware Hypervisors. Please consult +the appropriate documentation on how to update VMware Hypervisor's firewall +to allow these connections. + To use a remote VMware vSphere Hypervisor to build your virtual machine, fill in the required `remote_*` configurations: