From 1aa102dd068bad84b04312d51a7b44ad6a5eb5a7 Mon Sep 17 00:00:00 2001 From: Nick Cronin Date: Thu, 25 Sep 2014 14:20:35 +1000 Subject: [PATCH 1/2] addresses #1191 - Add VMWare virtualhw.version configuration option under 'version' --- builder/vmware/iso/builder.go | 5 +++++ builder/vmware/iso/builder_test.go | 4 ++++ builder/vmware/iso/step_create_vmx.go | 4 +++- website/source/docs/builders/vmware-iso.html.markdown | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 693d97e9b..da8ecd5c8 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -40,6 +40,7 @@ type config struct { ISOChecksum string `mapstructure:"iso_checksum"` ISOChecksumType string `mapstructure:"iso_checksum_type"` ISOUrls []string `mapstructure:"iso_urls"` + Version string `mapstructure:"version"` VMName string `mapstructure:"vm_name"` BootCommand []string `mapstructure:"boot_command"` SkipCompaction bool `mapstructure:"skip_compaction"` @@ -110,6 +111,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { b.config.VMName = fmt.Sprintf("packer-%s", b.config.PackerBuildName) } + if b.config.Version == "" { + b.config.Version = "9" + } + if b.config.RemoteUser == "" { b.config.RemoteUser = "root" } diff --git a/builder/vmware/iso/builder_test.go b/builder/vmware/iso/builder_test.go index f3c1dfd59..b6c0cfd81 100644 --- a/builder/vmware/iso/builder_test.go +++ b/builder/vmware/iso/builder_test.go @@ -134,6 +134,10 @@ func TestBuilderPrepare_Defaults(t *testing.T) { t.Errorf("bad output dir: %s", b.config.OutputDir) } + if b.config.Version != "9" { + t.Errorf("bad Version: %s", b.config.Version) + } + if b.config.SSHWaitTimeout != (20 * time.Minute) { t.Errorf("bad wait timeout: %s", b.config.SSHWaitTimeout) } diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 8544a1405..e490e639b 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -15,6 +15,7 @@ type vmxTemplateData struct { GuestOS string DiskName string ISOPath string + Version string } // This step creates the VMX file for the VM. @@ -41,6 +42,7 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { Name: config.VMName, GuestOS: config.GuestOSType, DiskName: config.DiskName, + Version: config.Version, ISOPath: isoPath, } @@ -180,7 +182,7 @@ tools.upgrade.policy = "upgradeAtPowerCycle" usb.pciSlotNumber = "32" usb.present = "FALSE" virtualHW.productCompatibility = "hosted" -virtualHW.version = "9" +virtualHW.version = "{{ .Version }}" vmci0.id = "1861462627" vmci0.pciSlotNumber = "35" vmci0.present = "TRUE" diff --git a/website/source/docs/builders/vmware-iso.html.markdown b/website/source/docs/builders/vmware-iso.html.markdown index 73beea129..3bf9c90b6 100644 --- a/website/source/docs/builders/vmware-iso.html.markdown +++ b/website/source/docs/builders/vmware-iso.html.markdown @@ -216,6 +216,8 @@ each category, the available options are alphabetized and described. `tools_upload_flavor`. By default the upload path is set to `{{.Flavor}}.iso`. +* `version` (string) - This is the vmx hardware version for the new virtual machine, by default this is '9'. [reference document](http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003746) + * `vm_name` (string) - This is the name of the VMX file for the new virtual machine, without the file extension. By default this is "packer-BUILDNAME", where "BUILDNAME" is the name of the build. @@ -320,6 +322,7 @@ these variables isn't required, however. * `GuestOS` - The VMware-valid guest OS type. * `DiskName` - The filename (without the suffix) of the main virtual disk. * `ISOPath` - The path to the ISO to use for the OS installation. +* `Version` - The Hardware version VMWare will execute this vm under. Also known as the `virtualhw.version`. ## Building on a Remote vSphere Hypervisor From da0c1cbd8c45babde23d8397c216bc817b9f7da9 Mon Sep 17 00:00:00 2001 From: Nick Cronin Date: Tue, 28 Oct 2014 11:44:35 +1100 Subject: [PATCH 2/2] #1191 - highlight 'experimental' state of VMWare vmx.version in docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per the comments on the pull request It was felt that vmx hardware version should be more explicitly documented as ‘experimental’ when using a non default value. --- website/source/docs/builders/vmware-iso.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/builders/vmware-iso.html.markdown b/website/source/docs/builders/vmware-iso.html.markdown index 3bf9c90b6..a7246e5ae 100644 --- a/website/source/docs/builders/vmware-iso.html.markdown +++ b/website/source/docs/builders/vmware-iso.html.markdown @@ -216,7 +216,7 @@ each category, the available options are alphabetized and described. `tools_upload_flavor`. By default the upload path is set to `{{.Flavor}}.iso`. -* `version` (string) - This is the vmx hardware version for the new virtual machine, by default this is '9'. [reference document](http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003746) +* `version` (string) - The [vmx hardware version](http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003746) for the new virtual machine. Only the default value has been tested, any other value is expiermental. Default value is '9'. * `vm_name` (string) - This is the name of the VMX file for the new virtual machine, without the file extension. By default this is "packer-BUILDNAME",