2013-06-04 18:00:58 -04:00
|
|
|
package vmware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
2013-07-02 01:12:57 -04:00
|
|
|
"path/filepath"
|
2013-06-04 18:00:58 -04:00
|
|
|
)
|
|
|
|
|
2013-06-05 17:49:04 -04:00
|
|
|
// This step creates the virtual disks for the VM.
|
|
|
|
//
|
|
|
|
// Uses:
|
|
|
|
// config *config
|
2013-06-06 15:19:38 -04:00
|
|
|
// driver Driver
|
2013-06-05 17:49:04 -04:00
|
|
|
// ui packer.Ui
|
|
|
|
//
|
|
|
|
// Produces:
|
|
|
|
// <nothing>
|
2013-06-04 18:00:58 -04:00
|
|
|
type stepCreateDisk struct{}
|
|
|
|
|
|
|
|
func (stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction {
|
|
|
|
config := state["config"].(*config)
|
2013-06-06 15:19:38 -04:00
|
|
|
driver := state["driver"].(Driver)
|
2013-06-04 18:00:58 -04:00
|
|
|
ui := state["ui"].(packer.Ui)
|
|
|
|
|
|
|
|
ui.Say("Creating virtual machine disk")
|
2013-07-02 01:12:57 -04:00
|
|
|
full_disk_path := filepath.Join(config.OutputDir, config.DiskName+".vmdk")
|
2013-07-02 01:32:50 -04:00
|
|
|
state["full_disk_path"] = full_disk_path
|
2013-07-02 01:12:57 -04:00
|
|
|
if err := driver.CreateDisk(full_disk_path, fmt.Sprintf("%dM", config.DiskSize)); err != nil {
|
2013-06-20 00:20:48 -04:00
|
|
|
err := fmt.Errorf("Error creating disk: %s", err)
|
|
|
|
state["error"] = err
|
|
|
|
ui.Error(err.Error())
|
2013-06-04 18:00:58 -04:00
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stepCreateDisk) Cleanup(map[string]interface{}) {}
|