1. Packages
  2. Libvirt Provider
  3. API Docs
  4. Pool
libvirt 0.8.3 published on Tuesday, Mar 4, 2025 by dmacvicar

libvirt.Pool

Explore with Pulumi AI

Manages a storage pool in libvirt. Currently only directory-based storage pool are supported. For more information on storage pools in libvirt, see the official documentation.

WARNING: This is experimental API and may change in the future.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as libvirt from "@pulumi/libvirt";

// A pool for all cluster volumes
const cluster = new libvirt.Pool("cluster", {
    type: "dir",
    target: {
        path: "/home/user/cluster_storage",
    },
});
const opensuseLeap = new libvirt.Volume("opensuseLeap", {
    pool: cluster.name,
    source: "http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2",
});
Copy
import pulumi
import pulumi_libvirt as libvirt

# A pool for all cluster volumes
cluster = libvirt.Pool("cluster",
    type="dir",
    target={
        "path": "/home/user/cluster_storage",
    })
opensuse_leap = libvirt.Volume("opensuseLeap",
    pool=cluster.name,
    source="http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2")
Copy
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 {
		// A pool for all cluster volumes
		cluster, err := libvirt.NewPool(ctx, "cluster", &libvirt.PoolArgs{
			Type: pulumi.String("dir"),
			Target: &libvirt.PoolTargetArgs{
				Path: pulumi.String("/home/user/cluster_storage"),
			},
		})
		if err != nil {
			return err
		}
		_, err = libvirt.NewVolume(ctx, "opensuseLeap", &libvirt.VolumeArgs{
			Pool:   cluster.Name,
			Source: pulumi.String("http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Libvirt = Pulumi.Libvirt;

return await Deployment.RunAsync(() => 
{
    // A pool for all cluster volumes
    var cluster = new Libvirt.Pool("cluster", new()
    {
        Type = "dir",
        Target = new Libvirt.Inputs.PoolTargetArgs
        {
            Path = "/home/user/cluster_storage",
        },
    });

    var opensuseLeap = new Libvirt.Volume("opensuseLeap", new()
    {
        Pool = cluster.Name,
        Source = "http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.libvirt.Pool;
import com.pulumi.libvirt.PoolArgs;
import com.pulumi.libvirt.inputs.PoolTargetArgs;
import com.pulumi.libvirt.Volume;
import com.pulumi.libvirt.VolumeArgs;
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) {
        // A pool for all cluster volumes
        var cluster = new Pool("cluster", PoolArgs.builder()
            .type("dir")
            .target(PoolTargetArgs.builder()
                .path("/home/user/cluster_storage")
                .build())
            .build());

        var opensuseLeap = new Volume("opensuseLeap", VolumeArgs.builder()
            .pool(cluster.name())
            .source("http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2")
            .build());

    }
}
Copy
resources:
  # A pool for all cluster volumes
  cluster:
    type: libvirt:Pool
    properties:
      type: dir
      target:
        path: /home/user/cluster_storage
  opensuseLeap:
    type: libvirt:Volume
    properties:
      pool: ${cluster.name}
      source: http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2
Copy

Create Pool Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Pool(name: string, args: PoolArgs, opts?: CustomResourceOptions);
@overload
def Pool(resource_name: str,
         args: PoolArgs,
         opts: Optional[ResourceOptions] = None)

@overload
def Pool(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         type: Optional[str] = None,
         allocation: Optional[float] = None,
         available: Optional[float] = None,
         capacity: Optional[float] = None,
         name: Optional[str] = None,
         path: Optional[str] = None,
         pool_id: Optional[str] = None,
         source: Optional[PoolSourceArgs] = None,
         target: Optional[PoolTargetArgs] = None,
         xml: Optional[PoolXmlArgs] = None)
func NewPool(ctx *Context, name string, args PoolArgs, opts ...ResourceOption) (*Pool, error)
public Pool(string name, PoolArgs args, CustomResourceOptions? opts = null)
public Pool(String name, PoolArgs args)
public Pool(String name, PoolArgs args, CustomResourceOptions options)
type: libvirt:Pool
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. PoolArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. PoolArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. PoolArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. PoolArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. PoolArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var poolResource = new Libvirt.Pool("poolResource", new()
{
    Type = "string",
    Allocation = 0,
    Available = 0,
    Capacity = 0,
    Name = "string",
    PoolId = "string",
    Source = new Libvirt.Inputs.PoolSourceArgs
    {
        Devices = new[]
        {
            new Libvirt.Inputs.PoolSourceDeviceArgs
            {
                Path = "string",
            },
        },
        Name = "string",
    },
    Target = new Libvirt.Inputs.PoolTargetArgs
    {
        Path = "string",
    },
    Xml = new Libvirt.Inputs.PoolXmlArgs
    {
        Xslt = "string",
    },
});
Copy
example, err := libvirt.NewPool(ctx, "poolResource", &libvirt.PoolArgs{
Type: pulumi.String("string"),
Allocation: pulumi.Float64(0),
Available: pulumi.Float64(0),
Capacity: pulumi.Float64(0),
Name: pulumi.String("string"),
PoolId: pulumi.String("string"),
Source: &.PoolSourceArgs{
Devices: .PoolSourceDeviceArray{
&.PoolSourceDeviceArgs{
Path: pulumi.String("string"),
},
},
Name: pulumi.String("string"),
},
Target: &.PoolTargetArgs{
Path: pulumi.String("string"),
},
Xml: &.PoolXmlArgs{
Xslt: pulumi.String("string"),
},
})
Copy
var poolResource = new Pool("poolResource", PoolArgs.builder()
    .type("string")
    .allocation(0)
    .available(0)
    .capacity(0)
    .name("string")
    .poolId("string")
    .source(PoolSourceArgs.builder()
        .devices(PoolSourceDeviceArgs.builder()
            .path("string")
            .build())
        .name("string")
        .build())
    .target(PoolTargetArgs.builder()
        .path("string")
        .build())
    .xml(PoolXmlArgs.builder()
        .xslt("string")
        .build())
    .build());
Copy
pool_resource = libvirt.Pool("poolResource",
    type="string",
    allocation=0,
    available=0,
    capacity=0,
    name="string",
    pool_id="string",
    source={
        "devices": [{
            "path": "string",
        }],
        "name": "string",
    },
    target={
        "path": "string",
    },
    xml={
        "xslt": "string",
    })
Copy
const poolResource = new libvirt.Pool("poolResource", {
    type: "string",
    allocation: 0,
    available: 0,
    capacity: 0,
    name: "string",
    poolId: "string",
    source: {
        devices: [{
            path: "string",
        }],
        name: "string",
    },
    target: {
        path: "string",
    },
    xml: {
        xslt: "string",
    },
});
Copy
type: libvirt:Pool
properties:
    allocation: 0
    available: 0
    capacity: 0
    name: string
    poolId: string
    source:
        devices:
            - path: string
        name: string
    target:
        path: string
    type: string
    xml:
        xslt: string
Copy

Pool Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Pool resource accepts the following input properties:

Type This property is required. string
The type of the pool. Currently, "dir" and "logical" are supported.
Allocation double
Available double
Capacity double
Name string
A unique name for the resource, required by libvirt.
Path string
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

PoolId string
a unique identifier for the resource
Source PoolSource
Target PoolTarget
Xml PoolXml
Type This property is required. string
The type of the pool. Currently, "dir" and "logical" are supported.
Allocation float64
Available float64
Capacity float64
Name string
A unique name for the resource, required by libvirt.
Path string
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

PoolId string
a unique identifier for the resource
Source PoolSourceArgs
Target PoolTargetArgs
Xml PoolXmlArgs
type This property is required. String
The type of the pool. Currently, "dir" and "logical" are supported.
allocation Double
available Double
capacity Double
name String
A unique name for the resource, required by libvirt.
path String
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

poolId String
a unique identifier for the resource
source PoolSource
target PoolTarget
xml PoolXml
type This property is required. string
The type of the pool. Currently, "dir" and "logical" are supported.
allocation number
available number
capacity number
name string
A unique name for the resource, required by libvirt.
path string
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

poolId string
a unique identifier for the resource
source PoolSource
target PoolTarget
xml PoolXml
type This property is required. str
The type of the pool. Currently, "dir" and "logical" are supported.
allocation float
available float
capacity float
name str
A unique name for the resource, required by libvirt.
path str
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

pool_id str
a unique identifier for the resource
source PoolSourceArgs
target PoolTargetArgs
xml PoolXmlArgs
type This property is required. String
The type of the pool. Currently, "dir" and "logical" are supported.
allocation Number
available Number
capacity Number
name String
A unique name for the resource, required by libvirt.
path String
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

poolId String
a unique identifier for the resource
source Property Map
target Property Map
xml Property Map

Outputs

All input properties are implicitly available as output properties. Additionally, the Pool resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Pool Resource

Get an existing Pool resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: PoolState, opts?: CustomResourceOptions): Pool
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        allocation: Optional[float] = None,
        available: Optional[float] = None,
        capacity: Optional[float] = None,
        name: Optional[str] = None,
        path: Optional[str] = None,
        pool_id: Optional[str] = None,
        source: Optional[PoolSourceArgs] = None,
        target: Optional[PoolTargetArgs] = None,
        type: Optional[str] = None,
        xml: Optional[PoolXmlArgs] = None) -> Pool
func GetPool(ctx *Context, name string, id IDInput, state *PoolState, opts ...ResourceOption) (*Pool, error)
public static Pool Get(string name, Input<string> id, PoolState? state, CustomResourceOptions? opts = null)
public static Pool get(String name, Output<String> id, PoolState state, CustomResourceOptions options)
resources:  _:    type: libvirt:Pool    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Allocation double
Available double
Capacity double
Name string
A unique name for the resource, required by libvirt.
Path string
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

PoolId string
a unique identifier for the resource
Source PoolSource
Target PoolTarget
Type string
The type of the pool. Currently, "dir" and "logical" are supported.
Xml PoolXml
Allocation float64
Available float64
Capacity float64
Name string
A unique name for the resource, required by libvirt.
Path string
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

PoolId string
a unique identifier for the resource
Source PoolSourceArgs
Target PoolTargetArgs
Type string
The type of the pool. Currently, "dir" and "logical" are supported.
Xml PoolXmlArgs
allocation Double
available Double
capacity Double
name String
A unique name for the resource, required by libvirt.
path String
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

poolId String
a unique identifier for the resource
source PoolSource
target PoolTarget
type String
The type of the pool. Currently, "dir" and "logical" are supported.
xml PoolXml
allocation number
available number
capacity number
name string
A unique name for the resource, required by libvirt.
path string
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

poolId string
a unique identifier for the resource
source PoolSource
target PoolTarget
type string
The type of the pool. Currently, "dir" and "logical" are supported.
xml PoolXml
allocation float
available float
capacity float
name str
A unique name for the resource, required by libvirt.
path str
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

pool_id str
a unique identifier for the resource
source PoolSourceArgs
target PoolTargetArgs
type str
The type of the pool. Currently, "dir" and "logical" are supported.
xml PoolXmlArgs
allocation Number
available Number
capacity Number
name String
A unique name for the resource, required by libvirt.
path String
Deprecated (Optional) use path in the target block.

Deprecated: Deprecated

poolId String
a unique identifier for the resource
source Property Map
target Property Map
type String
The type of the pool. Currently, "dir" and "logical" are supported.
xml Property Map

Supporting Types

PoolSource
, PoolSourceArgs

Devices List<PoolSourceDevice>
Name string
A unique name for the resource, required by libvirt.
Devices []PoolSourceDevice
Name string
A unique name for the resource, required by libvirt.
devices List<PoolSourceDevice>
name String
A unique name for the resource, required by libvirt.
devices PoolSourceDevice[]
name string
A unique name for the resource, required by libvirt.
devices Sequence[PoolSourceDevice]
name str
A unique name for the resource, required by libvirt.
devices List<Property Map>
name String
A unique name for the resource, required by libvirt.

PoolSourceDevice
, PoolSourceDeviceArgs

Path string
Deprecated (Optional) use path in the target block.
Path string
Deprecated (Optional) use path in the target block.
path String
Deprecated (Optional) use path in the target block.
path string
Deprecated (Optional) use path in the target block.
path str
Deprecated (Optional) use path in the target block.
path String
Deprecated (Optional) use path in the target block.

PoolTarget
, PoolTargetArgs

Path string
Deprecated (Optional) use path in the target block.
Path string
Deprecated (Optional) use path in the target block.
path String
Deprecated (Optional) use path in the target block.
path string
Deprecated (Optional) use path in the target block.
path str
Deprecated (Optional) use path in the target block.
path String
Deprecated (Optional) use path in the target block.

PoolXml
, PoolXmlArgs

Xslt string
Xslt string
xslt String
xslt string
xslt str
xslt String

Package Details

Repository
libvirt dmacvicar/terraform-provider-libvirt
License
Notes
This Pulumi package is based on the libvirt Terraform Provider.