Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cloudstack/data_source_cloudstack_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions cloudstack/data_source_cloudstack_ipaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func dataSourceCloudstackIPAddress() *schema.Resource {
Schema: map[string]*schema.Schema{
"filter": dataSourceFiltersSchema(),

"projectid": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a field project. Can't we use that instead?

Type: schema.TypeString,
Required: true,
},

//Computed values
"is_portable": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions cloudstack/data_source_cloudstack_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func dataSourceCloudstackVPC() *schema.Resource {
Schema: map[string]*schema.Schema{
"filter": dataSourceFiltersSchema(),

"projectid": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a field project. Can't we use that instead?

Type: schema.TypeString,
Required: true,
},

//Computed values
"name": {
Type: schema.TypeString,
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions cloudstack/resource_cloudstack_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion cloudstack/resource_cloudstack_nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ func resourceCloudStackNIC() *schema.Resource {
Required: true,
ForceNew: true,
},

"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
}
}
Expand Down Expand Up @@ -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))
Expand Down
12 changes: 11 additions & 1 deletion cloudstack/resource_cloudstack_vpn_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func resourceCloudStackVPNConnection() *schema.Resource {
Required: true,
ForceNew: true,
},

"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
}
}
Expand Down Expand Up @@ -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")
Expand Down
7 changes: 5 additions & 2 deletions cloudstack/resource_cloudstack_vpn_customer_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
13 changes: 12 additions & 1 deletion cloudstack/resource_cloudstack_vpn_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ func resourceCloudStackVPNGateway() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
}
}
Expand All @@ -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(
Expand Down