Enable headless mode by default on Parallels Desktop 11
This commit is contained in:
parent
7d3afc882a
commit
83980d2326
|
@ -40,7 +40,7 @@ func (d *Parallels11Driver) SetDefaultConfiguration(vmName string) error {
|
||||||
commands := make([][]string, 12)
|
commands := make([][]string, 12)
|
||||||
commands[0] = []string{"set", vmName, "--cpus", "1"}
|
commands[0] = []string{"set", vmName, "--cpus", "1"}
|
||||||
commands[1] = []string{"set", vmName, "--memsize", "512"}
|
commands[1] = []string{"set", vmName, "--memsize", "512"}
|
||||||
commands[2] = []string{"set", vmName, "--startup-view", "same"}
|
commands[2] = []string{"set", vmName, "--startup-view", "headless"}
|
||||||
commands[3] = []string{"set", vmName, "--on-shutdown", "close"}
|
commands[3] = []string{"set", vmName, "--on-shutdown", "close"}
|
||||||
commands[4] = []string{"set", vmName, "--on-window-close", "keep-running"}
|
commands[4] = []string{"set", vmName, "--on-window-close", "keep-running"}
|
||||||
commands[5] = []string{"set", vmName, "--auto-share-camera", "off"}
|
commands[5] = []string{"set", vmName, "--auto-share-camera", "off"}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type RunConfig struct {
|
type RunConfig struct {
|
||||||
Headless bool `mapstructure:"headless"`
|
|
||||||
RawBootWait string `mapstructure:"boot_wait"`
|
RawBootWait string `mapstructure:"boot_wait"`
|
||||||
|
|
||||||
BootWait time.Duration ``
|
BootWait time.Duration ``
|
||||||
|
|
|
@ -17,7 +17,6 @@ import (
|
||||||
// Produces:
|
// Produces:
|
||||||
type StepRun struct {
|
type StepRun struct {
|
||||||
BootWait time.Duration
|
BootWait time.Duration
|
||||||
Headless bool
|
|
||||||
|
|
||||||
vmName string
|
vmName string
|
||||||
}
|
}
|
||||||
|
@ -28,13 +27,6 @@ func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
vmName := state.Get("vmName").(string)
|
vmName := state.Get("vmName").(string)
|
||||||
|
|
||||||
ui.Say("Starting the virtual machine...")
|
ui.Say("Starting the virtual machine...")
|
||||||
//guiArgument := "gui"
|
|
||||||
if s.Headless == true {
|
|
||||||
ui.Message("WARNING: The VM will be started in headless mode, as configured.\n" +
|
|
||||||
"In headless mode, errors during the boot sequence or OS setup\n" +
|
|
||||||
"won't be easily visible. Use at your own discretion.")
|
|
||||||
//guiArgument = "headless"
|
|
||||||
}
|
|
||||||
command := []string{"start", vmName}
|
command := []string{"start", vmName}
|
||||||
if err := driver.Prlctl(command...); err != nil {
|
if err := driver.Prlctl(command...); err != nil {
|
||||||
err := fmt.Errorf("Error starting VM: %s", err)
|
err := fmt.Errorf("Error starting VM: %s", err)
|
||||||
|
|
|
@ -241,7 +241,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
},
|
},
|
||||||
¶llelscommon.StepRun{
|
¶llelscommon.StepRun{
|
||||||
BootWait: b.config.BootWait,
|
BootWait: b.config.BootWait,
|
||||||
Headless: b.config.Headless, // TODO: migth work on Enterprise Ed.
|
|
||||||
},
|
},
|
||||||
¶llelscommon.StepTypeBootCommand{
|
¶llelscommon.StepTypeBootCommand{
|
||||||
BootCommand: b.config.BootCommand,
|
BootCommand: b.config.BootCommand,
|
||||||
|
|
|
@ -74,7 +74,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
},
|
},
|
||||||
¶llelscommon.StepRun{
|
¶llelscommon.StepRun{
|
||||||
BootWait: b.config.BootWait,
|
BootWait: b.config.BootWait,
|
||||||
Headless: b.config.Headless,
|
|
||||||
},
|
},
|
||||||
¶llelscommon.StepTypeBootCommand{
|
¶llelscommon.StepTypeBootCommand{
|
||||||
BootCommand: b.config.BootCommand,
|
BootCommand: b.config.BootCommand,
|
||||||
|
|
|
@ -26,6 +26,7 @@ func init() {
|
||||||
"virtualbox-gaattach": new(FixerVirtualBoxGAAttach),
|
"virtualbox-gaattach": new(FixerVirtualBoxGAAttach),
|
||||||
"virtualbox-rename": new(FixerVirtualBoxRename),
|
"virtualbox-rename": new(FixerVirtualBoxRename),
|
||||||
"vmware-rename": new(FixerVMwareRename),
|
"vmware-rename": new(FixerVMwareRename),
|
||||||
|
"parallels-headless": new(FixerParallelsHeadless),
|
||||||
}
|
}
|
||||||
|
|
||||||
FixerOrder = []string{
|
FixerOrder = []string{
|
||||||
|
@ -35,5 +36,6 @@ func init() {
|
||||||
"pp-vagrant-override",
|
"pp-vagrant-override",
|
||||||
"virtualbox-rename",
|
"virtualbox-rename",
|
||||||
"vmware-rename",
|
"vmware-rename",
|
||||||
|
"parallels-headless",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package fix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FixerParallelsHeadless removes "headless" from a template in a Parallels builder
|
||||||
|
type FixerParallelsHeadless struct{}
|
||||||
|
|
||||||
|
func (FixerParallelsHeadless) Fix(input map[string]interface{}) (map[string]interface{}, error) {
|
||||||
|
// The type we'll decode into; we only care about builders
|
||||||
|
type template struct {
|
||||||
|
Builders []map[string]interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode the input into our structure, if we can
|
||||||
|
var tpl template
|
||||||
|
if err := mapstructure.Decode(input, &tpl); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, builder := range tpl.Builders {
|
||||||
|
builderTypeRaw, ok := builder["type"]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
builderType, ok := builderTypeRaw.(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if builderType != "parallels-iso" && builderType != "parallels-pvm" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
_, ok = builder["headless"]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(builder, "headless")
|
||||||
|
}
|
||||||
|
|
||||||
|
input["builders"] = tpl.Builders
|
||||||
|
return input, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (FixerParallelsHeadless) Synopsis() string {
|
||||||
|
return `Removes unused "headless" from Parallels builders`
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package fix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFixerParallelsHeadless_Impl(t *testing.T) {
|
||||||
|
var _ Fixer = new(FixerParallelsHeadless)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFixerParallelsHeadless_Fix(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
Input map[string]interface{}
|
||||||
|
Expected map[string]interface{}
|
||||||
|
}{
|
||||||
|
// No headless field
|
||||||
|
{
|
||||||
|
Input: map[string]interface{}{
|
||||||
|
"type": "parallels-iso",
|
||||||
|
},
|
||||||
|
|
||||||
|
Expected: map[string]interface{}{
|
||||||
|
"type": "parallels-iso",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Headless field
|
||||||
|
{
|
||||||
|
Input: map[string]interface{}{
|
||||||
|
"type": "parallels-iso",
|
||||||
|
"headless": false,
|
||||||
|
},
|
||||||
|
|
||||||
|
Expected: map[string]interface{}{
|
||||||
|
"type": "parallels-iso",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
var f FixerParallelsHeadless
|
||||||
|
|
||||||
|
input := map[string]interface{}{
|
||||||
|
"builders": []map[string]interface{}{tc.Input},
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := map[string]interface{}{
|
||||||
|
"builders": []map[string]interface{}{tc.Expected},
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := f.Fix(input)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(output, expected) {
|
||||||
|
t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue