Add option to skip export of installed VM for VMware iso builder

This commit is contained in:
DanHam 2017-01-10 11:44:11 +00:00
parent 377f451a9e
commit c7e8d671a9
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
2 changed files with 11 additions and 2 deletions

View File

@ -48,6 +48,7 @@ type Config struct {
BootCommand []string `mapstructure:"boot_command"`
KeepRegistered bool `mapstructure:"keep_registered"`
SkipCompaction bool `mapstructure:"skip_compaction"`
SkipExport bool `mapstructure:"skip_export"`
VMXTemplatePath string `mapstructure:"vmx_template_path"`
VMXDiskTemplatePath string `mapstructure:"vmx_disk_template_path"`
@ -301,7 +302,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
RemoteType: b.config.RemoteType,
},
&StepExport{
Format: b.config.Format,
Format: b.config.Format,
SkipExport: b.config.SkipExport,
},
}

View File

@ -14,7 +14,8 @@ import (
)
type StepExport struct {
Format string
Format string
SkipExport bool
}
func (s *StepExport) generateArgs(c *Config, outputPath string, hidePassword bool) []string {
@ -35,6 +36,12 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction {
c := state.Get("config").(*Config)
ui := state.Get("ui").(packer.Ui)
// Skip export if requested
if c.SkipExport {
ui.Say("Skipping export of virtual machine...")
return multistep.ActionContinue
}
if c.RemoteType != "esx5" || s.Format == "" {
return multistep.ActionContinue
}