From 471f33d02e9f20f5f49267b44ab0d566ba319b31 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Tue, 2 Jul 2013 10:31:22 -0700 Subject: [PATCH 1/2] Add wait5 and wait10 special keys for boot command. --- builder/virtualbox/step_type_boot_command.go | 24 +++++++++++++++++++- builder/vmware/step_type_boot_command.go | 14 ++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/builder/virtualbox/step_type_boot_command.go b/builder/virtualbox/step_type_boot_command.go index 4fabeff59..f0428e551 100644 --- a/builder/virtualbox/step_type_boot_command.go +++ b/builder/virtualbox/step_type_boot_command.go @@ -59,6 +59,16 @@ func (s *stepTypeBootCommand) Run(state map[string]interface{}) multistep.StepAc continue } + if code == "wait5" { + time.Sleep(5 * time.Second) + continue + } + + if code == "wait10" { + time.Sleep(10 * time.Second) + continue + } + // Since typing is sometimes so slow, we check for an interrupt // in between each character. if _, ok := state[multistep.StateCancelled]; ok { @@ -116,11 +126,23 @@ func scancodes(message string) []string { var scancode []string if strings.HasPrefix(message, "") { - log.Printf("Special code found, will sleep at this point.") + log.Printf("Special code found, will sleep 1 second at this point.") scancode = []string{"wait"} message = message[len(""):] } + if strings.HasPrefix(message, "") { + log.Printf("Special code found, will sleep 5 seconds at this point.") + scancode = []string{"wait5"} + message = message[len(""):] + } + + if strings.HasPrefix(message, "") { + log.Printf("Special code found, will sleep 10 seconds at this point.") + scancode = []string{"wait10"} + message = message[len(""):] + } + if scancode == nil { for specialCode, specialValue := range special { if strings.HasPrefix(message, specialCode) { diff --git a/builder/vmware/step_type_boot_command.go b/builder/vmware/step_type_boot_command.go index ddd806a81..1e4bbdfd6 100644 --- a/builder/vmware/step_type_boot_command.go +++ b/builder/vmware/step_type_boot_command.go @@ -114,6 +114,20 @@ func vncSendString(c *vnc.ClientConn, original string) { continue } + if strings.HasPrefix(original, "") { + log.Printf("Special code '' found, sleeping 5 seconds") + time.Sleep(5 * time.Second) + original = original[len(""):] + continue + } + + if strings.HasPrefix(original, "") { + log.Printf("Special code '' found, sleeping 10 seconds") + time.Sleep(10 * time.Second) + original = original[len(""):] + continue + } + for specialCode, specialValue := range special { if strings.HasPrefix(original, specialCode) { log.Printf("Special code '%s' found, replacing with: %d", specialCode, specialValue) From a5dba51d4fa06857530ac1efccf21add960d6187 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Tue, 2 Jul 2013 10:44:49 -0700 Subject: [PATCH 2/2] Document wait5 and wait10 boot command keys. --- website/source/docs/builders/virtualbox.html.markdown | 2 +- website/source/docs/builders/vmware.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/source/docs/builders/virtualbox.html.markdown b/website/source/docs/builders/virtualbox.html.markdown index d8f4dc985..88c6e7467 100644 --- a/website/source/docs/builders/virtualbox.html.markdown +++ b/website/source/docs/builders/virtualbox.html.markdown @@ -171,7 +171,7 @@ will be replaced by the proper key: * `` - Simulates pressing the tab key. -* `` - Adds a one second pause before sending any additional keys. This +* `` `` `` - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. In addition to the special keys, each command to type is treated as a diff --git a/website/source/docs/builders/vmware.html.markdown b/website/source/docs/builders/vmware.html.markdown index 9fc603009..7824d3ffc 100644 --- a/website/source/docs/builders/vmware.html.markdown +++ b/website/source/docs/builders/vmware.html.markdown @@ -168,7 +168,7 @@ will be replaced by the proper key: * `` - Simulates pressing the tab key. -* `` - Adds a one second pause before sending any additional keys. This +* `` `` `` - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. In addition to the special keys, each command to type is treated as a