diff --git a/cloudstack/data_source_cloudstack_instance.go b/cloudstack/data_source_cloudstack_instance.go index 5c909c8a..2bb5fe72 100644 --- a/cloudstack/data_source_cloudstack_instance.go +++ b/cloudstack/data_source_cloudstack_instance.go @@ -37,6 +37,11 @@ func dataSourceCloudstackInstance() *schema.Resource { Schema: map[string]*schema.Schema{ "filter": dataSourceFiltersSchema(), + "projectid": { + Type: schema.TypeString, + Required: true, + }, + //Computed values "instance_id": { Type: schema.TypeString, @@ -98,6 +103,7 @@ func dataSourceCloudstackInstanceRead(d *schema.ResourceData, meta interface{}) cs := meta.(*cloudstack.CloudStackClient) p := cs.VirtualMachine.NewListVirtualMachinesParams() + p.SetProjectid(d.Get("projectid").(string)) csInstances, err := cs.VirtualMachine.ListVirtualMachines(p) if err != nil { diff --git a/cloudstack/data_source_cloudstack_ipaddress.go b/cloudstack/data_source_cloudstack_ipaddress.go index 997a3a26..8fefa21e 100644 --- a/cloudstack/data_source_cloudstack_ipaddress.go +++ b/cloudstack/data_source_cloudstack_ipaddress.go @@ -37,6 +37,11 @@ func dataSourceCloudstackIPAddress() *schema.Resource { Schema: map[string]*schema.Schema{ "filter": dataSourceFiltersSchema(), + "projectid": { + Type: schema.TypeString, + Required: true, + }, + //Computed values "is_portable": { Type: schema.TypeBool, @@ -81,6 +86,7 @@ func dataSourceCloudstackIPAddress() *schema.Resource { func datasourceCloudStackIPAddressRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) p := cs.Address.NewListPublicIpAddressesParams() + p.SetProjectid(d.Get("projectid").(string)) csPublicIPAddresses, err := cs.Address.ListPublicIpAddresses(p) if err != nil { diff --git a/cloudstack/data_source_cloudstack_vpc.go b/cloudstack/data_source_cloudstack_vpc.go index 287acf4e..5eb6bce6 100644 --- a/cloudstack/data_source_cloudstack_vpc.go +++ b/cloudstack/data_source_cloudstack_vpc.go @@ -37,6 +37,11 @@ func dataSourceCloudstackVPC() *schema.Resource { Schema: map[string]*schema.Schema{ "filter": dataSourceFiltersSchema(), + "projectid": { + Type: schema.TypeString, + Required: true, + }, + //Computed values "name": { Type: schema.TypeString, @@ -81,6 +86,7 @@ func dataSourceCloudstackVPC() *schema.Resource { func datasourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) p := cs.VPC.NewListVPCsParams() + p.SetProjectid(d.Get("projectid").(string)) csVPCs, err := cs.VPC.ListVPCs(p) if err != nil { diff --git a/cloudstack/resource_cloudstack_instance.go b/cloudstack/resource_cloudstack_instance.go index fdf77ee9..7e2e1f4c 100644 --- a/cloudstack/resource_cloudstack_instance.go +++ b/cloudstack/resource_cloudstack_instance.go @@ -453,6 +453,7 @@ func resourceCloudStackInstanceRead(d *schema.ResourceData, meta interface{}) er p := cs.Volume.NewListVolumesParams() p.SetType("ROOT") p.SetVirtualmachineid(d.Id()) + p.SetProjectid(d.Get("project").(string)) // Get the root disk of the instance. l, err := cs.Volume.ListVolumes(p) diff --git a/cloudstack/resource_cloudstack_nic.go b/cloudstack/resource_cloudstack_nic.go index 82f455ee..68c8fb8a 100644 --- a/cloudstack/resource_cloudstack_nic.go +++ b/cloudstack/resource_cloudstack_nic.go @@ -53,6 +53,13 @@ func resourceCloudStackNIC() *schema.Resource { Required: true, ForceNew: true, }, + + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, }, } } @@ -97,7 +104,10 @@ func resourceCloudStackNICRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) // Get the virtual machine details - vm, count, err := cs.VirtualMachine.GetVirtualMachineByID(d.Get("virtual_machine_id").(string)) + vm, count, err := cs.VirtualMachine.GetVirtualMachineByID( + d.Get("virtual_machine_id").(string), + cloudstack.WithProject(d.Get("project").(string)), + ) if err != nil { if count == 0 { log.Printf("[DEBUG] Instance %s does no longer exist", d.Get("virtual_machine_id").(string)) diff --git a/cloudstack/resource_cloudstack_vpn_connection.go b/cloudstack/resource_cloudstack_vpn_connection.go index a493e16d..80ceff51 100644 --- a/cloudstack/resource_cloudstack_vpn_connection.go +++ b/cloudstack/resource_cloudstack_vpn_connection.go @@ -46,6 +46,13 @@ func resourceCloudStackVPNConnection() *schema.Resource { Required: true, ForceNew: true, }, + + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, }, } } @@ -74,7 +81,10 @@ func resourceCloudStackVPNConnectionRead(d *schema.ResourceData, meta interface{ cs := meta.(*cloudstack.CloudStackClient) // Get the VPN Connection details - v, count, err := cs.VPN.GetVpnConnectionByID(d.Id()) + v, count, err := cs.VPN.GetVpnConnectionByID( + d.Id(), + cloudstack.WithProject(d.Get("project").(string)), + ) if err != nil { if count == 0 { log.Printf("[DEBUG] VPN Connection does no longer exist") diff --git a/cloudstack/resource_cloudstack_vpn_customer_gateway.go b/cloudstack/resource_cloudstack_vpn_customer_gateway.go index c1f67380..e5c111ed 100644 --- a/cloudstack/resource_cloudstack_vpn_customer_gateway.go +++ b/cloudstack/resource_cloudstack_vpn_customer_gateway.go @@ -143,8 +143,11 @@ func resourceCloudStackVPNCustomerGatewayRead(d *schema.ResourceData, meta inter cs := meta.(*cloudstack.CloudStackClient) // Get the VPN Customer Gateway details - v, count, err := cs.VPN.GetVpnCustomerGatewayByID(d.Id()) - if err != nil { + v, count, err := cs.VPN.GetVpnCustomerGatewayByID( + d.Id(), + cloudstack.WithProject(d.Get("project").(string)), + ) + if err != nil { if count == 0 { log.Printf( "[DEBUG] VPN Customer Gateway %s does no longer exist", d.Get("name").(string)) diff --git a/cloudstack/resource_cloudstack_vpn_gateway.go b/cloudstack/resource_cloudstack_vpn_gateway.go index e35565ec..d29cb002 100644 --- a/cloudstack/resource_cloudstack_vpn_gateway.go +++ b/cloudstack/resource_cloudstack_vpn_gateway.go @@ -48,6 +48,13 @@ func resourceCloudStackVPNGateway() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, }, } } @@ -73,7 +80,11 @@ func resourceCloudStackVPNGatewayRead(d *schema.ResourceData, meta interface{}) cs := meta.(*cloudstack.CloudStackClient) // Get the VPN Gateway details - v, count, err := cs.VPN.GetVpnGatewayByID(d.Id()) + v, count, err := cs.VPN.GetVpnGatewayByID( + d.Id(), + cloudstack.WithProject(d.Get("project").(string)), + ) + if err != nil { if count == 0 { log.Printf(