github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/builder/parallels/iso/step_create_disk.go (about) 1 package iso 2 3 import ( 4 "fmt" 5 "strconv" 6 7 parallelscommon "github.com/hashicorp/packer/builder/parallels/common" 8 "github.com/hashicorp/packer/packer" 9 "github.com/mitchellh/multistep" 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 "--type", config.DiskType, 26 "--size", strconv.FormatUint(uint64(config.DiskSize), 10), 27 "--iface", config.HardDriveInterface, 28 } 29 30 ui.Say("Creating hard drive...") 31 err := driver.Prlctl(command...) 32 if err != nil { 33 err := fmt.Errorf("Error creating hard drive: %s", err) 34 state.Put("error", err) 35 ui.Error(err.Error()) 36 return multistep.ActionHalt 37 } 38 39 return multistep.ActionContinue 40 } 41 42 func (s *stepCreateDisk) Cleanup(state multistep.StateBag) {}