Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added encrypt and tags option to disk offering #84

Closed
Closed
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
32 changes: 31 additions & 1 deletion cloudstack/resource_cloudstack_disk_offering.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ func resourceCloudStackDiskOffering() *schema.Resource {
Type: schema.TypeInt,
Required: true,
},
"encrypt": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"tags": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
}
}
Expand All @@ -59,6 +69,14 @@ func resourceCloudStackDiskOfferingCreate(d *schema.ResourceData, meta interface
p := cs.DiskOffering.NewCreateDiskOfferingParams(name, display_text)
p.SetDisksize(int64(disk_size))

p.SetDisksize(int64(disk_size))
if encrypt, ok := d.GetOk("encrypt"); ok {
p.SetEncrypt(encrypt.(bool))
}
if tags, ok := d.GetOk("tags"); ok {
p.SetTags(tags.(string))
}

log.Printf("[DEBUG] Creating Disk Offering %s", name)
diskOff, err := cs.DiskOffering.CreateDiskOffering(p)

Expand All @@ -76,4 +94,16 @@ func resourceCloudStackDiskOfferingRead(d *schema.ResourceData, meta interface{}

func resourceCloudStackDiskOfferingUpdate(d *schema.ResourceData, meta interface{}) error { return nil }

func resourceCloudStackDiskOfferingDelete(d *schema.ResourceData, meta interface{}) error { return nil }
func resourceCloudStackDiskOfferingDelete(d *schema.ResourceData, meta interface{}) error {
cs := meta.(*cloudstack.CloudStackClient)

p := cs.DiskOffering.NewDeleteDiskOfferingParams(d.Id())
_, err := cs.DiskOffering.DeleteDiskOffering(p)
if err != nil {
return fmt.Errorf("Error deleting disk offering: %s", err)
}


return nil

}
2 changes: 2 additions & 0 deletions website/docs/r/disk_offering.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ The following arguments are supported:
* `name` - (Required) The name of the disk offering.
* `display_text` - (Required) The display text of the disk offering.
* `disk_size` - (Required) The size of the disk offering in GB.
* `encrypt` - (Optional) Volumes using this offering should be encrypted
* `tags` - (Optional) tags for the disk offering

## Attributes Reference

Expand Down
Loading