vsphere.getHostPciDevice
Explore with Pulumi AI
The vsphere.getHostPciDevice data source can be used to discover the device ID
of a vSphere host’s PCI device. This can then be used with
vsphere.VirtualMachine’s pci_device_id.
Example Usage
With Vendor ID And Class ID
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const datacenter = vsphere.getDatacenter({
    name: "dc-01",
});
const host = datacenter.then(datacenter => vsphere.getHost({
    name: "esxi-01.example.com",
    datacenterId: datacenter.id,
}));
const dev = host.then(host => vsphere.getHostPciDevice({
    hostId: host.id,
    classId: "123",
    vendorId: "456",
}));
import pulumi
import pulumi_vsphere as vsphere
datacenter = vsphere.get_datacenter(name="dc-01")
host = vsphere.get_host(name="esxi-01.example.com",
    datacenter_id=datacenter.id)
dev = vsphere.get_host_pci_device(host_id=host.id,
    class_id="123",
    vendor_id="456")
package main
import (
	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
			Name: pulumi.StringRef("dc-01"),
		}, nil)
		if err != nil {
			return err
		}
		host, err := vsphere.LookupHost(ctx, &vsphere.LookupHostArgs{
			Name:         pulumi.StringRef("esxi-01.example.com"),
			DatacenterId: datacenter.Id,
		}, nil)
		if err != nil {
			return err
		}
		_, err = vsphere.GetHostPciDevice(ctx, &vsphere.GetHostPciDeviceArgs{
			HostId:   host.Id,
			ClassId:  pulumi.StringRef("123"),
			VendorId: pulumi.StringRef("456"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;
return await Deployment.RunAsync(() => 
{
    var datacenter = VSphere.GetDatacenter.Invoke(new()
    {
        Name = "dc-01",
    });
    var host = VSphere.GetHost.Invoke(new()
    {
        Name = "esxi-01.example.com",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });
    var dev = VSphere.GetHostPciDevice.Invoke(new()
    {
        HostId = host.Apply(getHostResult => getHostResult.Id),
        ClassId = "123",
        VendorId = "456",
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vsphere.VsphereFunctions;
import com.pulumi.vsphere.inputs.GetDatacenterArgs;
import com.pulumi.vsphere.inputs.GetHostArgs;
import com.pulumi.vsphere.inputs.GetHostPciDeviceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var datacenter = VsphereFunctions.getDatacenter(GetDatacenterArgs.builder()
            .name("dc-01")
            .build());
        final var host = VsphereFunctions.getHost(GetHostArgs.builder()
            .name("esxi-01.example.com")
            .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
            .build());
        final var dev = VsphereFunctions.getHostPciDevice(GetHostPciDeviceArgs.builder()
            .hostId(host.applyValue(getHostResult -> getHostResult.id()))
            .classId(123)
            .vendorId(456)
            .build());
    }
}
variables:
  datacenter:
    fn::invoke:
      Function: vsphere:getDatacenter
      Arguments:
        name: dc-01
  host:
    fn::invoke:
      Function: vsphere:getHost
      Arguments:
        name: esxi-01.example.com
        datacenterId: ${datacenter.id}
  dev:
    fn::invoke:
      Function: vsphere:getHostPciDevice
      Arguments:
        hostId: ${host.id}
        classId: 123
        vendorId: 456
With Name Regular Expression
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const datacenter = vsphere.getDatacenter({
    name: "dc-01",
});
const host = datacenter.then(datacenter => vsphere.getHost({
    name: "esxi-01.example.com",
    datacenterId: datacenter.id,
}));
const dev = host.then(host => vsphere.getHostPciDevice({
    hostId: host.id,
    nameRegex: "MMC",
}));
import pulumi
import pulumi_vsphere as vsphere
datacenter = vsphere.get_datacenter(name="dc-01")
host = vsphere.get_host(name="esxi-01.example.com",
    datacenter_id=datacenter.id)
dev = vsphere.get_host_pci_device(host_id=host.id,
    name_regex="MMC")
package main
import (
	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
			Name: pulumi.StringRef("dc-01"),
		}, nil)
		if err != nil {
			return err
		}
		host, err := vsphere.LookupHost(ctx, &vsphere.LookupHostArgs{
			Name:         pulumi.StringRef("esxi-01.example.com"),
			DatacenterId: datacenter.Id,
		}, nil)
		if err != nil {
			return err
		}
		_, err = vsphere.GetHostPciDevice(ctx, &vsphere.GetHostPciDeviceArgs{
			HostId:    host.Id,
			NameRegex: pulumi.StringRef("MMC"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;
return await Deployment.RunAsync(() => 
{
    var datacenter = VSphere.GetDatacenter.Invoke(new()
    {
        Name = "dc-01",
    });
    var host = VSphere.GetHost.Invoke(new()
    {
        Name = "esxi-01.example.com",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });
    var dev = VSphere.GetHostPciDevice.Invoke(new()
    {
        HostId = host.Apply(getHostResult => getHostResult.Id),
        NameRegex = "MMC",
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vsphere.VsphereFunctions;
import com.pulumi.vsphere.inputs.GetDatacenterArgs;
import com.pulumi.vsphere.inputs.GetHostArgs;
import com.pulumi.vsphere.inputs.GetHostPciDeviceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var datacenter = VsphereFunctions.getDatacenter(GetDatacenterArgs.builder()
            .name("dc-01")
            .build());
        final var host = VsphereFunctions.getHost(GetHostArgs.builder()
            .name("esxi-01.example.com")
            .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
            .build());
        final var dev = VsphereFunctions.getHostPciDevice(GetHostPciDeviceArgs.builder()
            .hostId(host.applyValue(getHostResult -> getHostResult.id()))
            .nameRegex("MMC")
            .build());
    }
}
variables:
  datacenter:
    fn::invoke:
      Function: vsphere:getDatacenter
      Arguments:
        name: dc-01
  host:
    fn::invoke:
      Function: vsphere:getHost
      Arguments:
        name: esxi-01.example.com
        datacenterId: ${datacenter.id}
  dev:
    fn::invoke:
      Function: vsphere:getHostPciDevice
      Arguments:
        hostId: ${host.id}
        nameRegex: MMC
Using getHostPciDevice
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getHostPciDevice(args: GetHostPciDeviceArgs, opts?: InvokeOptions): Promise<GetHostPciDeviceResult>
function getHostPciDeviceOutput(args: GetHostPciDeviceOutputArgs, opts?: InvokeOptions): Output<GetHostPciDeviceResult>def get_host_pci_device(class_id: Optional[str] = None,
                        host_id: Optional[str] = None,
                        name_regex: Optional[str] = None,
                        vendor_id: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetHostPciDeviceResult
def get_host_pci_device_output(class_id: Optional[pulumi.Input[str]] = None,
                        host_id: Optional[pulumi.Input[str]] = None,
                        name_regex: Optional[pulumi.Input[str]] = None,
                        vendor_id: Optional[pulumi.Input[str]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetHostPciDeviceResult]func GetHostPciDevice(ctx *Context, args *GetHostPciDeviceArgs, opts ...InvokeOption) (*GetHostPciDeviceResult, error)
func GetHostPciDeviceOutput(ctx *Context, args *GetHostPciDeviceOutputArgs, opts ...InvokeOption) GetHostPciDeviceResultOutput> Note: This function is named GetHostPciDevice in the Go SDK.
public static class GetHostPciDevice 
{
    public static Task<GetHostPciDeviceResult> InvokeAsync(GetHostPciDeviceArgs args, InvokeOptions? opts = null)
    public static Output<GetHostPciDeviceResult> Invoke(GetHostPciDeviceInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetHostPciDeviceResult> getHostPciDevice(GetHostPciDeviceArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: vsphere:index/getHostPciDevice:getHostPciDevice
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Host
Id string - The [managed object reference ID][docs-about-morefs] of a host.
 - Class
Id string The hexadecimal PCI device class ID
NOTE:
name_regex,vendor_id, andclass_idcan all be used together.- Name
Regex string - A regular expression that will be used to match the host PCI device name.
 - Vendor
Id string - The hexadecimal PCI device vendor ID.
 
- Host
Id string - The [managed object reference ID][docs-about-morefs] of a host.
 - Class
Id string The hexadecimal PCI device class ID
NOTE:
name_regex,vendor_id, andclass_idcan all be used together.- Name
Regex string - A regular expression that will be used to match the host PCI device name.
 - Vendor
Id string - The hexadecimal PCI device vendor ID.
 
- host
Id String - The [managed object reference ID][docs-about-morefs] of a host.
 - class
Id String The hexadecimal PCI device class ID
NOTE:
name_regex,vendor_id, andclass_idcan all be used together.- name
Regex String - A regular expression that will be used to match the host PCI device name.
 - vendor
Id String - The hexadecimal PCI device vendor ID.
 
- host
Id string - The [managed object reference ID][docs-about-morefs] of a host.
 - class
Id string The hexadecimal PCI device class ID
NOTE:
name_regex,vendor_id, andclass_idcan all be used together.- name
Regex string - A regular expression that will be used to match the host PCI device name.
 - vendor
Id string - The hexadecimal PCI device vendor ID.
 
- host_
id str - The [managed object reference ID][docs-about-morefs] of a host.
 - class_
id str The hexadecimal PCI device class ID
NOTE:
name_regex,vendor_id, andclass_idcan all be used together.- name_
regex str - A regular expression that will be used to match the host PCI device name.
 - vendor_
id str - The hexadecimal PCI device vendor ID.
 
- host
Id String - The [managed object reference ID][docs-about-morefs] of a host.
 - class
Id String The hexadecimal PCI device class ID
NOTE:
name_regex,vendor_id, andclass_idcan all be used together.- name
Regex String - A regular expression that will be used to match the host PCI device name.
 - vendor
Id String - The hexadecimal PCI device vendor ID.
 
getHostPciDevice Result
The following output properties are available:
Package Details
- Repository
 - vSphere pulumi/pulumi-vsphere
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
vsphereTerraform Provider.