packer-cn/builder/vmware/step_create_disk.go

40 lines
977 B
Go
Raw Normal View History

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>
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)
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 {
ui.Error(fmt.Sprintf("Error creating VMware disk: %s", err))
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (stepCreateDisk) Cleanup(map[string]interface{}) {}