Add project parameter to cloudstack_template resource
This commit is contained in:
parent
aa950be63b
commit
7b4bb968d6
|
@ -51,6 +51,12 @@ func resourceCloudStackTemplate() *schema.Resource {
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"project": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
|
||||||
"zone": &schema.Schema{
|
"zone": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
|
@ -124,6 +130,17 @@ func resourceCloudStackTemplateCreate(d *schema.ResourceData, meta interface{})
|
||||||
return e.Error()
|
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
|
// Retrieve the zone UUID
|
||||||
zoneid, e := retrieveUUID(cs, "zone", d.Get("zone").(string))
|
zoneid, e := retrieveUUID(cs, "zone", d.Get("zone").(string))
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
@ -219,6 +236,8 @@ func resourceCloudStackTemplateRead(d *schema.ResourceData, meta interface{}) er
|
||||||
d.Set("password_enabled", t.Passwordenabled)
|
d.Set("password_enabled", t.Passwordenabled)
|
||||||
d.Set("is_ready", t.Isready)
|
d.Set("is_ready", t.Isready)
|
||||||
|
|
||||||
|
setValueOrUUID(d, "project", t.Project, t.Projectid)
|
||||||
|
|
||||||
if t.Zoneid == IS_GLOBAL_RESOURCE {
|
if t.Zoneid == IS_GLOBAL_RESOURCE {
|
||||||
setValueOrUUID(d, "zone", t.Zonename, IS_GLOBAL_RESOURCE)
|
setValueOrUUID(d, "zone", t.Zonename, IS_GLOBAL_RESOURCE)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue