Add special key modifiers to log output when used.
Update documentation to include new key modifiers.
This commit is contained in:
parent
e636c3de3c
commit
9c53df1e0e
|
@ -2,7 +2,7 @@ package common
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
//"log"
|
||||
"log"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
@ -162,77 +162,89 @@ func scancodes(message string) []string {
|
|||
if strings.HasPrefix(message, "<leftAltOn>") {
|
||||
scancode = []string{"38"}
|
||||
message = message[len("<leftAltOn>"):]
|
||||
log.Printf("Special code '<leftAltOn>' found, replacing with: 38")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<leftCtrlOn>") {
|
||||
scancode = []string{"1d"}
|
||||
message = message[len("<leftCtrlOn>"):]
|
||||
log.Printf("Special code '<leftCtrlOn>' found, replacing with: 1d")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<leftShiftOn>") {
|
||||
scancode = []string{"2a"}
|
||||
message = message[len("<leftShiftOn>"):]
|
||||
log.Printf("Special code '<leftShiftOn>' found, replacing with: 2a")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<leftAltOff>") {
|
||||
scancode = []string{"b8"}
|
||||
message = message[len("<leftAltOff>"):]
|
||||
log.Printf("Special code '<leftAltOff>' found, replacing with: b8")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<leftCtrlOff>") {
|
||||
scancode = []string{"9d"}
|
||||
message = message[len("<leftCtrlOff>"):]
|
||||
log.Printf("Special code '<leftCtrlOff>' found, replacing with: 9d")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<leftShiftOff>") {
|
||||
scancode = []string{"aa"}
|
||||
message = message[len("<leftShiftOff>"):]
|
||||
log.Printf("Special code '<leftShiftOff>' found, replacing with: aa")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<rightAltOn>") {
|
||||
scancode = []string{"e038"}
|
||||
message = message[len("<rightAltOn>"):]
|
||||
log.Printf("Special code '<rightAltOn>' found, replacing with: e038")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<rightCtrlOn>") {
|
||||
scancode = []string{"e01d"}
|
||||
message = message[len("<rightCtrlOn>"):]
|
||||
log.Printf("Special code '<rightCtrlOn>' found, replacing with: e01d")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<rightShiftOn>") {
|
||||
scancode = []string{"36"}
|
||||
message = message[len("<rightShiftOn>"):]
|
||||
log.Printf("Special code '<rightShiftOn>' found, replacing with: 36")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<rightAltOff>") {
|
||||
scancode = []string{"e0b8"}
|
||||
message = message[len("<rightAltOff>"):]
|
||||
log.Printf("Special code '<rightAltOff>' found, replacing with: e0b8")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<rightCtrlOff>") {
|
||||
scancode = []string{"e09d"}
|
||||
message = message[len("<rightCtrlOff>"):]
|
||||
log.Printf("Special code '<rightCtrlOff>' found, replacing with: e09d")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<rightShiftOff>") {
|
||||
scancode = []string{"b6"}
|
||||
message = message[len("<rightShiftOff>"):]
|
||||
log.Printf("Special code '<rightShiftOff>' found, replacing with: b6")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<wait>") {
|
||||
//log.Printf("Special code <wait> found, will sleep 1 second at this point.")
|
||||
log.Printf("Special code <wait> found, will sleep 1 second at this point.")
|
||||
scancode = []string{"wait"}
|
||||
message = message[len("<wait>"):]
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<wait5>") {
|
||||
//log.Printf("Special code <wait5> found, will sleep 5 seconds at this point.")
|
||||
log.Printf("Special code <wait5> found, will sleep 5 seconds at this point.")
|
||||
scancode = []string{"wait5"}
|
||||
message = message[len("<wait5>"):]
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "<wait10>") {
|
||||
//log.Printf("Special code <wait10> found, will sleep 10 seconds at this point.")
|
||||
log.Printf("Special code <wait10> found, will sleep 10 seconds at this point.")
|
||||
scancode = []string{"wait10"}
|
||||
message = message[len("<wait10>"):]
|
||||
}
|
||||
|
@ -240,7 +252,7 @@ func scancodes(message string) []string {
|
|||
if scancode == nil {
|
||||
for specialCode, specialValue := range special {
|
||||
if strings.HasPrefix(message, specialCode) {
|
||||
//log.Printf("Special code '%s' found, replacing with: %s", specialCode, specialValue)
|
||||
log.Printf("Special code '%s' found, replacing with: %s", specialCode, specialValue)
|
||||
scancode = specialValue
|
||||
message = message[len(specialCode):]
|
||||
break
|
||||
|
@ -266,7 +278,7 @@ func scancodes(message string) []string {
|
|||
}
|
||||
|
||||
scancode = append(scancode, fmt.Sprintf("%02x", scancodeInt+0x80))
|
||||
//log.Printf("Sending char '%c', code '%v', shift %v", r, scancode, keyShift)
|
||||
log.Printf("Sending char '%c', code '%v', shift %v", r, scancode, keyShift)
|
||||
}
|
||||
|
||||
result = append(result, scancode...)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "HyperV Builder (from an ISO)"
|
||||
description: |-
|
||||
The HyperV Packer builder is able to create HyperV virtual machines and export them.
|
||||
layout: "docs"
|
||||
page_title: "HyperV Builder (from an ISO)"
|
||||
---
|
||||
|
||||
# HyperV Builder (from an ISO)
|
||||
|
@ -59,126 +59,126 @@ can be configured for this builder.
|
|||
|
||||
### Required:
|
||||
|
||||
* `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO
|
||||
files are so large, this is required and Packer will verify it prior
|
||||
to booting a virtual machine with the ISO attached. The type of the
|
||||
checksum is specified with `iso_checksum_type`, documented below.
|
||||
- `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO
|
||||
files are so large, this is required and Packer will verify it prior
|
||||
to booting a virtual machine with the ISO attached. The type of the
|
||||
checksum is specified with `iso_checksum_type`, documented below.
|
||||
|
||||
* `iso_checksum_type` (string) - The type of the checksum specified in
|
||||
`iso_checksum`. Valid values are "none", "md5", "sha1", "sha256", or
|
||||
"sha512" currently. While "none" will skip checksumming, this is not
|
||||
recommended since ISO files are generally large and corruption does happen
|
||||
from time to time.
|
||||
- `iso_checksum_type` (string) - The type of the checksum specified in
|
||||
`iso_checksum`. Valid values are "none", "md5", "sha1", "sha256", or
|
||||
"sha512" currently. While "none" will skip checksumming, this is not
|
||||
recommended since ISO files are generally large and corruption does happen
|
||||
from time to time.
|
||||
|
||||
* `iso_url` (string) - A URL to the ISO containing the installation image.
|
||||
This URL can be either an HTTP URL or a file URL (or path to a file).
|
||||
If this is an HTTP URL, Packer will download it and cache it between
|
||||
runs.
|
||||
- `iso_url` (string) - A URL to the ISO containing the installation image.
|
||||
This URL can be either an HTTP URL or a file URL (or path to a file).
|
||||
If this is an HTTP URL, Packer will download it and cache it between
|
||||
runs.
|
||||
|
||||
### Optional:
|
||||
|
||||
* `boot_command` (array of strings) - This is an array of commands to type
|
||||
when the virtual machine is first booted. The goal of these commands should
|
||||
be to type just enough to initialize the operating system installer. Special
|
||||
keys can be typed as well, and are covered in the section below on the boot
|
||||
command. If this is not specified, it is assumed the installer will start
|
||||
itself.
|
||||
- `boot_command` (array of strings) - This is an array of commands to type
|
||||
when the virtual machine is first booted. The goal of these commands should
|
||||
be to type just enough to initialize the operating system installer. Special
|
||||
keys can be typed as well, and are covered in the section below on the boot
|
||||
command. If this is not specified, it is assumed the installer will start
|
||||
itself.
|
||||
|
||||
* `boot_wait` (string) - The time to wait after booting the initial virtual
|
||||
machine before typing the `boot_command`. The value of this should be
|
||||
a duration. Examples are "5s" and "1m30s" which will cause Packer to wait
|
||||
five seconds and one minute 30 seconds, respectively. If this isn't specified,
|
||||
the default is 10 seconds.
|
||||
- `boot_wait` (string) - The time to wait after booting the initial virtual
|
||||
machine before typing the `boot_command`. The value of this should be
|
||||
a duration. Examples are "5s" and "1m30s" which will cause Packer to wait
|
||||
five seconds and one minute 30 seconds, respectively. If this isn't specified,
|
||||
the default is 10 seconds.
|
||||
|
||||
* `cpu` (int) - The number of cpus the virtual machine should use. If this isn't specified,
|
||||
the default is 1 cpu.
|
||||
- `cpu` (int) - The number of cpus the virtual machine should use. If this isn't specified,
|
||||
the default is 1 cpu.
|
||||
|
||||
* `disk_size` (integer) - The size, in megabytes, of the hard disk to create
|
||||
for the VM. By default, this is 40000 (about 40 GB).
|
||||
- `disk_size` (integer) - The size, in megabytes, of the hard disk to create
|
||||
for the VM. By default, this is 40000 (about 40 GB).
|
||||
|
||||
* `enable_secure_boot` (bool) - If true enable secure boot for virtual machine.
|
||||
This defaults to false.
|
||||
- `enable_secure_boot` (bool) - If true enable secure boot for virtual machine.
|
||||
This defaults to false.
|
||||
|
||||
* `floppy_files` (array of strings) - A list of files to place onto a floppy
|
||||
disk that is attached when the VM is booted. This is most useful
|
||||
for unattended Windows installs, which look for an `Autounattend.xml` file
|
||||
on removable media. By default, no floppy will be attached. All files
|
||||
listed in this setting get placed into the root directory of the floppy
|
||||
and the floppy is attached as the first floppy device. Currently, no
|
||||
support exists for creating sub-directories on the floppy. Wildcard
|
||||
characters (*, ?, and []) are allowed. Directory names are also allowed,
|
||||
which will add all the files found in the directory to the floppy.
|
||||
- `floppy_files` (array of strings) - A list of files to place onto a floppy
|
||||
disk that is attached when the VM is booted. This is most useful
|
||||
for unattended Windows installs, which look for an `Autounattend.xml` file
|
||||
on removable media. By default, no floppy will be attached. All files
|
||||
listed in this setting get placed into the root directory of the floppy
|
||||
and the floppy is attached as the first floppy device. Currently, no
|
||||
support exists for creating sub-directories on the floppy. Wildcard
|
||||
characters (*, ?, and []) are allowed. Directory names are also allowed,
|
||||
which will add all the files found in the directory to the floppy.
|
||||
|
||||
* `generation` (int) - The HyperV generation for the virtual machine. By
|
||||
default, this is 1. Generation 2 HyperV virtual machines do not support
|
||||
floppy drives. In this scenario use secondary_iso_images instead. Hard
|
||||
drives and dvd drives will also be scsi and not ide.
|
||||
- `generation` (int) - The HyperV generation for the virtual machine. By
|
||||
default, this is 1. Generation 2 HyperV virtual machines do not support
|
||||
floppy drives. In this scenario use secondary_iso_images instead. Hard
|
||||
drives and dvd drives will also be scsi and not ide.
|
||||
|
||||
* `http_directory` (string) - Path to a directory to serve using an HTTP
|
||||
server. The files in this directory will be available over HTTP that will
|
||||
be requestable from the virtual machine. This is useful for hosting
|
||||
kickstart files and so on. By default this is "", which means no HTTP
|
||||
server will be started. The address and port of the HTTP server will be
|
||||
available as variables in `boot_command`. This is covered in more detail
|
||||
below.
|
||||
- `http_directory` (string) - Path to a directory to serve using an HTTP
|
||||
server. The files in this directory will be available over HTTP that will
|
||||
be requestable from the virtual machine. This is useful for hosting
|
||||
kickstart files and so on. By default this is "", which means no HTTP
|
||||
server will be started. The address and port of the HTTP server will be
|
||||
available as variables in `boot_command`. This is covered in more detail
|
||||
below.
|
||||
|
||||
* `http_port_min` and `http_port_max` (integer) - These are the minimum and
|
||||
maximum port to use for the HTTP server started to serve the `http_directory`.
|
||||
Because Packer often runs in parallel, Packer will choose a randomly available
|
||||
port in this range to run the HTTP server. If you want to force the HTTP
|
||||
server to be on one port, make this minimum and maximum port the same.
|
||||
By default the values are 8000 and 9000, respectively.
|
||||
- `http_port_min` and `http_port_max` (integer) - These are the minimum and
|
||||
maximum port to use for the HTTP server started to serve the `http_directory`.
|
||||
Because Packer often runs in parallel, Packer will choose a randomly available
|
||||
port in this range to run the HTTP server. If you want to force the HTTP
|
||||
server to be on one port, make this minimum and maximum port the same.
|
||||
By default the values are 8000 and 9000, respectively.
|
||||
|
||||
* `ip_address_timeout` (string) - The time to wait after creating the initial virtual
|
||||
machine and waiting for an ip address before assuming there is an error in the process.
|
||||
The value of this should be a duration. Examples are "5s" and "1m30s" which will cause Packer to wait
|
||||
five seconds and one minute 30 seconds, respectively. If this isn't specified,
|
||||
the default is 10 seconds.
|
||||
- `ip_address_timeout` (string) - The time to wait after creating the initial virtual
|
||||
machine and waiting for an ip address before assuming there is an error in the process.
|
||||
The value of this should be a duration. Examples are "5s" and "1m30s" which will cause Packer to wait
|
||||
five seconds and one minute 30 seconds, respectively. If this isn't specified,
|
||||
the default is 10 seconds.
|
||||
|
||||
* `iso_urls` (array of strings) - Multiple URLs for the ISO to download.
|
||||
Packer will try these in order. If anything goes wrong attempting to download
|
||||
or while downloading a single URL, it will move on to the next. All URLs
|
||||
must point to the same file (same checksum). By default this is empty
|
||||
and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified.
|
||||
- `iso_urls` (array of strings) - Multiple URLs for the ISO to download.
|
||||
Packer will try these in order. If anything goes wrong attempting to download
|
||||
or while downloading a single URL, it will move on to the next. All URLs
|
||||
must point to the same file (same checksum). By default this is empty
|
||||
and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified.
|
||||
|
||||
* `output_directory` (string) - This is the path to the directory where the
|
||||
resulting virtual machine will be created. This may be relative or absolute.
|
||||
If relative, the path is relative to the working directory when `packer`
|
||||
is executed. This directory must not exist or be empty prior to running the builder.
|
||||
By default this is "output-BUILDNAME" where "BUILDNAME" is the name
|
||||
of the build.
|
||||
- `output_directory` (string) - This is the path to the directory where the
|
||||
resulting virtual machine will be created. This may be relative or absolute.
|
||||
If relative, the path is relative to the working directory when `packer`
|
||||
is executed. This directory must not exist or be empty prior to running the builder.
|
||||
By default this is "output-BUILDNAME" where "BUILDNAME" is the name
|
||||
of the build.
|
||||
|
||||
* `secondary_iso_images` (array of strings) - A list of files to place onto a floppy
|
||||
disk that is attached when the VM is booted. This is most useful
|
||||
for unattended Windows installs, which look for an `Autounattend.xml` file
|
||||
on removable media. By default, no floppy will be attached. All files
|
||||
listed in this setting get placed into the root directory of the floppy
|
||||
and the floppy is attached as the first floppy device. Currently, no
|
||||
support exists for creating sub-directories on the floppy. Wildcard
|
||||
characters (*, ?, and []) are allowed. Directory names are also allowed,
|
||||
which will add all the files found in the directory to the floppy.
|
||||
disk that is attached when the VM is booted. This is most useful
|
||||
for unattended Windows installs, which look for an `Autounattend.xml` file
|
||||
on removable media. By default, no floppy will be attached. All files
|
||||
listed in this setting get placed into the root directory of the floppy
|
||||
and the floppy is attached as the first floppy device. Currently, no
|
||||
support exists for creating sub-directories on the floppy. Wildcard
|
||||
characters (*, ?, and []) are allowed. Directory names are also allowed,
|
||||
which will add all the files found in the directory to the floppy.
|
||||
|
||||
* `shutdown_command` (string) - The command to use to gracefully shut down the machine once all
|
||||
the provisioning is done. By default this is an empty string, which tells Packer to just
|
||||
forcefully shut down the machine unless a shutdown command takes place inside script so this may
|
||||
safely be omitted. If one or more scripts require a reboot it is suggested to leave this blank
|
||||
since reboots may fail and specify the final shutdown command in your last script.
|
||||
- `shutdown_command` (string) - The command to use to gracefully shut down the machine once all
|
||||
the provisioning is done. By default this is an empty string, which tells Packer to just
|
||||
forcefully shut down the machine unless a shutdown command takes place inside script so this may
|
||||
safely be omitted. If one or more scripts require a reboot it is suggested to leave this blank
|
||||
since reboots may fail and specify the final shutdown command in your last script.
|
||||
|
||||
* `shutdown_timeout` (string) - The amount of time to wait after executing
|
||||
the `shutdown_command` for the virtual machine to actually shut down.
|
||||
If it doesn't shut down in this time, it is an error. By default, the timeout
|
||||
is "5m", or five minutes.
|
||||
- `shutdown_timeout` (string) - The amount of time to wait after executing
|
||||
the `shutdown_command` for the virtual machine to actually shut down.
|
||||
If it doesn't shut down in this time, it is an error. By default, the timeout
|
||||
is "5m", or five minutes.
|
||||
|
||||
* `skip_compaction` (bool) - If true skip compacting the hard disk for virtual machine when
|
||||
exporting. This defaults to false.
|
||||
- `skip_compaction` (bool) - If true skip compacting the hard disk for virtual machine when
|
||||
exporting. This defaults to false.
|
||||
|
||||
* `switch_name` (string) - The name of the switch to connect the virtual machine to. Be defaulting
|
||||
this to an empty string, Packer will try to determine the switch to use by looking for
|
||||
external switch that is up and running.
|
||||
- `switch_name` (string) - The name of the switch to connect the virtual machine to. Be defaulting
|
||||
this to an empty string, Packer will try to determine the switch to use by looking for
|
||||
external switch that is up and running.
|
||||
|
||||
* `vm_name` (string) - This is the name of the virtua machine for the new virtual
|
||||
machine, without the file extension. By default this is "packer-BUILDNAME",
|
||||
where "BUILDNAME" is the name of the build.
|
||||
- `vm_name` (string) - This is the name of the virtua machine for the new virtual
|
||||
machine, without the file extension. By default this is "packer-BUILDNAME",
|
||||
where "BUILDNAME" is the name of the build.
|
||||
|
||||
## Boot Command
|
||||
|
||||
|
@ -196,30 +196,51 @@ to the machine, simulating a human actually typing the keyboard. There are
|
|||
a set of special keys available. If these are in your boot command, they
|
||||
will be replaced by the proper key:
|
||||
|
||||
* `<bs>` - Backspace
|
||||
- `<bs>` - Backspace
|
||||
|
||||
* `<del>` - Delete
|
||||
- `<del>` - Delete
|
||||
|
||||
* `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress.
|
||||
- `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress.
|
||||
|
||||
* `<esc>` - Simulates pressing the escape key.
|
||||
- `<esc>` - Simulates pressing the escape key.
|
||||
|
||||
* `<tab>` - Simulates pressing the tab key.
|
||||
- `<tab>` - Simulates pressing the tab key.
|
||||
|
||||
* `<f1>` - `<f12>` - Simulates pressing a function key.
|
||||
- `<f1>` - `<f12>` - Simulates pressing a function key.
|
||||
|
||||
* `<up>` `<down>` `<left>` `<right>` - Simulates pressing an arrow key.
|
||||
- `<up>` `<down>` `<left>` `<right>` - Simulates pressing an arrow key.
|
||||
|
||||
* `<spacebar>` - Simulates pressing the spacebar.
|
||||
- `<spacebar>` - Simulates pressing the spacebar.
|
||||
|
||||
* `<insert>` - Simulates pressing the insert key.
|
||||
- `<insert>` - Simulates pressing the insert key.
|
||||
|
||||
* `<home>` `<end>` - Simulates pressing the home and end keys.
|
||||
- `<home>` `<end>` - Simulates pressing the home and end keys.
|
||||
|
||||
* `<pageUp>` `<pageDown>` - Simulates pressing the page up and page down keys.
|
||||
- `<pageUp>` `<pageDown>` - Simulates pressing the page up and page down keys.
|
||||
|
||||
* `<wait>` `<wait5>` `<wait10>` - 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.
|
||||
- `<leftAlt>` `<rightAlt>` - Simulates pressing the alt key.
|
||||
|
||||
- `<leftCtrl>` `<rightCtrl>` - Simulates pressing the ctrl key.
|
||||
|
||||
- `<leftShift>` `<rightShift>` - Simulates pressing the shift key.
|
||||
|
||||
- `<leftAltOn>` `<rightAltOn>` - Simulates pressing and holding the alt key.
|
||||
|
||||
- `<leftCtrlOn>` `<rightCtrlOn>` - Simulates pressing and holding the ctrl key.
|
||||
|
||||
- `<leftShiftOn>` `<rightShiftOn>` - Simulates pressing and holding the shift key.
|
||||
|
||||
- `<leftAltOff>` `<rightAltOff>` - Simulates releasing a held alt key.
|
||||
|
||||
- `<leftCtrlOff>` `<rightCtrlOff>` - Simulates releasing a held ctrl key.
|
||||
|
||||
- `<leftShiftOff>` `<rightShiftOff>` - Simulates releasing a held shift key.
|
||||
|
||||
- `<wait>` `<wait5>` `<wait10>` - 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.
|
||||
|
||||
When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `<leftCtrlOn>c<leftCtrlOff>`.
|
||||
|
||||
In addition to the special keys, each command to type is treated as a
|
||||
[configuration template](/docs/templates/configuration-templates.html).
|
||||
|
|
Loading…
Reference in New Issue