rename 'cpus' to 'CPUs'

This commit is contained in:
Michael Kuzmin 2017-07-01 18:03:52 +03:00
parent 172118bbe5
commit 2a43e5039e
4 changed files with 10 additions and 10 deletions

View File

@ -59,7 +59,7 @@ Destination:
* `linked_clone` - create VM as a linked clone from latest snapshot. `false` by default.
Hardware customization:
* `cpus` - number of CPU sockets. Inherited from source VM by default.
* `CPUs` - number of CPU sockets. Inherited from source VM by default.
* `ram` - Amount of RAM in megabytes. Inherited from source VM by default.
Post-processing:
@ -92,7 +92,7 @@ Post-processing:
"datastore": "datastore1",
"linked_clone": true,
"cpus": 2,
"CPUs": 2,
"ram": 8192,
"ssh_username": "root",

View File

@ -36,7 +36,7 @@ type Config struct {
ShutdownTimeout time.Duration
// Customization
Cpus string `mapstructure:"cpus"`
CPUs string `mapstructure:"CPUs"`
ShutdownCommand string `mapstructure:"shutdown_command"`
Ram string `mapstructure:"RAM"`
CreateSnapshot bool `mapstructure:"create_snapshot"`
@ -83,9 +83,9 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
// Verify numeric parameters if present
if c.Cpus != "" {
if _, err = strconv.Atoi(c.Cpus); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Invalid number of cpu sockets"))
if c.CPUs != "" {
if _, err = strconv.Atoi(c.CPUs); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Invalid number of CPU sockets"))
}
}
if c.Ram != "" {

View File

@ -13,7 +13,7 @@ func TestMinimalConfig(t *testing.T) {
func TestInvalidCpu(t *testing.T) {
raw := minimalConfig()
raw["cpus"] = "string"
raw["CPUs"] = "string"
_, warns, errs := NewConfig(raw)
testConfigErr(t, warns, errs)
}

View File

@ -25,14 +25,14 @@ func (s *StepConfigureHW) Run(state multistep.StateBag) multistep.StepAction {
var confSpec types.VirtualMachineConfigSpec
parametersFlag := ConfigParametersFlag{}
// configure HW
if s.config.Cpus != "" {
cpus, err := strconv.Atoi(s.config.Cpus)
if s.config.CPUs != "" {
CPUs, err := strconv.Atoi(s.config.CPUs)
if err != nil {
state.Put("error", err)
return multistep.ActionHalt
}
confSpec.NumCPUs = int32(cpus)
confSpec.NumCPUs = int32(CPUs)
parametersFlag.NumCPUsPtr = &(confSpec.NumCPUs)
}
if s.config.Ram != "" {