Commit 2860bfdf authored by Mikhail Zholobov's avatar Mikhail Zholobov

builder/parallels: Apply default settings on the VM creation step.

parent f7af571c
...@@ -23,37 +23,33 @@ func (s *stepCreateVM) Run(state multistep.StateBag) multistep.StepAction { ...@@ -23,37 +23,33 @@ func (s *stepCreateVM) Run(state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
name := config.VMName name := config.VMName
commands := make([][]string, 8) command := []string{
commands[0] = []string{
"create", name, "create", name,
"--distribution", config.GuestOSType, "--distribution", config.GuestOSType,
"--dst", config.OutputDir, "--dst", config.OutputDir,
"--vmtype", "vm", "--vmtype", "vm",
"--no-hdd", "--no-hdd",
} }
commands[1] = []string{"set", name, "--cpus", "1"}
commands[2] = []string{"set", name, "--memsize", "512"}
commands[3] = []string{"set", name, "--startup-view", "same"}
commands[4] = []string{"set", name, "--on-shutdown", "close"}
commands[5] = []string{"set", name, "--on-window-close", "keep-running"}
commands[6] = []string{"set", name, "--auto-share-camera", "off"}
commands[7] = []string{"set", name, "--smart-guard", "off"}
ui.Say("Creating virtual machine...") ui.Say("Creating virtual machine...")
for _, command := range commands { if err := driver.Prlctl(command...); err != nil {
err := driver.Prlctl(command...) err := fmt.Errorf("Error creating VM: %s", err)
ui.Say(fmt.Sprintf("Executing: prlctl %s", command)) state.Put("error", err)
if err != nil { ui.Error(err.Error())
err := fmt.Errorf("Error creating VM: %s", err) return multistep.ActionHalt
state.Put("error", err) }
ui.Error(err.Error())
return multistep.ActionHalt ui.Say("Applying default settings...")
} if err := driver.SetDefaultConfiguration(name); err != nil {
err := fmt.Errorf("Error VM configuration: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
// Set the VM name property on the first command // Set the VM name property on the first command
if s.vmName == "" { if s.vmName == "" {
s.vmName = name s.vmName = name
}
} }
// Set the final name in the state bag so others can use it // Set the final name in the state bag so others can use it
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment