From 71c211fa0979cbeae0c4ab9550612aa099ff7c1b Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Sun, 2 Jul 2017 00:02:49 +0300 Subject: [PATCH] Add 'RAM_reservation' parameter --- README.md | 2 ++ step_hardware.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 7071f9b51..417b658e9 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Hardware customization: * `CPU_reservation` - Amount of reserved CPU resources in MHz. Inherited from source VM by default. * `CPU_limit` - Upper limit of available CPU resources in MHz. Inherited from source VM by default, set to `-1` for reset. * `RAM` - Amount of RAM in megabytes. Inherited from source VM by default. +* `RAM_reservation` - Amount of reserved RAM in MB. Inherited from source VM by default. Provisioning: * `ssh_username` - [**mandatory**] username in guest OS. @@ -103,6 +104,7 @@ Post-processing: "CPU_reservation": 1000, "CPU_limit": 2000, "RAM": 8192, + "RAM_reservation": 2048, "ssh_username": "root", "ssh_password": "{{user `guest_password`}}", diff --git a/step_hardware.go b/step_hardware.go index a420f122e..5675ab4f5 100644 --- a/step_hardware.go +++ b/step_hardware.go @@ -13,6 +13,7 @@ type HardwareConfig struct { CPUReservation int64 `mapstructure:"CPU_reservation"` CPULimit int64 `mapstructure:"CPU_limit"` RAM int64 `mapstructure:"RAM"` + RAMReservation int64 `mapstructure:"RAM_reservation"` } type StepConfigureHardware struct { @@ -36,6 +37,10 @@ func (s *StepConfigureHardware) Run(state multistep.StateBag) multistep.StepActi cpuSpec.Limit = s.config.CPULimit confSpec.CpuAllocation = &cpuSpec + var ramSpec types.ResourceAllocationInfo + ramSpec.Reservation = s.config.RAMReservation + confSpec.MemoryAllocation = &ramSpec + task, err := vm.Reconfigure(ctx, confSpec) if err != nil { state.Put("error", err)