diff --git a/builder/vmware/common/driver.go b/builder/vmware/common/driver.go index b230d84b9..a8a898a21 100644 --- a/builder/vmware/common/driver.go +++ b/builder/vmware/common/driver.go @@ -15,7 +15,6 @@ import ( "strings" "time" - "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" ) @@ -82,7 +81,7 @@ type Driver interface { // NewDriver returns a new driver implementation for this operating // system, or an error if the driver couldn't be initialized. -func NewDriver(dconfig *DriverConfig, config *SSHConfig, commConfig *communicator.Config, vmName string) (Driver, error) { +func NewDriver(dconfig *DriverConfig, config *SSHConfig, vmName string) (Driver, error) { drivers := []Driver{} if dconfig.RemoteType != "" { @@ -97,7 +96,7 @@ func NewDriver(dconfig *DriverConfig, config *SSHConfig, commConfig *communicato CacheDatastore: dconfig.RemoteCacheDatastore, CacheDirectory: dconfig.RemoteCacheDirectory, VMName: vmName, - CommConfig: *commConfig, + CommConfig: *(&config.Comm), }, } diff --git a/builder/vmware/common/export_config.go b/builder/vmware/common/export_config.go index 663972847..79c4eaeea 100644 --- a/builder/vmware/common/export_config.go +++ b/builder/vmware/common/export_config.go @@ -11,6 +11,7 @@ type ExportConfig struct { OVFToolOptions []string `mapstructure:"ovftool_options"` SkipExport bool `mapstructure:"skip_export"` KeepRegistered bool `mapstructure:"keep_registered"` + SkipCompaction bool `mapstructure:"skip_compaction"` } func (c *ExportConfig) Prepare(ctx *interpolate.Context) []error { diff --git a/builder/vmware/common/step_export.go b/builder/vmware/common/step_export.go index 088541d0d..173de488b 100644 --- a/builder/vmware/common/step_export.go +++ b/builder/vmware/common/step_export.go @@ -26,7 +26,7 @@ type StepExport struct { OutputDir string } -func (s *StepExport) generateArgs(c *DriverConfig, displayName string, outputPath string, hidePassword bool) []string { +func (s *StepExport) generateArgs(c *DriverConfig, displayName string, hidePassword bool) []string { password := url.QueryEscape(c.RemotePassword) if hidePassword { password = "****" @@ -37,7 +37,7 @@ func (s *StepExport) generateArgs(c *DriverConfig, displayName string, outputPat "-tt=" + s.Format, "vi://" + c.RemoteUser + ":" + password + "@" + c.RemoteHost + "/" + displayName, - outputPath, + s.OutputDir, } return append(s.OVFToolOptions, args...) } diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 9ec662dca..129180d1f 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -66,17 +66,9 @@ type Config struct { Serial string `mapstructure:"serial"` Parallel string `mapstructure:"parallel"` - // booting a guest - KeepRegistered bool `mapstructure:"keep_registered"` - OVFToolOptions []string `mapstructure:"ovftool_options"` - SkipCompaction bool `mapstructure:"skip_compaction"` - SkipExport bool `mapstructure:"skip_export"` - VMXDiskTemplatePath string `mapstructure:"vmx_disk_template_path"` VMXTemplatePath string `mapstructure:"vmx_template_path"` - CommConfig communicator.Config `mapstructure:",squash"` - ctx interpolate.Context } @@ -232,7 +224,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { } func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { - driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, &b.config.CommConfig, b.config.VMName) + driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) } @@ -369,6 +361,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, }, } diff --git a/builder/vmware/iso/builder_test.go b/builder/vmware/iso/builder_test.go index 59e18907d..b17fb95ab 100644 --- a/builder/vmware/iso/builder_test.go +++ b/builder/vmware/iso/builder_test.go @@ -459,13 +459,13 @@ func TestBuilderPrepare_CommConfig(t *testing.T) { t.Fatalf("should not have error: %s", err) } - if b.config.CommConfig.WinRMUser != "username" { - t.Errorf("bad winrm_username: %s", b.config.CommConfig.WinRMUser) + if b.config.SSHConfig.Comm.WinRMUser != "username" { + t.Errorf("bad winrm_username: %s", b.config.SSHConfig.Comm.WinRMUser) } - if b.config.CommConfig.WinRMPassword != "password" { - t.Errorf("bad winrm_password: %s", b.config.CommConfig.WinRMPassword) + if b.config.SSHConfig.Comm.WinRMPassword != "password" { + t.Errorf("bad winrm_password: %s", b.config.SSHConfig.Comm.WinRMPassword) } - if host := b.config.CommConfig.Host(); host != "1.2.3.4" { + if host := b.config.SSHConfig.Comm.Host(); host != "1.2.3.4" { t.Errorf("bad host: %s", host) } } @@ -487,13 +487,13 @@ func TestBuilderPrepare_CommConfig(t *testing.T) { t.Fatalf("should not have error: %s", err) } - if b.config.CommConfig.SSHUsername != "username" { - t.Errorf("bad ssh_username: %s", b.config.CommConfig.SSHUsername) + if b.config.SSHConfig.Comm.SSHUsername != "username" { + t.Errorf("bad ssh_username: %s", b.config.SSHConfig.Comm.SSHUsername) } - if b.config.CommConfig.SSHPassword != "password" { - t.Errorf("bad ssh_password: %s", b.config.CommConfig.SSHPassword) + if b.config.SSHConfig.Comm.SSHPassword != "password" { + t.Errorf("bad ssh_password: %s", b.config.SSHConfig.Comm.SSHPassword) } - if host := b.config.CommConfig.Host(); host != "1.2.3.4" { + if host := b.config.SSHConfig.Comm.Host(); host != "1.2.3.4" { t.Errorf("bad host: %s", host) } } diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index 4f0a5258c..017e32918 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -34,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { // Run executes a Packer build and returns a packer.Artifact representing // a VMware image. func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { - driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, &b.config.CommConfig, b.config.VMName) + driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) } diff --git a/builder/vmware/vmx/config.go b/builder/vmware/vmx/config.go index e21daba2f..0c726f590 100644 --- a/builder/vmware/vmx/config.go +++ b/builder/vmware/vmx/config.go @@ -7,7 +7,6 @@ import ( vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" - "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" @@ -28,14 +27,10 @@ type Config struct { vmwcommon.VMXConfig `mapstructure:",squash"` vmwcommon.ExportConfig `mapstructure:",squash"` - Linked bool `mapstructure:"linked"` - RemoteType string `mapstructure:"remote_type"` - SkipCompaction bool `mapstructure:"skip_compaction"` - BootCommand []string `mapstructure:"boot_command"` - SourcePath string `mapstructure:"source_path"` - VMName string `mapstructure:"vm_name"` - - CommConfig communicator.Config `mapstructure:",squash"` + Linked bool `mapstructure:"linked"` + RemoteType string `mapstructure:"remote_type"` + SourcePath string `mapstructure:"source_path"` + VMName string `mapstructure:"vm_name"` ctx interpolate.Context }