commit
96bbf964f6
|
@ -3,9 +3,7 @@ package common
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
commonssh "github.com/hashicorp/packer/common/ssh"
|
commonssh "github.com/hashicorp/packer/common/ssh"
|
||||||
"github.com/hashicorp/packer/communicator/ssh"
|
"github.com/hashicorp/packer/communicator/ssh"
|
||||||
|
@ -23,18 +21,11 @@ func CommHost(config *SSHConfig) func(multistep.StateBag) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Lookup up IP information...")
|
log.Println("Lookup up IP information...")
|
||||||
f, err := os.Open(vmxPath)
|
|
||||||
|
vmxData, err := ReadVMX(vmxPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
vmxBytes, err := ioutil.ReadAll(f)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
vmxData := ParseVMX(string(vmxBytes))
|
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
macAddress := ""
|
macAddress := ""
|
||||||
|
|
|
@ -3,7 +3,6 @@ package common
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -26,7 +25,7 @@ func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) mult
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
vmxPath := state.Get("vmx_path").(string)
|
vmxPath := state.Get("vmx_path").(string)
|
||||||
|
|
||||||
vmxContents, err := ioutil.ReadFile(vmxPath)
|
vmxData, err := ReadVMX(vmxPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error reading VMX file: %s", err)
|
err := fmt.Errorf("Error reading VMX file: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -34,8 +33,6 @@ func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) mult
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
vmxData := ParseVMX(string(vmxContents))
|
|
||||||
|
|
||||||
// Set this so that no dialogs ever appear from Packer.
|
// Set this so that no dialogs ever appear from Packer.
|
||||||
vmxData["msg.autoanswer"] = "true"
|
vmxData["msg.autoanswer"] = "true"
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,9 @@ package common
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
"github.com/hashicorp/packer/packer"
|
"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)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
vmxPath := state.Get("vmx_path").(string)
|
vmxPath := state.Get("vmx_path").(string)
|
||||||
|
|
||||||
f, err := os.Open(vmxPath)
|
vmxData, err := ReadVMX(vmxPath)
|
||||||
if err != nil {
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
vmxBytes, err := ioutil.ReadAll(f)
|
|
||||||
if err != nil {
|
|
||||||
err := fmt.Errorf("Error reading VMX data: %s", err)
|
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
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)
|
log.Printf("Found available VNC port: %d", vncPort)
|
||||||
|
|
||||||
vmxData := ParseVMX(string(vmxBytes))
|
|
||||||
vncFinder.UpdateVMX(vncBindAddress, vncPassword, vncPort, vmxData)
|
vncFinder.UpdateVMX(vncBindAddress, vncPassword, vncPort, vmxData)
|
||||||
|
|
||||||
if err := WriteVMX(vmxPath, vmxData); err != nil {
|
if err := WriteVMX(vmxPath, vmxData); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue