github.com/sneal/packer@v0.5.2/builder/vmware/iso/step_create_disk.go (about) 1 package iso 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 vmwcommon "github.com/mitchellh/packer/builder/vmware/common" 7 "github.com/mitchellh/packer/packer" 8 "path/filepath" 9 ) 10 11 // This step creates the virtual disks for the VM. 12 // 13 // Uses: 14 // config *config 15 // driver Driver 16 // ui packer.Ui 17 // 18 // Produces: 19 // full_disk_path (string) - The full path to the created disk. 20 type stepCreateDisk struct{} 21 22 func (stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { 23 config := state.Get("config").(*config) 24 driver := state.Get("driver").(vmwcommon.Driver) 25 ui := state.Get("ui").(packer.Ui) 26 27 ui.Say("Creating virtual machine disk") 28 full_disk_path := filepath.Join(config.OutputDir, config.DiskName+".vmdk") 29 if err := driver.CreateDisk(full_disk_path, fmt.Sprintf("%dM", config.DiskSize), config.DiskTypeId); err != nil { 30 err := fmt.Errorf("Error creating disk: %s", err) 31 state.Put("error", err) 32 ui.Error(err.Error()) 33 return multistep.ActionHalt 34 } 35 36 state.Put("full_disk_path", full_disk_path) 37 38 return multistep.ActionContinue 39 } 40 41 func (stepCreateDisk) Cleanup(multistep.StateBag) {}