Commit 05962667 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/vmware: Add better logging

parent 5947d77f
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log"
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"net" "net"
...@@ -41,10 +42,12 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction { ...@@ -41,10 +42,12 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction {
// Find an open VNC port. Note that this can still fail later on // Find an open VNC port. Note that this can still fail later on
// because we have to release the port at some point. But this does its // because we have to release the port at some point. But this does its
// best. // best.
log.Printf("Looking for available port between %d and %d", config.VNCPortMin, config.VNCPortMax)
var vncPort uint var vncPort uint
portRange := int(config.VNCPortMax - config.VNCPortMin) portRange := int(config.VNCPortMax - config.VNCPortMin)
for { for {
vncPort = uint(rand.Intn(portRange) + portRange) vncPort = uint(rand.Intn(portRange) + portRange)
log.Printf("Trying port: %d", vncPort)
l, err := net.Listen("tcp", fmt.Sprintf(":%d", vncPort)) l, err := net.Listen("tcp", fmt.Sprintf(":%d", vncPort))
if err == nil { if err == nil {
defer l.Close() defer l.Close()
...@@ -52,6 +55,8 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction { ...@@ -52,6 +55,8 @@ func (stepConfigureVNC) Run(state map[string]interface{}) multistep.StepAction {
} }
} }
log.Printf("Found available VNC port: %d", vncPort)
vmxData := ParseVMX(string(vmxBytes)) vmxData := ParseVMX(string(vmxBytes))
vmxData["RemoteDisplay.vnc.enabled"] = "TRUE" vmxData["RemoteDisplay.vnc.enabled"] = "TRUE"
vmxData["RemoteDisplay.vnc.port"] = fmt.Sprintf("%d", vncPort) vmxData["RemoteDisplay.vnc.port"] = fmt.Sprintf("%d", vncPort)
......
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