|
|
|
@ -1,10 +1,9 @@
|
|
|
|
package iso
|
|
|
|
package common
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/go-vnc"
|
|
|
|
"github.com/mitchellh/go-vnc"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
vmwcommon "github.com/mitchellh/packer/builder/vmware/common"
|
|
|
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
@ -26,18 +25,20 @@ type bootCommandTemplateData struct {
|
|
|
|
// This step "types" the boot command into the VM over VNC.
|
|
|
|
// This step "types" the boot command into the VM over VNC.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Uses:
|
|
|
|
// Uses:
|
|
|
|
// config *config
|
|
|
|
|
|
|
|
// http_port int
|
|
|
|
// http_port int
|
|
|
|
// ui packer.Ui
|
|
|
|
// ui packer.Ui
|
|
|
|
// vnc_port uint
|
|
|
|
// vnc_port uint
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Produces:
|
|
|
|
// Produces:
|
|
|
|
// <nothing>
|
|
|
|
// <nothing>
|
|
|
|
type stepTypeBootCommand struct{}
|
|
|
|
type StepTypeBootCommand struct {
|
|
|
|
|
|
|
|
BootCommand []string
|
|
|
|
|
|
|
|
VMName string
|
|
|
|
|
|
|
|
Tpl *packer.ConfigTemplate
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
config := state.Get("config").(*config)
|
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
driver := state.Get("driver").(vmwcommon.Driver)
|
|
|
|
|
|
|
|
httpPort := state.Get("http_port").(uint)
|
|
|
|
httpPort := state.Get("http_port").(uint)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
vncIp := state.Get("vnc_ip").(string)
|
|
|
|
vncIp := state.Get("vnc_ip").(string)
|
|
|
|
@ -88,12 +89,12 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
|
|
|
|
tplData := &bootCommandTemplateData{
|
|
|
|
tplData := &bootCommandTemplateData{
|
|
|
|
hostIp,
|
|
|
|
hostIp,
|
|
|
|
httpPort,
|
|
|
|
httpPort,
|
|
|
|
config.VMName,
|
|
|
|
s.VMName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui.Say("Typing the boot command over VNC...")
|
|
|
|
ui.Say("Typing the boot command over VNC...")
|
|
|
|
for _, command := range config.BootCommand {
|
|
|
|
for _, command := range s.BootCommand {
|
|
|
|
command, err := config.tpl.Process(command, tplData)
|
|
|
|
command, err := s.Tpl.Process(command, tplData)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
err := fmt.Errorf("Error preparing boot command: %s", err)
|
|
|
|
err := fmt.Errorf("Error preparing boot command: %s", err)
|
|
|
|
state.Put("error", err)
|
|
|
|
state.Put("error", err)
|
|
|
|
@ -113,7 +114,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
|
|
|
|
return multistep.ActionContinue
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (*stepTypeBootCommand) Cleanup(multistep.StateBag) {}
|
|
|
|
func (*StepTypeBootCommand) Cleanup(multistep.StateBag) {}
|
|
|
|
|
|
|
|
|
|
|
|
func vncSendString(c *vnc.ClientConn, original string) {
|
|
|
|
func vncSendString(c *vnc.ClientConn, original string) {
|
|
|
|
// Scancodes reference: https://github.com/qemu/qemu/blob/master/ui/vnc_keysym.h
|
|
|
|
// Scancodes reference: https://github.com/qemu/qemu/blob/master/ui/vnc_keysym.h
|