Add a computed FullDiskPath config option.

This commit is contained in:
Steven Merrill 2013-07-01 22:22:00 -04:00
parent ac5c90bd7e
commit 4de76ccd3f
2 changed files with 5 additions and 2 deletions

View File

@ -52,6 +52,7 @@ type config struct {
PackerBuildName string `mapstructure:"packer_build_name"`
PackerDebug bool `mapstructure:"packer_debug"`
FullDiskPath string ``
RawBootWait string `mapstructure:"boot_wait"`
RawShutdownTimeout string `mapstructure:"shutdown_timeout"`
@ -114,6 +115,9 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b.config.ToolsUploadPath = "{{ .Flavor }}.iso"
}
// Store the full path to the disk file.
b.config.FullDiskPath = filepath.Join(b.config.OutputDir, b.config.DiskName+".vmdk")
// Accumulate any errors
var err error
errs := make([]error, 0)

View File

@ -24,8 +24,7 @@ func (stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction {
ui := state["ui"].(packer.Ui)
ui.Say("Creating virtual machine disk")
output := filepath.Join(config.OutputDir, config.DiskName+".vmdk")
if err := driver.CreateDisk(output, fmt.Sprintf("%dM", config.DiskSize)); err != nil {
if err := driver.CreateDisk(config.FullDiskPath, fmt.Sprintf("%dM", config.DiskSize)); err != nil {
err := fmt.Errorf("Error creating disk: %s", err)
state["error"] = err
ui.Error(err.Error())