1. Packages
  2. libvirt
  3. API Docs
  4. Volume
libvirt v0.4.5 published on Thursday, Mar 21, 2024 by Pulumi

libvirt.Volume

Explore with Pulumi AI

libvirt logo
libvirt v0.4.5 published on Thursday, Mar 21, 2024 by Pulumi

    Manages a storage volume in libvirt. For more information see the official documentation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as libvirt from "@pulumi/libvirt";
    
    // Base OS image to use to create a cluster of different
    // nodes
    const opensuseLeap = new libvirt.Volume("opensuseLeap", {source: "http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2"});
    // volume to attach to the "master" domain as main disk
    const master = new libvirt.Volume("master", {baseVolumeId: opensuseLeap.id});
    // volumes to attach to the "workers" domains as main disk
    const worker: libvirt.Volume[] = [];
    for (const range = {value: 0}; range.value < _var.workers_count; range.value++) {
        worker.push(new libvirt.Volume(`worker-${range.value}`, {baseVolumeId: opensuseLeap.id}));
    }
    
    import pulumi
    import pulumi_libvirt as libvirt
    
    # Base OS image to use to create a cluster of different
    # nodes
    opensuse_leap = libvirt.Volume("opensuseLeap", source="http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2")
    # volume to attach to the "master" domain as main disk
    master = libvirt.Volume("master", base_volume_id=opensuse_leap.id)
    # volumes to attach to the "workers" domains as main disk
    worker = []
    for range in [{"value": i} for i in range(0, var.workers_count)]:
        worker.append(libvirt.Volume(f"worker-{range['value']}", base_volume_id=opensuse_leap.id))
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-libvirt/sdk/go/libvirt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Base OS image to use to create a cluster of different
    		// nodes
    		opensuseLeap, err := libvirt.NewVolume(ctx, "opensuseLeap", &libvirt.VolumeArgs{
    			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
    		}
    		// volume to attach to the "master" domain as main disk
    		_, err = libvirt.NewVolume(ctx, "master", &libvirt.VolumeArgs{
    			BaseVolumeId: opensuseLeap.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		// volumes to attach to the "workers" domains as main disk
    		var worker []*libvirt.Volume
    		for index := 0; index < _var.Workers_count; index++ {
    			key0 := index
    			_ := index
    			__res, err := libvirt.NewVolume(ctx, fmt.Sprintf("worker-%v", key0), &libvirt.VolumeArgs{
    				BaseVolumeId: opensuseLeap.ID(),
    			})
    			if err != nil {
    				return err
    			}
    			worker = append(worker, __res)
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Libvirt = Pulumi.Libvirt;
    
    return await Deployment.RunAsync(() => 
    {
        // Base OS image to use to create a cluster of different
        // nodes
        var opensuseLeap = new Libvirt.Volume("opensuseLeap", new()
        {
            Source = "http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2",
        });
    
        // volume to attach to the "master" domain as main disk
        var master = new Libvirt.Volume("master", new()
        {
            BaseVolumeId = opensuseLeap.Id,
        });
    
        // volumes to attach to the "workers" domains as main disk
        var worker = new List<Libvirt.Volume>();
        for (var rangeIndex = 0; rangeIndex < @var.Workers_count; rangeIndex++)
        {
            var range = new { Value = rangeIndex };
            worker.Add(new Libvirt.Volume($"worker-{range.Value}", new()
            {
                BaseVolumeId = opensuseLeap.Id,
            }));
        }
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.libvirt.Volume;
    import com.pulumi.libvirt.VolumeArgs;
    import com.pulumi.codegen.internal.KeyedValue;
    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) {
            var opensuseLeap = new Volume("opensuseLeap", VolumeArgs.builder()        
                .source("http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2")
                .build());
    
            var master = new Volume("master", VolumeArgs.builder()        
                .baseVolumeId(opensuseLeap.id())
                .build());
    
            for (var i = 0; i < var_.workers_count(); i++) {
                new Volume("worker-" + i, VolumeArgs.builder()            
                    .baseVolumeId(opensuseLeap.id())
                    .build());
    
            
    }
        }
    }
    
    resources:
      # Base OS image to use to create a cluster of different
      # nodes
      opensuseLeap:
        type: libvirt:Volume
        properties:
          source: http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2
      # volume to attach to the "master" domain as main disk
      master:
        type: libvirt:Volume
        properties:
          baseVolumeId: ${opensuseLeap.id}
      # volumes to attach to the "workers" domains as main disk
      worker:
        type: libvirt:Volume
        properties:
          baseVolumeId: ${opensuseLeap.id}
        options: {}
    

    Tip: when provisioning multiple domains using the same base image, create a libvirt.Volume for the base image and then define the domain specific ones as based on it. This way the image will not be modified and no extra disk space is going to be used for the base image.

    Create Volume Resource

    new Volume(name: string, args?: VolumeArgs, opts?: CustomResourceOptions);
    @overload
    def Volume(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               base_volume_id: Optional[str] = None,
               base_volume_name: Optional[str] = None,
               base_volume_pool: Optional[str] = None,
               format: Optional[str] = None,
               name: Optional[str] = None,
               pool: Optional[str] = None,
               size: Optional[int] = None,
               source: Optional[str] = None,
               xml: Optional[VolumeXmlArgs] = None)
    @overload
    def Volume(resource_name: str,
               args: Optional[VolumeArgs] = None,
               opts: Optional[ResourceOptions] = None)
    func NewVolume(ctx *Context, name string, args *VolumeArgs, opts ...ResourceOption) (*Volume, error)
    public Volume(string name, VolumeArgs? args = null, CustomResourceOptions? opts = null)
    public Volume(String name, VolumeArgs args)
    public Volume(String name, VolumeArgs args, CustomResourceOptions options)
    
    type: libvirt:Volume
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args VolumeArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args VolumeArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args VolumeArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args VolumeArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args VolumeArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Volume Resource Properties

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

    Inputs

    The Volume resource accepts the following input properties:

    BaseVolumeId string
    The backing volume (CoW) to use for this volume.
    BaseVolumeName string
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    BaseVolumePool string
    The name of the storage pool containing the volume defined by base_volume_name.
    Format string
    Name string
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    Pool string
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    Size int
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    Source string
    Xml VolumeXml
    BaseVolumeId string
    The backing volume (CoW) to use for this volume.
    BaseVolumeName string
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    BaseVolumePool string
    The name of the storage pool containing the volume defined by base_volume_name.
    Format string
    Name string
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    Pool string
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    Size int
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    Source string
    Xml VolumeXmlArgs
    baseVolumeId String
    The backing volume (CoW) to use for this volume.
    baseVolumeName String
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    baseVolumePool String
    The name of the storage pool containing the volume defined by base_volume_name.
    format String
    name String
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool String
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size Integer
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source String
    xml VolumeXml
    baseVolumeId string
    The backing volume (CoW) to use for this volume.
    baseVolumeName string
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    baseVolumePool string
    The name of the storage pool containing the volume defined by base_volume_name.
    format string
    name string
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool string
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size number
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source string
    xml VolumeXml
    base_volume_id str
    The backing volume (CoW) to use for this volume.
    base_volume_name str
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    base_volume_pool str
    The name of the storage pool containing the volume defined by base_volume_name.
    format str
    name str
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool str
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size int
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source str
    xml VolumeXmlArgs
    baseVolumeId String
    The backing volume (CoW) to use for this volume.
    baseVolumeName String
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    baseVolumePool String
    The name of the storage pool containing the volume defined by base_volume_name.
    format String
    name String
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool String
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size Number
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source String
    xml Property Map

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Volume 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 Volume Resource

    Get an existing Volume 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?: VolumeState, opts?: CustomResourceOptions): Volume
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            base_volume_id: Optional[str] = None,
            base_volume_name: Optional[str] = None,
            base_volume_pool: Optional[str] = None,
            format: Optional[str] = None,
            name: Optional[str] = None,
            pool: Optional[str] = None,
            size: Optional[int] = None,
            source: Optional[str] = None,
            xml: Optional[VolumeXmlArgs] = None) -> Volume
    func GetVolume(ctx *Context, name string, id IDInput, state *VolumeState, opts ...ResourceOption) (*Volume, error)
    public static Volume Get(string name, Input<string> id, VolumeState? state, CustomResourceOptions? opts = null)
    public static Volume get(String name, Output<String> id, VolumeState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    BaseVolumeId string
    The backing volume (CoW) to use for this volume.
    BaseVolumeName string
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    BaseVolumePool string
    The name of the storage pool containing the volume defined by base_volume_name.
    Format string
    Name string
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    Pool string
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    Size int
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    Source string
    Xml VolumeXml
    BaseVolumeId string
    The backing volume (CoW) to use for this volume.
    BaseVolumeName string
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    BaseVolumePool string
    The name of the storage pool containing the volume defined by base_volume_name.
    Format string
    Name string
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    Pool string
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    Size int
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    Source string
    Xml VolumeXmlArgs
    baseVolumeId String
    The backing volume (CoW) to use for this volume.
    baseVolumeName String
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    baseVolumePool String
    The name of the storage pool containing the volume defined by base_volume_name.
    format String
    name String
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool String
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size Integer
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source String
    xml VolumeXml
    baseVolumeId string
    The backing volume (CoW) to use for this volume.
    baseVolumeName string
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    baseVolumePool string
    The name of the storage pool containing the volume defined by base_volume_name.
    format string
    name string
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool string
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size number
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source string
    xml VolumeXml
    base_volume_id str
    The backing volume (CoW) to use for this volume.
    base_volume_name str
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    base_volume_pool str
    The name of the storage pool containing the volume defined by base_volume_name.
    format str
    name str
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool str
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size int
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source str
    xml VolumeXmlArgs
    baseVolumeId String
    The backing volume (CoW) to use for this volume.
    baseVolumeName String
    The name of the backing volume (CoW) to use for this volume. Note well: when base_volume_pool is not specified the volume is going to be searched inside of pool.
    baseVolumePool String
    The name of the storage pool containing the volume defined by base_volume_name.
    format String
    name String
    A unique name for the resource, required by libvirt. Changing this forces a new resource to be created.
    pool String
    The storage pool where the resource will be created. If not given, the default storage pool will be used.
    size Number
    The size of the volume in bytes (if you don't like this, help fix this issue. If source is specified, size will be set to the source image file size. size can be omitted if source is specified. size will then be set to the source image file size. size can be omitted if base_volume_id or base_volume_name is specified. size will then be set to the base volume size. If size is specified to be bigger than base_volume_id or base_volume_name size, you can use cloudinit if your OS supports it, with libvirt.CloudInitDisk and the growpart module to resize the partition.
    source String
    xml Property Map

    Supporting Types

    VolumeXml, VolumeXmlArgs

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

    Package Details

    Repository
    libvirt pulumi/pulumi-libvirt
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the libvirt Terraform Provider.
    libvirt logo
    libvirt v0.4.5 published on Thursday, Mar 21, 2024 by Pulumi