From 3991b0e95cb786803c0ca836a8f1e444f2114631 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Sat, 1 Jul 2017 23:43:40 +0300 Subject: [PATCH] Add 'CPU_reservation' parameter --- README.md | 2 ++ step_hardware.go | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc51a0807..3fd9f9ec0 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Destination: Hardware customization: * `CPUs` - number of CPU sockets. Inherited from source VM by default. +* `CPU_reservation` - Amount of reserved CPU resources in MHz. Inherited from source VM by default. * `RAM` - Amount of RAM in megabytes. Inherited from source VM by default. Provisioning: @@ -98,6 +99,7 @@ Post-processing: "linked_clone": true, "CPUs": 2, + "CPU_reservation": 1000, "RAM": 8192, "ssh_username": "root", diff --git a/step_hardware.go b/step_hardware.go index 38771c332..2a1ea04af 100644 --- a/step_hardware.go +++ b/step_hardware.go @@ -9,8 +9,9 @@ import ( ) type HardwareConfig struct { - CPUs int32 `mapstructure:"CPUs"` - RAM int64 `mapstructure:"RAM"` + CPUs int32 `mapstructure:"CPUs"` + CPUReservation int64 `mapstructure:"CPU_reservation"` + RAM int64 `mapstructure:"RAM"` } type StepConfigureHardware struct { @@ -29,6 +30,10 @@ func (s *StepConfigureHardware) Run(state multistep.StateBag) multistep.StepActi confSpec.NumCPUs = s.config.CPUs confSpec.MemoryMB = s.config.RAM + var cpuSpec types.ResourceAllocationInfo + cpuSpec.Reservation = s.config.CPUReservation + confSpec.CpuAllocation = &cpuSpec + task, err := vm.Reconfigure(ctx, confSpec) if err != nil { state.Put("error", err)