From 5d8b476a7ff2c1a16b8e5cf66b919b9da394d65d Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Thu, 26 Apr 2018 14:01:58 -0500 Subject: [PATCH 1/3] Fixed the regex in common/step_clean_vmx.go for the VMware builder to also support removal of sata-based cdrom devices. Also added a comment in iso/step_create_vmx.go that links both pieces of related code. --- builder/vmware/common/step_clean_vmx.go | 2 +- builder/vmware/iso/step_create_vmx.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/builder/vmware/common/step_clean_vmx.go b/builder/vmware/common/step_clean_vmx.go index f112227f8..db0db5aac 100644 --- a/builder/vmware/common/step_clean_vmx.go +++ b/builder/vmware/common/step_clean_vmx.go @@ -47,7 +47,7 @@ func (s StepCleanVMX) Run(_ context.Context, state multistep.StateBag) multistep } vmxData["floppy0.present"] = "FALSE" - devRe := regexp.MustCompile(`^ide\d:\d\.`) + devRe := regexp.MustCompile(`^(ide|sata)\d:\d\.`) for k, v := range vmxData { ide := devRe.FindString(k) if ide == "" || v != "cdrom-image" { diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index db9010a04..0f68736ea 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -396,6 +396,8 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist /// Use the disk adapter type that the user specified to tweak the .vmx // Also sync the cdrom adapter type according to what's common for that disk type. + // XXX: If the cdrom type is modified, make sure to update common/step_clean_vmx.go + // so that it will regex the correct cdrom device for removal. diskAdapterType := strings.ToLower(config.DiskAdapterType) switch diskAdapterType { case "ide": From 0e519d79e06909f30b16858e4fd38180ddc9f949 Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Thu, 26 Apr 2018 14:16:50 -0500 Subject: [PATCH 2/3] Modified iso/step_create_vmx.go in the vmware-iso builder to also specify the "bios.hddOrder" field depending on the hdd device that was specified. This might close issue #6197 --- builder/vmware/iso/step_create_vmx.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 0f68736ea..6273fa3b3 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -382,6 +382,7 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist NVME_Present: "FALSE", DiskType: "scsi", + HDD_BootOrder: "scsi0:0", CDROMType: "ide", CDROMType_MasterSlave: "0", @@ -404,17 +405,20 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist templateData.DiskType = "ide" templateData.CDROMType = "ide" templateData.CDROMType_MasterSlave = "1" + templateData.HDD_BootOrder = "ide0:0" case "sata": templateData.SATA_Present = "TRUE" templateData.DiskType = "sata" templateData.CDROMType = "sata" templateData.CDROMType_MasterSlave = "1" + templateData.HDD_BootOrder = "sata0:0" case "nvme": templateData.NVME_Present = "TRUE" templateData.DiskType = "nvme" templateData.SATA_Present = "TRUE" templateData.CDROMType = "sata" templateData.CDROMType_MasterSlave = "0" + templateData.HDD_BootOrder = "nvme0:0" case "scsi": diskAdapterType = "lsilogic" fallthrough @@ -424,6 +428,7 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist templateData.DiskType = "scsi" templateData.CDROMType = "ide" templateData.CDROMType_MasterSlave = "0" + templateData.HDD_BootOrder = "scsi0:0" } /// Handle the cdrom adapter type. If the disk adapter type and the @@ -643,7 +648,8 @@ func (s *stepCreateVMX) Cleanup(multistep.StateBag) { // do so by specifying in the builder configuration. const DefaultVMXTemplate = ` .encoding = "UTF-8" -bios.bootOrder = "hdd,CDROM" +bios.bootOrder = "hdd,cdrom" +bios.hddOrder = "{{ .HDD_BootOrder }}" checkpoint.vmState = "" cleanShutdown = "TRUE" config.version = "8" From 673d4579e448fe530c6a362aeba07d2976f43c09 Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Thu, 26 Apr 2018 14:22:37 -0500 Subject: [PATCH 3/3] Ack! Forgot to include the template variable in the definition for vmxTemplateData for commit 0e519d79e06909f30b16858e4fd38180ddc9f949. Now it's added.. --- builder/vmware/iso/step_create_vmx.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 6273fa3b3..432d543fe 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -21,6 +21,8 @@ type vmxTemplateData struct { ISOPath string Version string + HDD_BootOrder string + SCSI_Present string SCSI_diskAdapterType string SATA_Present string