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