remove unnecessary checks; we always default format to ovf if it is unset.

fix exportoutputdir
This commit is contained in:
Megan Marsh 2018-11-02 11:10:51 -07:00
parent c3144c2d0a
commit 5815b376b4
4 changed files with 18 additions and 7 deletions

View File

@ -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()

View File

@ -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)
}
}
}

View File

@ -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)
}

View File

@ -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)
}