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