From d0c64f90d546f67f544eeaa81788289894900c57 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Tue, 31 May 2016 18:40:16 -0700 Subject: [PATCH] Read key interval from ENV; default to 100ms --- builder/vmware/common/step_type_boot_command.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/builder/vmware/common/step_type_boot_command.go b/builder/vmware/common/step_type_boot_command.go index f3fa5dc49..1bd04ebaf 100644 --- a/builder/vmware/common/step_type_boot_command.go +++ b/builder/vmware/common/step_type_boot_command.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net" + "os" "runtime" "strings" "time" @@ -360,10 +361,15 @@ func vncSendString(c *vnc.ClientConn, original string) { // Send the key events. We add a 100ms sleep after each key event // to deal with network latency and the OS responding to the keystroke. // It is kind of arbitrary but it is better than nothing. + keyInterval := 100 * time.Millisecond + if envInterval, err := time.ParseDuration(os.Getenv("PACKER_KEY_INTERVAL")); err == nil { + keyInterval = envInterval + } + c.KeyEvent(keyCode, true) - time.Sleep(10 * time.Millisecond) + time.Sleep(keyInterval) c.KeyEvent(keyCode, false) - time.Sleep(10 * time.Millisecond) + time.Sleep(keyInterval) if keyShift { c.KeyEvent(KeyLeftShift, false)