Merge pull request #7048 from hashicorp/follow_up_7019
fix defaulting/lack thereof for cpu count and memory in vmware template
This commit is contained in:
commit
2174652876
|
@ -49,8 +49,11 @@ func (a *artifact) State(name string) interface{} {
|
|||
}
|
||||
|
||||
func (a *artifact) Destroy() error {
|
||||
if a.dir != nil {
|
||||
return a.dir.RemoveAll()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewArtifact(remoteType string, format string, exportOutputPath string, vmName string, skipExport bool, keepRegistered bool, state multistep.StateBag) (packer.Artifact, error) {
|
||||
var files []string
|
||||
|
|
|
@ -315,6 +315,18 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist
|
|||
templateData.Serial_Host = ""
|
||||
templateData.Serial_Auto = "FALSE"
|
||||
|
||||
// Set the number of cpus if it was specified
|
||||
if config.HWConfig.CpuCount > 0 {
|
||||
templateData.CpuCount = strconv.Itoa(config.HWConfig.CpuCount)
|
||||
}
|
||||
|
||||
// Apply the memory size that was specified
|
||||
if config.HWConfig.MemorySize > 0 {
|
||||
templateData.MemorySize = strconv.Itoa(config.HWConfig.MemorySize)
|
||||
} else {
|
||||
templateData.MemorySize = "512"
|
||||
}
|
||||
|
||||
switch serial.Union.(type) {
|
||||
case *vmwcommon.SerialConfigPipe:
|
||||
templateData.Serial_Type = "pipe"
|
||||
|
@ -412,15 +424,8 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist
|
|||
|
||||
/// Now to handle options that will modify the template
|
||||
vmxData := vmwcommon.ParseVMX(vmxContents)
|
||||
|
||||
// Set the number of cpus if it was specified
|
||||
if config.HWConfig.CpuCount > 0 {
|
||||
vmxData["numvcpus"] = strconv.Itoa(config.HWConfig.CpuCount)
|
||||
}
|
||||
|
||||
// Apply the memory size that was specified
|
||||
if config.HWConfig.MemorySize > 0 {
|
||||
vmxData["memsize"] = strconv.Itoa(config.HWConfig.MemorySize)
|
||||
if vmxData["numvcpus"] == "" {
|
||||
delete(vmxData, "numvcpus")
|
||||
}
|
||||
|
||||
/// Write the vmxData to the vmxPath
|
||||
|
|
Loading…
Reference in New Issue