Add project parameter to cloudstack_template resource

This commit is contained in:
Hany Fahim 2015-09-24 16:28:40 -04:00
parent aa950be63b
commit 7b4bb968d6
1 changed files with 19 additions and 0 deletions

View File

@ -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 {