Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
a5d39ceb
Commit
a5d39ceb
authored
Jun 22, 2014
by
Rickard von Essen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1173 from rickard-von-essen/pvm_bootcommand
[feature] Support boot command for pvm builder
parents
3f3deab1
4d994deb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
102 additions
and
36 deletions
+102
-36
builder/parallels/common/host_ip.go
builder/parallels/common/host_ip.go
+1
-1
builder/parallels/common/host_ip_ifconfig.go
builder/parallels/common/host_ip_ifconfig.go
+1
-1
builder/parallels/common/host_ip_ifconfig_test.go
builder/parallels/common/host_ip_ifconfig_test.go
+1
-1
builder/parallels/common/step_type_boot_command.go
builder/parallels/common/step_type_boot_command.go
+32
-26
builder/parallels/iso/builder.go
builder/parallels/iso/builder.go
+6
-1
builder/parallels/pvm/builder.go
builder/parallels/pvm/builder.go
+7
-0
builder/parallels/pvm/config.go
builder/parallels/pvm/config.go
+13
-6
website/source/docs/builders/parallels-pvm.html.markdown
website/source/docs/builders/parallels-pvm.html.markdown
+41
-0
No files found.
builder/parallels/
iso
/host_ip.go
→
builder/parallels/
common
/host_ip.go
View file @
a5d39ceb
package
iso
package
common
// Interface to help find the host IP that is available from within
// the Parallels virtual machines.
...
...
builder/parallels/
iso
/host_ip_ifconfig.go
→
builder/parallels/
common
/host_ip_ifconfig.go
View file @
a5d39ceb
package
iso
package
common
import
(
"bytes"
...
...
builder/parallels/
iso
/host_ip_ifconfig_test.go
→
builder/parallels/
common
/host_ip_ifconfig_test.go
View file @
a5d39ceb
package
iso
package
common
import
"testing"
...
...
builder/parallels/
iso
/step_type_boot_command.go
→
builder/parallels/
common
/step_type_boot_command.go
View file @
a5d39ceb
package
iso
package
common
import
(
"fmt"
"github.com/mitchellh/multistep"
parallelscommon
"github.com/mitchellh/packer/builder/parallels/common"
"github.com/mitchellh/packer/packer"
"log"
"strings"
...
...
@@ -24,7 +23,6 @@ type bootCommandTemplateData struct {
// Parallels Virtualization SDK - C API.
//
// Uses:
// config *config
// driver Driver
// http_port int
// ui packer.Ui
...
...
@@ -32,24 +30,32 @@ type bootCommandTemplateData struct {
//
// Produces:
// <nothing>
type
stepTypeBootCommand
struct
{}
type
StepTypeBootCommand
struct
{
BootCommand
[]
string
HostInterfaces
[]
string
VMName
string
Tpl
*
packer
.
ConfigTemplate
}
func
(
s
*
stepTypeBootCommand
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
func
(
s
*
StepTypeBootCommand
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
httpPort
:=
state
.
Get
(
"http_port"
)
.
(
uint
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
driver
:=
state
.
Get
(
"driver"
)
.
(
parallelscommon
.
Driver
)
// Determine the host IP
ipFinder
:=
&
IfconfigIPFinder
{
Devices
:
config
.
HostInterfaces
}
hostIp
,
err
:=
ipFinder
.
HostIP
()
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error detecting host IP: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
hostIp
:=
"0.0.0.0"
if
len
(
s
.
HostInterfaces
)
>
0
{
// Determine the host IP
ipFinder
:=
&
IfconfigIPFinder
{
Devices
:
s
.
HostInterfaces
}
ip
,
err
:=
ipFinder
.
HostIP
()
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error detecting host IP: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
hostIp
=
ip
}
ui
.
Say
(
fmt
.
Sprintf
(
"Host IP for the Parallels machine: %s"
,
hostIp
))
...
...
@@ -57,12 +63,12 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
tplData
:=
&
bootCommandTemplateData
{
hostIp
,
httpPort
,
config
.
VMName
,
s
.
VMName
,
}
ui
.
Say
(
"Typing the boot command..."
)
for
_
,
command
:=
range
config
.
BootCommand
{
command
,
err
:=
config
.
t
pl
.
Process
(
command
,
tplData
)
for
_
,
command
:=
range
s
.
BootCommand
{
command
,
err
:=
s
.
T
pl
.
Process
(
command
,
tplData
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error preparing boot command: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
...
...
@@ -73,7 +79,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
codes
:=
[]
string
{}
for
_
,
code
:=
range
scancodes
(
command
)
{
if
code
==
"wait"
{
if
err
:=
driver
.
SendKeyScanCodes
(
vm
Name
,
codes
...
);
err
!=
nil
{
if
err
:=
driver
.
SendKeyScanCodes
(
s
.
VM
Name
,
codes
...
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error sending boot command: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
...
...
@@ -85,7 +91,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
}
if
code
==
"wait5"
{
if
err
:=
driver
.
SendKeyScanCodes
(
vm
Name
,
codes
...
);
err
!=
nil
{
if
err
:=
driver
.
SendKeyScanCodes
(
s
.
VM
Name
,
codes
...
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error sending boot command: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
...
...
@@ -97,7 +103,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
}
if
code
==
"wait10"
{
if
err
:=
driver
.
SendKeyScanCodes
(
vm
Name
,
codes
...
);
err
!=
nil
{
if
err
:=
driver
.
SendKeyScanCodes
(
s
.
VM
Name
,
codes
...
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error sending boot command: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
...
...
@@ -116,7 +122,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
codes
=
append
(
codes
,
code
)
}
log
.
Printf
(
"Sending scancodes: %#v"
,
codes
)
if
err
:=
driver
.
SendKeyScanCodes
(
vm
Name
,
codes
...
);
err
!=
nil
{
if
err
:=
driver
.
SendKeyScanCodes
(
s
.
VM
Name
,
codes
...
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error sending boot command: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
...
...
@@ -127,7 +133,7 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
return
multistep
.
ActionContinue
}
func
(
*
s
tepTypeBootCommand
)
Cleanup
(
multistep
.
StateBag
)
{}
func
(
*
S
tepTypeBootCommand
)
Cleanup
(
multistep
.
StateBag
)
{}
func
scancodes
(
message
string
)
[]
string
{
// Scancodes reference: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
...
...
builder/parallels/iso/builder.go
View file @
a5d39ceb
...
...
@@ -298,7 +298,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
BootWait
:
b
.
config
.
BootWait
,
Headless
:
b
.
config
.
Headless
,
// TODO: migth work on Enterprise Ed.
},
new
(
stepTypeBootCommand
),
&
parallelscommon
.
StepTypeBootCommand
{
BootCommand
:
b
.
config
.
BootCommand
,
HostInterfaces
:
b
.
config
.
HostInterfaces
,
VMName
:
b
.
config
.
VMName
,
Tpl
:
b
.
config
.
tpl
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
parallelscommon
.
SSHAddress
,
SSHConfig
:
parallelscommon
.
SSHConfigFunc
(
b
.
config
.
SSHConfig
),
...
...
builder/parallels/pvm/builder.go
View file @
a5d39ceb
...
...
@@ -43,6 +43,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
state
.
Put
(
"driver"
,
driver
)
state
.
Put
(
"hook"
,
hook
)
state
.
Put
(
"ui"
,
ui
)
state
.
Put
(
"http_port"
,
uint
(
0
))
// Build the steps.
steps
:=
[]
multistep
.
Step
{
...
...
@@ -70,6 +71,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
BootWait
:
b
.
config
.
BootWait
,
Headless
:
b
.
config
.
Headless
,
},
&
parallelscommon
.
StepTypeBootCommand
{
BootCommand
:
b
.
config
.
BootCommand
,
HostInterfaces
:
[]
string
{},
VMName
:
b
.
config
.
VMName
,
Tpl
:
b
.
config
.
tpl
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
parallelscommon
.
SSHAddress
,
SSHConfig
:
parallelscommon
.
SSHConfigFunc
(
b
.
config
.
SSHConfig
),
...
...
builder/parallels/pvm/config.go
View file @
a5d39ceb
...
...
@@ -19,12 +19,12 @@ type Config struct {
parallelscommon
.
PrlctlConfig
`mapstructure:",squash"`
parallelscommon
.
PrlctlVersionConfig
`mapstructure:",squash"`
ParallelsToolsMode
string
`mapstructure:"parallels_tools_mode
"`
ParallelsTools
GuestPath
string
`mapstructure:"parallels_tools_guest_path
"`
ParallelsTools
HostPath
string
`mapstructure:"parallels_tools_ho
st_path"`
SourcePath
string
`mapstructure:"source_path"`
VMName
string
`mapstructure:"vm_name"`
BootCommand
[]
string
`mapstructure:"boot_command
"`
ParallelsTools
Mode
string
`mapstructure:"parallels_tools_mode
"`
ParallelsTools
GuestPath
string
`mapstructure:"parallels_tools_gue
st_path"`
ParallelsToolsHostPath
string
`mapstructure:"parallels_tools_host_path"`
SourcePath
string
`mapstructure:"source_path"`
VMName
string
`mapstructure:"vm_name"`
tpl
*
packer
.
ConfigTemplate
}
...
...
@@ -86,6 +86,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
}
for
i
,
command
:=
range
c
.
BootCommand
{
if
err
:=
c
.
tpl
.
Validate
(
command
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing boot_command[%d]: %s"
,
i
,
err
))
}
}
validMode
:=
false
validModes
:=
[]
string
{
parallelscommon
.
ParallelsToolsModeDisable
,
...
...
website/source/docs/builders/parallels-pvm.html.markdown
View file @
a5d39ceb
...
...
@@ -53,6 +53,19 @@ each category, the available options are alphabetized and described.
### 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_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.
*
`floppy_files`
(array of strings) - A list of files to put onto a floppy
disk that is attached when the VM is booted for the first time. This is
most useful for unattended Windows installs, which look for an
...
...
@@ -135,6 +148,34 @@ uploaded is controllable by `parallels_tools_path`, and defaults to
of the SSH user. Parallels Tools ISO's can be found in:
"/Applications/Parallels Desktop.app/Contents/Resources/Tools/"
## Boot Command
The
`boot_command`
specifies the keys to type when the virtual machine is first booted. This command is typed after
`boot_wait`
.
As documented above, the
`boot_command`
is an array of strings. The
strings are all typed in sequence. It is an array only to improve readability
within the template.
The boot command is "typed" character for character using the
`prltype`
(part
of prl-utils, see
[
Parallels Builder
](
/docs/builders/parallels.html
)
)
command connected 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:
*
`<enter>`
and
`<return>`
- Simulates an actual "enter" or "return" keypress.
*
`<esc>`
- Simulates pressing the escape key.
*
`<tab>`
- Simulates pressing the tab 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.
In addition to the special keys, each command to type is treated as a
[
configuration template
](
/docs/templates/configuration-templates.html
)
.
The available variables are:
## prlctl Commands
In order to perform extra customization of the virtual machine, a template can
define extra calls to
`prlctl`
to perform.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment