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