terraform-provider-vsphere
terraform-provider-vsphere copied to clipboard
Add support for the `vsphere_host_pci_device` data source to return all PCI devices which share the same details
Description
Using vsphere_host_pci_device data source, unable to get ID of the second device when there is a situation where there are 2 PCI devices on the same host which share same vendor, name, model.
For example, I have an esxi host which has 2 GPU cards from the same vendor, and are the same.
ID: 0000:D8:00.0
NAME: NVIDIA Corporation
GA100 [A100 PCIe 40GB]
and
ID: 0000:3B:00.0
NAME: NVIDIA Corporation
GA100 [A100 PCIe 40GB]
Now, if i want to get the ID of these devices, ill need to use code below.
Potential Terraform Configuration
data "vsphere_datacenter" "dc" {
name = "DC"
}
data "vsphere_host" "esxi1" {
name = "esx1.domain.local"
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_host_pci_device" "esxi1_gpu" {
host_id = data.vsphere_host.esxi1.id
name_regex = "GA100"
}
Here im using name_regex to find a matching device, problem is, this returns only a single ID of the first match. Its impossible to get the ID of the second GPU.
Same happens when trying to filter using vendor_id
or class_id
When I run the above code, and use output to see output:
output "device_details" {
value = data.vsphere_host_pci_device.esx1-gpu2
}
this is the result:
Changes to Outputs:
+ device_details = {
+ class_id = "302"
+ host_id = "host-1006"
+ id = "0000:3b:00.0"
+ name = "GA100 [A100 PCIe 40GB]"
+ name_regex = "GA100"
+ vendor_id = "10de"
}
Only the first GPU is "reachable"
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Continuing slack chat, tagging @tenthirtyam Thanks Ryan.
Same. vsphere_host_pci_device data source is pretty broken if it can only return the first device, when there are many. This is over a year old, be great if can be prioritised. @itayporezky, did you come up with any workaround?
Same. vsphere_host_pci_device data source is pretty broken if it can only return the first device, when there are many. This is over a year old, be great if can be prioritised. @itayporezky, did you come up with any workaround?
No, our workaround is to use terraform and then add PCI with PowerCLI, this makes the state in terraform not aligned but its fine for our use case..