From 330673038c15c63fd9d6ef3de4d0be0d0d744622 Mon Sep 17 00:00:00 2001 From: Hany Fahim Date: Thu, 20 Aug 2015 13:35:11 -0400 Subject: [PATCH] Add project parameter to cloudstack_disk --- .../cloudstack/resource_cloudstack_disk.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/builtin/providers/cloudstack/resource_cloudstack_disk.go b/builtin/providers/cloudstack/resource_cloudstack_disk.go index 1c7ad36bd..c19cac8bc 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_disk.go +++ b/builtin/providers/cloudstack/resource_cloudstack_disk.go @@ -61,6 +61,12 @@ func resourceCloudStackDisk() *schema.Resource { Required: true, ForceNew: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -74,6 +80,17 @@ func resourceCloudStackDiskCreate(d *schema.ResourceData, meta interface{}) erro // Create a new parameter struct p := cs.Volume.NewCreateVolumeParams(name) + // If there is a project supplied, we retreive and set the project id + if project, ok := d.GetOk("project"); ok { + // Retrieve the project UUID + projectid, e := retrieveUUID(cs, "project", project.(string)) + if e != nil { + return e.Error() + } + // Set the default project ID + p.SetProjectid(projectid) + } + // Retrieve the disk_offering UUID diskofferingid, e := retrieveUUID(cs, "disk_offering", d.Get("disk_offering").(string)) if e != nil { @@ -144,6 +161,7 @@ func resourceCloudStackDiskRead(d *schema.ResourceData, meta interface{}) error setValueOrUUID(d, "disk_offering", v.Diskofferingname, v.Diskofferingid) setValueOrUUID(d, "zone", v.Zonename, v.Zoneid) + setValueOrUUID(d, "project", v.Project, v.Projectid) if v.Attached != "" { // Get the virtual machine details