From 109ba2c54c5eca427efe67e570d47c4cc5add472 Mon Sep 17 00:00:00 2001 From: Eric Mowry Date: Thu, 28 Feb 2019 21:36:25 -0500 Subject: [PATCH] After testing a ISO and VMX clone along with setting the display_name option it was determined that having no name for the .vmxf file did not work either. Updating to check if displayName is not empty before using and falling back to VMName if displayName is empty. --- builder/vmware/common/step_configure_vmx.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/builder/vmware/common/step_configure_vmx.go b/builder/vmware/common/step_configure_vmx.go index fd8bdea87..1d94e4362 100644 --- a/builder/vmware/common/step_configure_vmx.go +++ b/builder/vmware/common/step_configure_vmx.go @@ -102,7 +102,16 @@ func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) mult } } - vmxData["extendedconfigfile"] = fmt.Sprintf("%s.vmxf", s.DisplayName) + // Set the extendedConfigFile setting for the .vmxf filename to the VMName + // if displayName is not set. This is needed so that when VMWare creates + // the .vmxf file it matches the displayName if it is set. When just using + // the sisplayName if it was empty VMWare would make a file named ".vmxf". + // The ".vmxf" file would not get deleted when the VM got deleted. + if s.DisplayName != "" { + vmxData["extendedconfigfile"] = fmt.Sprintf("%s.vmxf", s.DisplayName) + } else { + vmxData["extendedconfigfile"] = fmt.Sprintf("%s.vmxf", s.VMName) + } err = WriteVMX(vmxPath, vmxData)