diff --git a/builder/vmware/common/artifact.go b/builder/vmware/common/artifact.go index 729dc0e17..b8056e544 100644 --- a/builder/vmware/common/artifact.go +++ b/builder/vmware/common/artifact.go @@ -56,7 +56,7 @@ func NewArtifact(remoteType string, format string, exportOutputPath string, vmNa var files []string var dir OutputDir var err error - if remoteType != "" && format != "" && !skipExport { + if remoteType != "" && !skipExport { dir = new(LocalOutputDir) dir.SetOutputDir(exportOutputPath) files, err = dir.ListFiles() diff --git a/builder/vmware/common/step_register.go b/builder/vmware/common/step_register.go index 0d9b93b7b..6866e6703 100644 --- a/builder/vmware/common/step_register.go +++ b/builder/vmware/common/step_register.go @@ -53,7 +53,7 @@ func (s *StepRegister) Cleanup(state multistep.StateBag) { } if remoteDriver, ok := driver.(RemoteDriver); ok { - if s.Format == "" || s.SkipExport { + if s.SkipExport { ui.Say("Unregistering virtual machine...") if err := remoteDriver.Unregister(s.registeredPath); err != nil { ui.Error(fmt.Sprintf("Error unregistering VM: %s", err)) @@ -71,7 +71,7 @@ func (s *StepRegister) Cleanup(state multistep.StateBag) { if destroyed { break } - time.Sleep(150 * time.Millisecond) + time.Sleep(1 * time.Second) } } } diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 129180d1f..1a6b66171 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -238,6 +238,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe dir = new(vmwcommon.LocalOutputDir) } + // The OutputDir will track remote esxi output; exportOutputPath preserves + // the path to the output on the machine running Packer. + exportOutputPath := b.config.OutputDir + if b.config.RemoteType != "" { b.config.OutputDir = b.config.VMName } @@ -361,7 +365,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe SkipExport: b.config.SkipExport, VMName: b.config.VMName, OVFToolOptions: b.config.OVFToolOptions, - OutputDir: b.config.OutputDir, + OutputDir: exportOutputPath, }, } @@ -384,7 +388,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe } // Compile the artifact list - return vmwcommon.NewArtifact(b.config.RemoteType, b.config.Format, b.config.OutputDir, + return vmwcommon.NewArtifact(b.config.RemoteType, b.config.Format, exportOutputPath, b.config.VMName, b.config.SkipExport, b.config.KeepRegistered, state) } diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index 017e32918..9a633a40b 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -47,7 +47,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe default: dir = new(vmwcommon.LocalOutputDir) } - if b.config.RemoteType != "" && b.config.Format != "" { + + // The OutputDir will track remote esxi output; exportOutputPath preserves + // the path to the output on the machine running Packer. + exportOutputPath := b.config.OutputDir + + if b.config.RemoteType != "" { b.config.OutputDir = b.config.VMName } dir.SetOutputDir(b.config.OutputDir) @@ -159,6 +164,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe SkipExport: b.config.SkipExport, VMName: b.config.VMName, OVFToolOptions: b.config.OVFToolOptions, + OutputDir: exportOutputPath, }, } @@ -181,7 +187,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe } // Artifact - return vmwcommon.NewArtifact(b.config.RemoteType, b.config.Format, b.config.OutputDir, + log.Printf("Generating artifact...") + return vmwcommon.NewArtifact(b.config.RemoteType, b.config.Format, exportOutputPath, b.config.VMName, b.config.SkipExport, b.config.KeepRegistered, state) }