From b8555b75f3cedc6fc74618581b1fe196e7cb3329 Mon Sep 17 00:00:00 2001 From: vishesh92 Date: Tue, 26 Aug 2025 13:51:12 +0530 Subject: [PATCH 1/2] Add disk_offering & override_disk_offering to instance resource --- cloudstack/resource_cloudstack_instance.go | 33 ++++++++++++++++++++++ website/docs/r/instance.html.markdown | 12 ++++++++ 2 files changed, 45 insertions(+) diff --git a/cloudstack/resource_cloudstack_instance.go b/cloudstack/resource_cloudstack_instance.go index fdf77ee9..34a77ccd 100644 --- a/cloudstack/resource_cloudstack_instance.go +++ b/cloudstack/resource_cloudstack_instance.go @@ -59,6 +59,20 @@ func resourceCloudStackInstance() *schema.Resource { Required: true, }, + "disk_offering": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "override_disk_offering": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "network_id": { Type: schema.TypeString, Optional: true, @@ -297,6 +311,24 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) p.SetRootdisksize(int64(rootdisksize.(int))) } + if diskoffering, ok := d.GetOk("disk_offering"); ok { + // Retrieve the disk_offering ID + diskofferingid, e := retrieveID(cs, "disk_offering", diskoffering.(string)) + if e != nil { + return e.Error() + } + p.SetDiskofferingid(diskofferingid) + } + + if override_disk_offering, ok := d.GetOk("override_disk_offering"); ok { + // Retrieve the override_disk_offering ID + override_disk_offeringid, e := retrieveID(cs, "disk_offering", override_disk_offering.(string)) + if e != nil { + return e.Error() + } + p.SetOverridediskofferingid(override_disk_offeringid) + } + if d.Get("uefi").(bool) { p.SetBoottype("UEFI") p.SetBootmode("Legacy") @@ -502,6 +534,7 @@ func resourceCloudStackInstanceRead(d *schema.ResourceData, meta interface{}) er d.Set("tags", tagsToMap(vm.Tags)) setValueOrID(d, "service_offering", vm.Serviceofferingname, vm.Serviceofferingid) + setValueOrID(d, "disk_offering", vm.Diskofferingname, vm.Diskofferingid) setValueOrID(d, "template", vm.Templatename, vm.Templateid) setValueOrID(d, "project", vm.Project, vm.Projectid) setValueOrID(d, "zone", vm.Zonename, vm.Zoneid) diff --git a/website/docs/r/instance.html.markdown b/website/docs/r/instance.html.markdown index d4d61872..c0921a40 100644 --- a/website/docs/r/instance.html.markdown +++ b/website/docs/r/instance.html.markdown @@ -34,6 +34,18 @@ The following arguments are supported: * `service_offering` - (Required) The name or ID of the service offering used for this instance. +* `disk_offering` - (Optional) The name or ID of the disk offering for the virtual machine. + If the template is of ISO format, the disk offering is for the root disk volume. + Otherwise this parameter is used to indicate the offering for the data disk volume. + If the template parameter passed is from a Template object, the disk offering refers + to a DATA Disk Volume created. If the template parameter passed is from an ISO object, + the disk offering refers to a ROOT Disk Volume created. + +* `override_disk_offering` - (Optional) The name or ID of the disk offering for the virtual + machine to be used for root volume instead of the disk offering mapped in service offering. + In case of virtual machine deploying from ISO, then the diskOffering specified for root + volume is ignored and uses this override disk offering. + * `host_id` - (Optional) destination Host ID to deploy the VM to - parameter available for root admin only From 22827301d9b56ba10e87e347ff7863ee31ea4f01 Mon Sep 17 00:00:00 2001 From: Vishesh Date: Tue, 26 Aug 2025 14:05:00 +0530 Subject: [PATCH 2/2] Update website/docs/r/instance.html.markdown Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- website/docs/r/instance.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/instance.html.markdown b/website/docs/r/instance.html.markdown index c0921a40..ee3aef4a 100644 --- a/website/docs/r/instance.html.markdown +++ b/website/docs/r/instance.html.markdown @@ -43,7 +43,7 @@ The following arguments are supported: * `override_disk_offering` - (Optional) The name or ID of the disk offering for the virtual machine to be used for root volume instead of the disk offering mapped in service offering. - In case of virtual machine deploying from ISO, then the diskOffering specified for root + In case of virtual machine deploying from ISO, then the disk offering specified for root volume is ignored and uses this override disk offering. * `host_id` - (Optional) destination Host ID to deploy the VM to - parameter available