2013-06-04 18:00:58 -04:00
|
|
|
package vmware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
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 {
|
|
|
|
// TODO(mitchellh): Configurable disk size
|
|
|
|
// TODO(mitchellh): Capture error output in case things go wrong to report it
|
|
|
|
|
|
|
|
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-06-06 15:19:38 -04:00
|
|
|
output := filepath.Join(config.OutputDir, config.DiskName+".vmdk")
|
|
|
|
if err := driver.CreateDisk(output, "40000M"); err != nil {
|
2013-06-04 18:00:58 -04:00
|
|
|
ui.Error(fmt.Sprintf("Error creating VMware disk: %s", err))
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stepCreateDisk) Cleanup(map[string]interface{}) {}
|