This commit is contained in:
_jac 2015-05-27 18:33:57 -07:00
parent b3a4965f84
commit a09afbb4aa
1 changed files with 16 additions and 0 deletions

View File

@ -82,6 +82,11 @@ func resourceCloudStackInstance() *schema.Resource {
Optional: true, Optional: true,
Default: false, Default: false,
}, },
"project_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: nil,
},
}, },
} }
} }
@ -148,6 +153,17 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{})
p.SetUserdata(ud) p.SetUserdata(ud)
} }
// If the project_name contains any info, we retreive the project_id
if projectName, ok := d.GetOk("project_name"); ok {
project, _, err := cs.Project.GetProjectByName(projectName.(string))
if err != nil {
return err
}
log.Printf("[DEBUG] project id %s", project.Id)
p.SetProjectid(project.Id)
d.Set("project_id", project.Id)
}
// Create the new instance // Create the new instance
r, err := cs.VirtualMachine.DeployVirtualMachine(p) r, err := cs.VirtualMachine.DeployVirtualMachine(p)
if err != nil { if err != nil {