diff --git a/builder/virtualbox/common/step_type_boot_command.go b/builder/virtualbox/common/step_type_boot_command.go index aa12df00f..ab9cd5c70 100644 --- a/builder/virtualbox/common/step_type_boot_command.go +++ b/builder/virtualbox/common/step_type_boot_command.go @@ -65,7 +65,7 @@ func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction return multistep.ActionHalt } - for _, code := range gathercodes(scancodes(command)) { + for _, code := range scancodes(command) { if code == "wait" { time.Sleep(1 * time.Second) continue @@ -91,9 +91,7 @@ func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction pauseFn(multistep.DebugLocationAfterRun, fmt.Sprintf("boot_command[%d]: %s", i, command), state) } - args := []string{"controlvm", vmName, "keyboardputscancode"} - args = append(args, strings.Split(code, " ")...) - if err := driver.VBoxManage(args...); err != nil { + if err := driver.VBoxManage("controlvm", vmName, "keyboardputscancode", code); err != nil { err := fmt.Errorf("Error sending boot command: %s", err) state.Put("error", err) ui.Error(err.Error()) @@ -107,27 +105,6 @@ func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction func (*StepTypeBootCommand) Cleanup(multistep.StateBag) {} -// Gather scancodes to send to console efficiently. -func gathercodes(codes []string) (gathered []string) { - working := []string{} - pushWorking := func() { - if len(working) > 0 { - gathered = append(gathered, strings.Join(working, " ")) - working = []string{} - } - } - for _, code := range codes { - if strings.HasPrefix(code, "wait") { - pushWorking() - gathered = append(gathered, code) - } else { - working = append(working, code) - } - } - pushWorking() - return -} - func scancodes(message string) []string { // Scancodes reference: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html // diff --git a/builder/virtualbox/common/step_type_boot_command_test.go b/builder/virtualbox/common/step_type_boot_command_test.go deleted file mode 100644 index 53b33bda5..000000000 --- a/builder/virtualbox/common/step_type_boot_command_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package common - -import ( - "reflect" - "testing" -) - -func TestStepTypeBootCommand_gather(t *testing.T) { - input := [][]string{ - {"02", "82", "wait1", "03", "83"}, - {"02", "82", "03", "83"}, - {"wait5", "wait1", "wait10"}, - {"wait5", "02", "82", "03", "83", "wait1", "wait10"}, - {"wait1"}, - {"01"}, - } - - expected := [][]string{ - {"02 82", "wait1", "03 83"}, - {"02 82 03 83"}, - {"wait5", "wait1", "wait10"}, - {"wait5", "02 82 03 83", "wait1", "wait10"}, - {"wait1"}, - {"01"}, - } - - for i, data := range input { - gathered := gathercodes(data) - if !reflect.DeepEqual(gathered, expected[i]) { - t.Fatalf("%#v did not equal expected %#v", gathered, expected[i]) - } - } -}