|
|
|
|
@ -3,11 +3,9 @@ package common
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"log"
|
|
|
|
|
"math/rand"
|
|
|
|
|
"net"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
|
|
|
"github.com/hashicorp/packer/packer"
|
|
|
|
|
@ -87,17 +85,9 @@ func (s *StepConfigureVNC) Run(_ context.Context, state multistep.StateBag) mult
|
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
vmxPath := state.Get("vmx_path").(string)
|
|
|
|
|
|
|
|
|
|
f, err := os.Open(vmxPath)
|
|
|
|
|
vmxData, err := ReadVMX(vmxPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
err := fmt.Errorf("Error reading VMX data: %s", err)
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
ui.Error(err.Error())
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vmxBytes, err := ioutil.ReadAll(f)
|
|
|
|
|
if err != nil {
|
|
|
|
|
err := fmt.Errorf("Error reading VMX data: %s", err)
|
|
|
|
|
err := fmt.Errorf("Error reading VMX file: %s", err)
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
ui.Error(err.Error())
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
@ -121,7 +111,6 @@ func (s *StepConfigureVNC) Run(_ context.Context, state multistep.StateBag) mult
|
|
|
|
|
|
|
|
|
|
log.Printf("Found available VNC port: %d", vncPort)
|
|
|
|
|
|
|
|
|
|
vmxData := ParseVMX(string(vmxBytes))
|
|
|
|
|
vncFinder.UpdateVMX(vncBindAddress, vncPassword, vncPort, vmxData)
|
|
|
|
|
|
|
|
|
|
if err := WriteVMX(vmxPath, vmxData); err != nil {
|
|
|
|
|
|