Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions cloudstack/resource_cloudstack_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions website/docs/r/instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
for root admin only

Expand Down
Loading