The current code is incorrect in requiring the VM Sizing Policy CPU and Memory limits need to be at least 0, as this completely removes the ability to create policies with unlimited CPU/Memory as per the API.
"limit_in_mhz": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Description: "Defines the CPU limit in MHz for a VM. If not defined in the VDC compute policy, CPU limit is equal to the vCPU speed multiplied by the number of vCPUs.",
ValidateFunc: IsIntAndAtLeast(0),
}
And here is the API showing that -1 is a valid value
cpuLimit integer($int64)
The limit of CPU in MHz for the VM on which this policy is applied. -1 means unlimited. This
is optional. If not provided, limit would be equal to the vCPUSpeed multiplied by numCPU.
memoryLimit integer($int64)
The limit of memory in MB for the VM on which this policy is applied. -1 means unlimited. This
is optional. If not provided, limit would be equal to the configured memory of the VM.
Using the above config, I'd expect a new VM Sizing policy to be created with CPU Limit set to Unlimited
Actual Behavior
An error is printed that -1 is not a valid value as it's less than 0.
│ Error: expected cpu.0.limit_in_mhz to be at least (0), got -1
│
│ with vcd_vm_sizing_policy.vmsizingpolicy1,
│ on main.tf line 171, in resource "vcd_vm_sizing_policy" "vmsizingpolicy1":
│ 171: limit_in_mhz = "-1"
│
Hello,
The current code is incorrect in requiring the VM Sizing Policy CPU and Memory limits need to be at least 0, as this completely removes the ability to create policies with unlimited CPU/Memory as per the API.
You can see the section of code here for CPU Limits https://github.com/vmware/terraform-provider-vcd/blob/1f61f1eb157271cbe9cdd98698503f45148b22c7/vcd/resource_vcd_vm_sizing_policy.go#L94C3-L99C37
And here is the API showing that
-1
is a valid valueTerraform Version
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
Using the above config, I'd expect a new VM Sizing policy to be created with
CPU Limit
set toUnlimited
Actual Behavior
An error is printed that
-1
is not a valid value as it's less than 0.Steps to Reproduce
terraform plan