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

View File

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

View File

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

View File

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