|
|
|
|
@ -20,9 +20,10 @@ import (
|
|
|
|
|
// Produces:
|
|
|
|
|
// display_name string - Value of the displayName key set in the VMX file
|
|
|
|
|
type StepConfigureVMX struct {
|
|
|
|
|
CustomData map[string]string
|
|
|
|
|
SkipFloppy bool
|
|
|
|
|
VMName string
|
|
|
|
|
CustomData map[string]string
|
|
|
|
|
DisplayName string
|
|
|
|
|
SkipFloppy bool
|
|
|
|
|
VMName string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
|
|
|
|
@ -73,6 +74,25 @@ func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) mult
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the build is taking place on a remote ESX server, the displayName
|
|
|
|
|
// will be needed for discovery of the VM's IP address and for export
|
|
|
|
|
// of the VM. The displayName key should always be set in the VMX file,
|
|
|
|
|
// so error if we don't find it and the user has not set it in the config.
|
|
|
|
|
if s.DisplayName != "" {
|
|
|
|
|
vmxData["displayname"] = s.DisplayName
|
|
|
|
|
state.Put("display_name", s.DisplayName)
|
|
|
|
|
} else {
|
|
|
|
|
displayName, ok := vmxData["displayname"]
|
|
|
|
|
if !ok { // Packer converts key names to lowercase!
|
|
|
|
|
err := fmt.Errorf("Error: Could not get value of displayName from VMX data")
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
ui.Error(err.Error())
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
} else {
|
|
|
|
|
state.Put("display_name", displayName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = WriteVMX(vmxPath, vmxData)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
@ -82,19 +102,6 @@ func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) mult
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the build is taking place on a remote ESX server, the displayName
|
|
|
|
|
// will be needed for discovery of the VM's IP address and for export
|
|
|
|
|
// of the VM. The displayName key should always be set in the VMX file,
|
|
|
|
|
// so error if we don't find it
|
|
|
|
|
if displayName, ok := vmxData["displayname"]; !ok { // Packer converts key names to lowercase!
|
|
|
|
|
err := fmt.Errorf("Error: Could not get value of displayName from VMX data")
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
ui.Error(err.Error())
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
} else {
|
|
|
|
|
state.Put("display_name", displayName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|