diff --git a/builder/vmware/common/step_clean_vmx.go b/builder/vmware/common/step_clean_vmx.go old mode 100644 new mode 100755 index bf76f5863..44bf4c407 --- a/builder/vmware/common/step_clean_vmx.go +++ b/builder/vmware/common/step_clean_vmx.go @@ -51,8 +51,8 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { ui.Message("Detaching ISO from CD-ROM device...") - vmxData[ide+"devicetype"] = "cdrom-raw" - vmxData[ide+"filename"] = "auto detect" + vmxData[ide+"deviceType"] = "cdrom-raw" + vmxData[ide+"fileName"] = "auto detect" } ui.Message("Disabling VNC server...") diff --git a/builder/vmware/common/step_clean_vmx_test.go b/builder/vmware/common/step_clean_vmx_test.go old mode 100644 new mode 100755 index ea30fb54a..3ca6a7e23 --- a/builder/vmware/common/step_clean_vmx_test.go +++ b/builder/vmware/common/step_clean_vmx_test.go @@ -61,8 +61,8 @@ func TestStepCleanVMX_floppyPath(t *testing.T) { Value string }{ {"floppy0.present", "FALSE"}, - {"floppy0.filetype", ""}, - {"floppy0.filename", ""}, + {"floppy0.fileType", ""}, + {"floppy0.fileName", ""}, } for _, tc := range cases { @@ -109,9 +109,9 @@ func TestStepCleanVMX_isoPath(t *testing.T) { Key string Value string }{ - {"ide0:0.filename", "auto detect"}, - {"ide0:0.devicetype", "cdrom-raw"}, - {"ide0:1.filename", "bar"}, + {"ide0:0.fileName", "auto detect"}, + {"ide0:0.deviceType", "cdrom-raw"}, + {"ide0:1.fileName", "bar"}, {"foo", "bar"}, } @@ -130,12 +130,12 @@ func TestStepCleanVMX_isoPath(t *testing.T) { const testVMXFloppyPath = ` floppy0.present = "TRUE" -floppy0.filetype = "file" +floppy0.fileType = "file" ` const testVMXISOPath = ` -ide0:0.devicetype = "cdrom-image" -ide0:0.filename = "foo" -ide0:1.filename = "bar" +ide0:0.deviceType = "cdrom-image" +ide0:0.fileName = "foo" +ide0:1.fileName = "bar" foo = "bar" ` diff --git a/builder/vmware/common/step_configure_vmx.go b/builder/vmware/common/step_configure_vmx.go old mode 100644 new mode 100755 index 401d53055..14c68e76a --- a/builder/vmware/common/step_configure_vmx.go +++ b/builder/vmware/common/step_configure_vmx.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "log" "regexp" - "strings" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" @@ -53,7 +52,6 @@ func (s *StepConfigureVMX) Run(state multistep.StateBag) multistep.StepAction { // Set custom data for k, v := range s.CustomData { log.Printf("Setting VMX: '%s' = '%s'", k, v) - k = strings.ToLower(k) vmxData[k] = v } diff --git a/builder/vmware/common/vmx.go b/builder/vmware/common/vmx.go old mode 100644 new mode 100755 index e7cdb662f..ab0291807 --- a/builder/vmware/common/vmx.go +++ b/builder/vmware/common/vmx.go @@ -17,7 +17,7 @@ import ( func ParseVMX(contents string) map[string]string { results := make(map[string]string) - lineRe := regexp.MustCompile(`^(.+?)\s*=\s*"(.*?)"\s*$`) + lineRe := regexp.MustCompile(`^(.+?)\s*=\s*"?(.*?)"?\s*$`) for _, line := range strings.Split(contents, "\n") { matches := lineRe.FindStringSubmatch(line) @@ -25,8 +25,7 @@ func ParseVMX(contents string) map[string]string { continue } - key := strings.ToLower(matches[1]) - results[key] = matches[2] + results[matches[1]] = matches[2] } return results @@ -43,9 +42,22 @@ func EncodeVMX(contents map[string]string) string { i++ } + // a list of VMX key fragments that should not be wrapped in quotes, + // fragments because multiple disks can use the virtualSSD suffix + noQuotes := []string { + "virtualSSD", + } + sort.Strings(keys) for _, k := range keys { - buf.WriteString(fmt.Sprintf("%s = \"%s\"\n", k, contents[k])) + pat := "%s = \"%s\"\n" + for _, q := range noQuotes { + if strings.Contains(k, q) { + pat = "%s = %s\n" + break; + } + } + buf.WriteString(fmt.Sprintf(pat, k, contents[k])) } return buf.String() diff --git a/builder/vmware/vmx/step_clone_vmx.go b/builder/vmware/vmx/step_clone_vmx.go old mode 100644 new mode 100755 index a020e1627..1dbae678a --- a/builder/vmware/vmx/step_clone_vmx.go +++ b/builder/vmware/vmx/step_clone_vmx.go @@ -38,14 +38,14 @@ func (s *StepCloneVMX) Run(state multistep.StateBag) multistep.StepAction { } var diskName string - if _, ok := vmxData["scsi0:0.filename"]; ok { - diskName = vmxData["scsi0:0.filename"] + if _, ok := vmxData["scsi0:0.fileName"]; ok { + diskName = vmxData["scsi0:0.fileName"] } - if _, ok := vmxData["sata0:0.filename"]; ok { - diskName = vmxData["sata0:0.filename"] + if _, ok := vmxData["sata0:0.fileName"]; ok { + diskName = vmxData["sata0:0.fileName"] } - if _, ok := vmxData["ide0:0.filename"]; ok { - diskName = vmxData["ide0:0.filename"] + if _, ok := vmxData["ide0:0.fileName"]; ok { + diskName = vmxData["ide0:0.fileName"] } if diskName == "" { err := fmt.Errorf("Root disk filename could not be found!")