2014-04-06 13:21:22 -04:00
|
|
|
package iso
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
parallelscommon "github.com/mitchellh/packer/builder/parallels/common"
|
2014-05-01 17:24:19 -04:00
|
|
|
"github.com/mitchellh/packer/packer"
|
2014-04-06 13:21:22 -04:00
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This step creates the virtual disk that will be used as the
|
|
|
|
// hard drive for the virtual machine.
|
|
|
|
type stepCreateDisk struct{}
|
|
|
|
|
|
|
|
func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
config := state.Get("config").(*config)
|
|
|
|
driver := state.Get("driver").(parallelscommon.Driver)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
vmName := state.Get("vmName").(string)
|
|
|
|
|
|
|
|
command := []string{
|
|
|
|
"set", vmName,
|
2014-10-01 08:04:22 -04:00
|
|
|
"--device-add", "hdd",
|
2014-04-06 13:21:22 -04:00
|
|
|
"--size", strconv.FormatUint(uint64(config.DiskSize), 10),
|
|
|
|
"--iface", config.HardDriveInterface,
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.Say("Creating hard drive...")
|
|
|
|
err := driver.Prlctl(command...)
|
|
|
|
if err != nil {
|
|
|
|
err := fmt.Errorf("Error creating hard drive: %s", err)
|
|
|
|
state.Put("error", err)
|
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *stepCreateDisk) Cleanup(state multistep.StateBag) {}
|