Skip to content

Commit b8555b7

Browse files
committed
Add disk_offering & override_disk_offering to instance resource
1 parent 4eb6d4b commit b8555b7

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

cloudstack/resource_cloudstack_instance.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ func resourceCloudStackInstance() *schema.Resource {
5959
Required: true,
6060
},
6161

62+
"disk_offering": {
63+
Type: schema.TypeString,
64+
Optional: true,
65+
Computed: true,
66+
ForceNew: true,
67+
},
68+
69+
"override_disk_offering": {
70+
Type: schema.TypeString,
71+
Optional: true,
72+
Computed: true,
73+
ForceNew: true,
74+
},
75+
6276
"network_id": {
6377
Type: schema.TypeString,
6478
Optional: true,
@@ -297,6 +311,24 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{})
297311
p.SetRootdisksize(int64(rootdisksize.(int)))
298312
}
299313

314+
if diskoffering, ok := d.GetOk("disk_offering"); ok {
315+
// Retrieve the disk_offering ID
316+
diskofferingid, e := retrieveID(cs, "disk_offering", diskoffering.(string))
317+
if e != nil {
318+
return e.Error()
319+
}
320+
p.SetDiskofferingid(diskofferingid)
321+
}
322+
323+
if override_disk_offering, ok := d.GetOk("override_disk_offering"); ok {
324+
// Retrieve the override_disk_offering ID
325+
override_disk_offeringid, e := retrieveID(cs, "disk_offering", override_disk_offering.(string))
326+
if e != nil {
327+
return e.Error()
328+
}
329+
p.SetOverridediskofferingid(override_disk_offeringid)
330+
}
331+
300332
if d.Get("uefi").(bool) {
301333
p.SetBoottype("UEFI")
302334
p.SetBootmode("Legacy")
@@ -502,6 +534,7 @@ func resourceCloudStackInstanceRead(d *schema.ResourceData, meta interface{}) er
502534
d.Set("tags", tagsToMap(vm.Tags))
503535

504536
setValueOrID(d, "service_offering", vm.Serviceofferingname, vm.Serviceofferingid)
537+
setValueOrID(d, "disk_offering", vm.Diskofferingname, vm.Diskofferingid)
505538
setValueOrID(d, "template", vm.Templatename, vm.Templateid)
506539
setValueOrID(d, "project", vm.Project, vm.Projectid)
507540
setValueOrID(d, "zone", vm.Zonename, vm.Zoneid)

website/docs/r/instance.html.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ The following arguments are supported:
3434
* `service_offering` - (Required) The name or ID of the service offering used
3535
for this instance.
3636

37+
* `disk_offering` - (Optional) The name or ID of the disk offering for the virtual machine.
38+
If the template is of ISO format, the disk offering is for the root disk volume.
39+
Otherwise this parameter is used to indicate the offering for the data disk volume.
40+
If the template parameter passed is from a Template object, the disk offering refers
41+
to a DATA Disk Volume created. If the template parameter passed is from an ISO object,
42+
the disk offering refers to a ROOT Disk Volume created.
43+
44+
* `override_disk_offering` - (Optional) The name or ID of the disk offering for the virtual
45+
machine to be used for root volume instead of the disk offering mapped in service offering.
46+
In case of virtual machine deploying from ISO, then the diskOffering specified for root
47+
volume is ignored and uses this override disk offering.
48+
3749
* `host_id` - (Optional) destination Host ID to deploy the VM to - parameter available
3850
for root admin only
3951

0 commit comments

Comments
 (0)