Added support for specifying the number of cores as `cores` to vmware-common.

This commit is contained in:
Ali Rizvi-Santiago 2019-01-11 18:58:57 -06:00
parent 32f226eda0
commit 062c62eed8
2 changed files with 11 additions and 0 deletions

View File

@ -14,6 +14,7 @@ type HWConfig struct {
// cpu information
CpuCount int `mapstructure:"cpus"`
MemorySize int `mapstructure:"memory"`
CoreCount int `mapstructure:"cores"`
// network type and adapter
Network string `mapstructure:"network"`
@ -40,6 +41,11 @@ func (c *HWConfig) Prepare(ctx *interpolate.Context) []error {
errs = append(errs, fmt.Errorf("An invalid amount of memory was specified (memory < 0): %d", c.MemorySize))
}
// Hardware and cpu options
if c.CoreCount < 0 {
errs = append(errs, fmt.Errorf("An invalid number of cores was specified (cores < 0): %d", c.CoreCount))
}
// Peripherals
if !c.Sound {
c.Sound = false

View File

@ -8,6 +8,7 @@ import (
func testHWConfig() *HWConfig {
return &HWConfig{
CpuCount: 1,
CoreCount: 1,
MemorySize: 512,
Sound: true,
@ -26,6 +27,10 @@ func TestHWConfigPrepare(t *testing.T) {
t.Errorf("bad cpu count: %d", c.CpuCount)
}
if c.CoreCount < 0 {
t.Errorf("bad core count: %d", c.CoreCount)
}
if c.MemorySize < 0 {
t.Errorf("bad memory size: %d", c.MemorySize)
}