github.com/rothwerx/packer@v0.9.0/builder/parallels/iso/step_create_disk.go (about) 1 package iso 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 parallelscommon "github.com/mitchellh/packer/builder/parallels/common" 7 "github.com/mitchellh/packer/packer" 8 "strconv" 9 ) 10 11 // This step creates the virtual disk that will be used as the 12 // hard drive for the virtual machine. 13 type stepCreateDisk struct{} 14 15 func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { 16 config := state.Get("config").(*Config) 17 driver := state.Get("driver").(parallelscommon.Driver) 18 ui := state.Get("ui").(packer.Ui) 19 vmName := state.Get("vmName").(string) 20 21 command := []string{ 22 "set", vmName, 23 "--device-add", "hdd", 24 "--size", strconv.FormatUint(uint64(config.DiskSize), 10), 25 "--iface", config.HardDriveInterface, 26 } 27 28 ui.Say("Creating hard drive...") 29 err := driver.Prlctl(command...) 30 if err != nil { 31 err := fmt.Errorf("Error creating hard drive: %s", err) 32 state.Put("error", err) 33 ui.Error(err.Error()) 34 return multistep.ActionHalt 35 } 36 37 return multistep.ActionContinue 38 } 39 40 func (s *stepCreateDisk) Cleanup(state multistep.StateBag) {}