1. Packages
  2. Libvirt Provider
  3. API Docs
  4. getNodeDevices
libvirt 0.9.0 published on Saturday, Nov 8, 2025 by dmacvicar
libvirt logo
libvirt 0.9.0 published on Saturday, Nov 8, 2025 by dmacvicar

    Enumerates devices available on the libvirt host node.

    This data source lists devices by capability type, useful for discovering PCI devices for passthrough, USB devices, network interfaces, storage devices, and more.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as libvirt from "@pulumi/libvirt";
    
    // List all devices
    const all = libvirt.getNodeDevices({});
    // List only PCI devices (useful for GPU passthrough)
    const pci = libvirt.getNodeDevices({
        capability: "pci",
    });
    // List only network interfaces
    const network = libvirt.getNodeDevices({
        capability: "net",
    });
    // List only USB devices
    const usb = libvirt.getNodeDevices({
        capability: "usb_device",
    });
    // List only storage devices
    const storage = libvirt.getNodeDevices({
        capability: "storage",
    });
    export const allDevices = all.then(all => all.devices);
    export const pciDevices = pci.then(pci => pci.devices);
    export const networkInterfaces = network.then(network => network.devices);
    
    import pulumi
    import pulumi_libvirt as libvirt
    
    # List all devices
    all = libvirt.get_node_devices()
    # List only PCI devices (useful for GPU passthrough)
    pci = libvirt.get_node_devices(capability="pci")
    # List only network interfaces
    network = libvirt.get_node_devices(capability="net")
    # List only USB devices
    usb = libvirt.get_node_devices(capability="usb_device")
    # List only storage devices
    storage = libvirt.get_node_devices(capability="storage")
    pulumi.export("allDevices", all.devices)
    pulumi.export("pciDevices", pci.devices)
    pulumi.export("networkInterfaces", network.devices)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/libvirt/libvirt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// List all devices
    		all, err := libvirt.GetNodeDevices(ctx, &libvirt.GetNodeDevicesArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		// List only PCI devices (useful for GPU passthrough)
    		pci, err := libvirt.GetNodeDevices(ctx, &libvirt.GetNodeDevicesArgs{
    			Capability: pulumi.StringRef("pci"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// List only network interfaces
    		network, err := libvirt.GetNodeDevices(ctx, &libvirt.GetNodeDevicesArgs{
    			Capability: pulumi.StringRef("net"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// List only USB devices
    		_, err = libvirt.GetNodeDevices(ctx, &libvirt.GetNodeDevicesArgs{
    			Capability: pulumi.StringRef("usb_device"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// List only storage devices
    		_, err = libvirt.GetNodeDevices(ctx, &libvirt.GetNodeDevicesArgs{
    			Capability: pulumi.StringRef("storage"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("allDevices", all.Devices)
    		ctx.Export("pciDevices", pci.Devices)
    		ctx.Export("networkInterfaces", network.Devices)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Libvirt = Pulumi.Libvirt;
    
    return await Deployment.RunAsync(() => 
    {
        // List all devices
        var all = Libvirt.GetNodeDevices.Invoke();
    
        // List only PCI devices (useful for GPU passthrough)
        var pci = Libvirt.GetNodeDevices.Invoke(new()
        {
            Capability = "pci",
        });
    
        // List only network interfaces
        var network = Libvirt.GetNodeDevices.Invoke(new()
        {
            Capability = "net",
        });
    
        // List only USB devices
        var usb = Libvirt.GetNodeDevices.Invoke(new()
        {
            Capability = "usb_device",
        });
    
        // List only storage devices
        var storage = Libvirt.GetNodeDevices.Invoke(new()
        {
            Capability = "storage",
        });
    
        return new Dictionary<string, object?>
        {
            ["allDevices"] = all.Apply(getNodeDevicesResult => getNodeDevicesResult.Devices),
            ["pciDevices"] = pci.Apply(getNodeDevicesResult => getNodeDevicesResult.Devices),
            ["networkInterfaces"] = network.Apply(getNodeDevicesResult => getNodeDevicesResult.Devices),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.libvirt.LibvirtFunctions;
    import com.pulumi.libvirt.inputs.GetNodeDevicesArgs;
    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) {
            // List all devices
            final var all = LibvirtFunctions.getNodeDevices(GetNodeDevicesArgs.builder()
                .build());
    
            // List only PCI devices (useful for GPU passthrough)
            final var pci = LibvirtFunctions.getNodeDevices(GetNodeDevicesArgs.builder()
                .capability("pci")
                .build());
    
            // List only network interfaces
            final var network = LibvirtFunctions.getNodeDevices(GetNodeDevicesArgs.builder()
                .capability("net")
                .build());
    
            // List only USB devices
            final var usb = LibvirtFunctions.getNodeDevices(GetNodeDevicesArgs.builder()
                .capability("usb_device")
                .build());
    
            // List only storage devices
            final var storage = LibvirtFunctions.getNodeDevices(GetNodeDevicesArgs.builder()
                .capability("storage")
                .build());
    
            ctx.export("allDevices", all.devices());
            ctx.export("pciDevices", pci.devices());
            ctx.export("networkInterfaces", network.devices());
        }
    }
    
    variables:
      # List all devices
      all:
        fn::invoke:
          function: libvirt:getNodeDevices
          arguments: {}
      # List only PCI devices (useful for GPU passthrough)
      pci:
        fn::invoke:
          function: libvirt:getNodeDevices
          arguments:
            capability: pci
      # List only network interfaces
      network:
        fn::invoke:
          function: libvirt:getNodeDevices
          arguments:
            capability: net
      # List only USB devices
      usb:
        fn::invoke:
          function: libvirt:getNodeDevices
          arguments:
            capability: usb_device
      # List only storage devices
      storage:
        fn::invoke:
          function: libvirt:getNodeDevices
          arguments:
            capability: storage
    outputs:
      allDevices: ${all.devices}
      pciDevices: ${pci.devices}
      networkInterfaces: ${network.devices}
    

    Using getNodeDevices

    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 getNodeDevices(args: GetNodeDevicesArgs, opts?: InvokeOptions): Promise<GetNodeDevicesResult>
    function getNodeDevicesOutput(args: GetNodeDevicesOutputArgs, opts?: InvokeOptions): Output<GetNodeDevicesResult>
    def get_node_devices(capability: Optional[str] = None,
                         opts: Optional[InvokeOptions] = None) -> GetNodeDevicesResult
    def get_node_devices_output(capability: Optional[pulumi.Input[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetNodeDevicesResult]
    func GetNodeDevices(ctx *Context, args *GetNodeDevicesArgs, opts ...InvokeOption) (*GetNodeDevicesResult, error)
    func GetNodeDevicesOutput(ctx *Context, args *GetNodeDevicesOutputArgs, opts ...InvokeOption) GetNodeDevicesResultOutput

    > Note: This function is named GetNodeDevices in the Go SDK.

    public static class GetNodeDevices 
    {
        public static Task<GetNodeDevicesResult> InvokeAsync(GetNodeDevicesArgs args, InvokeOptions? opts = null)
        public static Output<GetNodeDevicesResult> Invoke(GetNodeDevicesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetNodeDevicesResult> getNodeDevices(GetNodeDevicesArgs args, InvokeOptions options)
    public static Output<GetNodeDevicesResult> getNodeDevices(GetNodeDevicesArgs args, InvokeOptions options)
    
    fn::invoke:
      function: libvirt:index/getNodeDevices:getNodeDevices
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Capability string
    Capability string
    capability String
    capability string
    capability String

    getNodeDevices Result

    The following output properties are available:

    Devices List<string>
    Id string
    Capability string
    Devices []string
    Id string
    Capability string
    devices List<String>
    id String
    capability String
    devices string[]
    id string
    capability string
    devices Sequence[str]
    id str
    capability str
    devices List<String>
    id String
    capability String

    Package Details

    Repository
    libvirt dmacvicar/terraform-provider-libvirt
    License
    Notes
    This Pulumi package is based on the libvirt Terraform Provider.
    libvirt logo
    libvirt 0.9.0 published on Saturday, Nov 8, 2025 by dmacvicar
      Meet Neo: Your AI Platform Teammate