Merge pull request #6204 from arizvisa/GH-6197

Specify "bios.hddOrder" during the CreateVMX step for the vmware-iso builder.
This commit is contained in:
Megan Marsh 2018-08-24 15:46:31 -07:00 committed by GitHub
commit bf191d1ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -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" {

View File

@ -21,6 +21,8 @@ type vmxTemplateData struct {
ISOPath string
Version string
HDD_BootOrder string
SCSI_Present string
SCSI_diskAdapterType string
SATA_Present string
@ -382,6 +384,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",
@ -396,23 +399,28 @@ 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":
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
@ -422,6 +430,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
@ -641,7 +650,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"