From 7b4bb968d62d7b64de60afabde30554f7e082d9d Mon Sep 17 00:00:00 2001 From: Hany Fahim Date: Thu, 24 Sep 2015 16:28:40 -0400 Subject: [PATCH] Add project parameter to cloudstack_template resource --- .../resource_cloudstack_template.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/builtin/providers/cloudstack/resource_cloudstack_template.go b/builtin/providers/cloudstack/resource_cloudstack_template.go index 6762e3467..a045816dd 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_template.go +++ b/builtin/providers/cloudstack/resource_cloudstack_template.go @@ -51,6 +51,12 @@ func resourceCloudStackTemplate() *schema.Resource { ForceNew: true, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "zone": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -124,6 +130,17 @@ func resourceCloudStackTemplateCreate(d *schema.ResourceData, meta interface{}) return e.Error() } + // If there is a project supplied, we retrieve 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 zone UUID zoneid, e := retrieveUUID(cs, "zone", d.Get("zone").(string)) if e != nil { @@ -219,6 +236,8 @@ func resourceCloudStackTemplateRead(d *schema.ResourceData, meta interface{}) er d.Set("password_enabled", t.Passwordenabled) d.Set("is_ready", t.Isready) + setValueOrUUID(d, "project", t.Project, t.Projectid) + if t.Zoneid == IS_GLOBAL_RESOURCE { setValueOrUUID(d, "zone", t.Zonename, IS_GLOBAL_RESOURCE) } else {