Skip to content

Commit 3976398

Browse files
committed
Add cpu, mem reservations
1 parent 406d8c3 commit 3976398

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This Terraform module deploys single or multiple virtual machines of type (Linux
2222
- Ability to configure advance features for the vm.
2323
- Ability to deploy either a datastore or a datastore cluster.
2424
- Ability to enable cpu and memory hot plug features for the VM.
25+
- Ability to enable cpu and memory reservations for the VM.
2526
- Ability to define different datastores for data disks.
2627
- Ability to define different scsi_controllers per disk, including data disks.
2728
- Ability to define network type per interface and disk label per attached disk.
@@ -100,6 +101,8 @@ module "example-server-windowsvm-advanced" {
100101
instances = 2
101102
cpu_number = 2
102103
ram_size = 2096
104+
cpu_reservation = 2000
105+
memory_reservation = 2000
103106
cpu_hot_add_enabled = "true"
104107
cpu_hot_remove_enabled = "true"
105108
memory_hot_add_enabled = "true"

main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ resource "vsphere_virtual_machine" "Linux" {
8282
num_cores_per_socket = var.num_cores_per_socket
8383
cpu_hot_add_enabled = var.cpu_hot_add_enabled
8484
cpu_hot_remove_enabled = var.cpu_hot_remove_enabled
85+
cpu_reservation = var.cpu_reservation
86+
memory_reservation = var.memory_reservation
8587
memory = var.ram_size
8688
memory_hot_add_enabled = var.memory_hot_add_enabled
8789
guest_id = data.vsphere_virtual_machine.template.guest_id
@@ -175,6 +177,8 @@ resource "vsphere_virtual_machine" "Windows" {
175177
num_cores_per_socket = var.num_cores_per_socket
176178
cpu_hot_add_enabled = var.cpu_hot_add_enabled
177179
cpu_hot_remove_enabled = var.cpu_hot_remove_enabled
180+
cpu_reservation = var.cpu_reservation
181+
memory_reservation = var.memory_reservation
178182
memory = var.ram_size
179183
memory_hot_add_enabled = var.memory_hot_add_enabled
180184
guest_id = data.vsphere_virtual_machine.template.guest_id

variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ variable "cpu_number" {
2727
default = 2
2828
}
2929

30+
variable "cpu_reservation" {
31+
description = "The amount of CPU (in MHz) that this virtual machine is guaranteed."
32+
default = null
33+
}
34+
35+
3036
variable "ram_size" {
3137
description = "VM RAM size in megabytes"
3238
default = 4096
@@ -150,6 +156,11 @@ variable "memory_hot_add_enabled" {
150156
default = null
151157
}
152158

159+
variable "memory_reservation" {
160+
description = "The amount of memory (in MB) that this virtual machine is guaranteed."
161+
default = null
162+
}
163+
153164
variable "disk_label" {
154165
description = "Storage data disk labels"
155166
type = list

0 commit comments

Comments
 (0)