Modified the cpus and memory options for the vmware builders to only apply them if they were specified.
This commit is contained in:
parent
fb7ce9f2b5
commit
61ee3a44f5
|
@ -36,17 +36,11 @@ func (c *HWConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
errs = append(errs, fmt.Errorf("An invalid number of cpus was specified (cpus < 0): %d", c.CpuCount))
|
||||
c.CpuCount = 0
|
||||
}
|
||||
if c.CpuCount == 0 {
|
||||
c.CpuCount = 1
|
||||
}
|
||||
|
||||
if c.MemorySize < 0 {
|
||||
errs = append(errs, fmt.Errorf("An invalid amount of memory was specified (memory < 0): %d", c.MemorySize))
|
||||
c.MemorySize = 0
|
||||
}
|
||||
if c.MemorySize == 0 {
|
||||
c.MemorySize = 512
|
||||
}
|
||||
|
||||
// Peripherals
|
||||
if !c.Sound {
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestHWConfigPrepare(t *testing.T) {
|
|||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
if c.CpuCount < 1 {
|
||||
if c.CpuCount < 0 {
|
||||
t.Errorf("bad cpu count: %d", c.CpuCount)
|
||||
}
|
||||
|
||||
|
|
|
@ -160,9 +160,6 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist
|
|||
Version: config.Version,
|
||||
ISOPath: isoPath,
|
||||
|
||||
CpuCount: strconv.Itoa(config.HWConfig.CpuCount),
|
||||
MemorySize: strconv.Itoa(config.HWConfig.MemorySize),
|
||||
|
||||
SCSI_Present: "FALSE",
|
||||
SCSI_diskAdapterType: "lsilogic",
|
||||
SATA_Present: "FALSE",
|
||||
|
@ -413,8 +410,22 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist
|
|||
s.tempDir = vmxDir
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
|
||||
/// Write the vmxData to the vmxPath
|
||||
vmxPath := filepath.Join(vmxDir, config.VMName+".vmx")
|
||||
if err := vmwcommon.WriteVMX(vmxPath, vmwcommon.ParseVMX(vmxContents)); err != nil {
|
||||
if err := vmwcommon.WriteVMX(vmxPath, vmxData); err != nil {
|
||||
err := fmt.Errorf("Error creating VMX file: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
|
|
Loading…
Reference in New Issue