Commit 5e4ffb56 authored by Jason A. Beranek's avatar Jason A. Beranek

Merge pull request #1505 from jasonberanek/issue-1480

builder/vmware-esx: Ignore localhost for VNC lookup and document VNC requirements [GH-1480]
parents a7122b3c 58a50e05
...@@ -151,6 +151,8 @@ func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint, error) { ...@@ -151,6 +151,8 @@ func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint, error) {
var vncPort uint var vncPort uint
//Process ports ESXi is listening on to determine which are available //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") r, err := d.esxcli("network", "ip", "connection", "list")
if err != nil { if err != nil {
err = fmt.Errorf("Could not retrieve network information for ESXi: %v", err) err = fmt.Errorf("Could not retrieve network information for ESXi: %v", err)
...@@ -161,12 +163,13 @@ func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint, error) { ...@@ -161,12 +163,13 @@ func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint, error) {
for record, err := r.read(); record != nil && err == nil; record, err = r.read() { for record, err := r.read(); record != nil && err == nil; record, err = r.read() {
if record["State"] == "LISTEN" { if record["State"] == "LISTEN" {
splitAddress := strings.Split(record["LocalAddress"], ":") splitAddress := strings.Split(record["LocalAddress"], ":")
log.Print(splitAddress) if splitAddress[0] != "127.0.0.1" {
port := splitAddress[len(splitAddress)-1] port := splitAddress[len(splitAddress)-1]
log.Printf("ESXi Listening on: %s", port) log.Printf("ESXi listening on address %s, port %s unavailable for VNC", record["LocalAddress"], port)
listenPorts[port] = true listenPorts[port] = true
} }
} }
}
for port := portMin; port <= portMax; port++ { for port := portMin; port <= portMax; port++ {
if _, ok := listenPorts[fmt.Sprintf("%d", port)]; ok { if _, ok := listenPorts[fmt.Sprintf("%d", port)]; ok {
......
...@@ -342,6 +342,11 @@ ISO and various files locally, and uploads these to the remote machine. ...@@ -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 Packer currently uses SSH to communicate to the ESXi machine rather than
the vSphere API. At some point, the vSphere API may be used. 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, To use a remote VMware vSphere Hypervisor to build your virtual machine,
fill in the required `remote_*` configurations: fill in the required `remote_*` configurations:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment