add project support https://github.com/xanzy/go-cloudstack/pull/21/files
This commit is contained in:
parent
b3a4965f84
commit
a09afbb4aa
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue