From 078b16b20e30d09b60c36e8799ada42c0d52c22a Mon Sep 17 00:00:00 2001 From: Hany Fahim Date: Thu, 20 Aug 2015 08:32:57 -0400 Subject: [PATCH] Add project parameter to cloudstack_ipaddress --- .../resource_cloudstack_ipaddress.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go b/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go index 84e067f81e..054c3bb744 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go +++ b/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go @@ -32,6 +32,12 @@ func resourceCloudStackIPAddress() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -46,6 +52,17 @@ func resourceCloudStackIPAddressCreate(d *schema.ResourceData, meta interface{}) // Create a new parameter struct p := cs.Address.NewAssociateIpAddressParams() + // If there is a project supplied, we retreive 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) + } + if network, ok := d.GetOk("network"); ok { // Retrieve the network UUID networkid, e := retrieveUUID(cs, "network", network.(string)) @@ -118,6 +135,8 @@ func resourceCloudStackIPAddressRead(d *schema.ResourceData, meta interface{}) e setValueOrUUID(d, "vpc", v.Name, f.Vpcid) } + setValueOrUUID(d, "project", f.Project, f.Projectid) + return nil }