drivers

package
v0.0.0-...-288c4de Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Overview

Example (Ceph_parseParent)
d := &ceph{}

parents := []string{
	"pool/zombie_image_9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb_ext4.block@readonly",
	"pool/zombie_image_9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb_ext4.block",
	"pool/image_9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb_ext4.block@readonly",
	"pool/zombie_image_9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb_ext4@readonly",
	"pool/zombie_image_9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb_ext4",
	"pool/image_9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb_ext4@readonly",
	"pool/zombie_image_2cfc5a5567b8d74c0986f3d8a77a2a78e58fe22ea9abd2693112031f85afa1a1_xfs@zombie_snapshot_7f6d679b-ee25-419e-af49-bb805cb32088",
	"pool/container_bar@zombie_snapshot_ce77e971-6c1b-45c0-b193-dba9ec5e7d82",
	"pool/container_test-project_c4.block",
	"pool/zombie_container_test-project_c1_28e7a7ab-740a-490c-8118-7caf7810f83b@zombie_snapshot_1027f4ab-de11-4cee-8015-bd532a1fed76",
}

for _, parent := range parents {
	vol, snapName, err := d.parseParent(parent)
	fmt.Println(vol.pool, vol.volType, vol.name, vol.config["block.filesystem"], vol.contentType, snapName, err)
}
Output:

pool zombie_image 9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb ext4 block readonly <nil>
pool zombie_image 9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb ext4 block  <nil>
pool image 9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb ext4 block readonly <nil>
pool zombie_image 9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb ext4 filesystem readonly <nil>
pool zombie_image 9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb ext4 filesystem  <nil>
pool image 9e90b7b9ccdd7a671a987fadcf07ab92363be57e7f056d18d42af452cdaf95bb ext4 filesystem readonly <nil>
pool zombie_image 2cfc5a5567b8d74c0986f3d8a77a2a78e58fe22ea9abd2693112031f85afa1a1 xfs filesystem zombie_snapshot_7f6d679b-ee25-419e-af49-bb805cb32088 <nil>
pool container bar  filesystem zombie_snapshot_ce77e971-6c1b-45c0-b193-dba9ec5e7d82 <nil>
pool container test-project_c4  block  <nil>
pool zombie_container test-project_c1_28e7a7ab-740a-490c-8118-7caf7810f83b  filesystem zombie_snapshot_1027f4ab-de11-4cee-8015-bd532a1fed76 <nil>
Example (Lvm_parseLogicalVolumeName)
d := &lvm{}
d.name = "pool"

type testVol struct {
	lvName string
	parent Volume
}

parentCT := Volume{
	contentType: ContentTypeFS,
	volType:     VolumeTypeContainer,
	name:        "proj_testct-with-hyphens",
}

parentVM := Volume{
	contentType: ContentTypeBlock,
	volType:     VolumeTypeVM,
	name:        "proj_testvm-with-hyphens",
}

custVol := Volume{
	contentType: ContentTypeFS,
	volType:     VolumeTypeCustom,
	name:        "proj_testvol-with-hyphens.block", // .block ending doesn't indicate a block vol.
}

tests := []testVol{
	// Test container snapshots.
	{parent: parentCT, lvName: "containers_proj_testct--with--hyphens"},
	{parent: parentCT, lvName: "containers_proj_testct--with--hyphens-snap1--with--hyphens"},
	{parent: parentCT, lvName: "containers_proj_testct--with--hyphens-snap1--with--hyphens.block"},
	// Test container with name containing snapshot prefix.
	{parent: parentCT, lvName: "containers_proj_testct--with--hyphens--snap0"},
	// Test virtual machine snapshots.
	{parent: parentVM, lvName: "virtual-machines_proj_testvm--with--hyphens.block"},
	{parent: parentVM, lvName: "virtual-machines_proj_testvm--with--hyphens-snap1--with--hyphens.block"},
	{parent: parentVM, lvName: "virtual-machines_proj_testvm--with--hyphens-snap1--with--hyphens.block.block"},
	// Test custom volume filesystem snapshots.
	{parent: custVol, lvName: "custom_proj_testvol--with--hyphens.block"},
	{parent: custVol, lvName: "custom_proj_testvol--with--hyphens.block-snap1--with--hyphens.block"},
}

for _, test := range tests {
	snapName := d.parseLogicalVolumeSnapshot(test.parent, test.lvName)
	if snapName == "" {
		fmt.Printf("%s: Unrecognised\n", test.lvName)
	} else {
		fmt.Printf("%s: %s\n", test.lvName, snapName)
	}
}
Output:

containers_proj_testct--with--hyphens: Unrecognised
containers_proj_testct--with--hyphens-snap1--with--hyphens: snap1-with-hyphens
containers_proj_testct--with--hyphens-snap1--with--hyphens.block: snap1-with-hyphens.block
containers_proj_testct--with--hyphens--snap0: Unrecognised
virtual-machines_proj_testvm--with--hyphens.block: Unrecognised
virtual-machines_proj_testvm--with--hyphens-snap1--with--hyphens.block: snap1-with-hyphens
virtual-machines_proj_testvm--with--hyphens-snap1--with--hyphens.block.block: snap1-with-hyphens.block
custom_proj_testvol--with--hyphens.block: Unrecognised
custom_proj_testvol--with--hyphens.block-snap1--with--hyphens.block: snap1-with-hyphens.block

Index

Examples

Constants

View Source
const CephDefaultCluster = "ceph"

CephDefaultCluster represents the default ceph cluster name.

View Source
const CephDefaultUser = "admin"

CephDefaultUser represents the default ceph user name.

View Source
const ContentTypeBlock = ContentType("block")

ContentTypeBlock indicates the volume will be a block device and its contents and we do not know which filesystem(s) (if any) are in use.

View Source
const ContentTypeFS = ContentType("filesystem")

ContentTypeFS indicates the volume will be populated with a mountabble filesystem.

View Source
const ContentTypeISO = ContentType("iso")

ContentTypeISO indicates the volume will be an ISO which is read-only, and uses the ISO 9660 filesystem.

View Source
const DefaultBlockSize = "10GiB"

DefaultBlockSize is the default size of block volumes.

View Source
const DefaultFilesystem = "ext4"

DefaultFilesystem filesytem to use for block devices by default.

View Source
const MinBlockBoundary = 8192

MinBlockBoundary minimum block boundary size to use.

View Source
const VolumeTypeBucket = VolumeType("buckets")

VolumeTypeBucket represents a bucket storage volume.

View Source
const VolumeTypeContainer = VolumeType("containers")

VolumeTypeContainer represents a container storage volume.

View Source
const VolumeTypeCustom = VolumeType("custom")

VolumeTypeCustom represents a custom storage volume.

View Source
const VolumeTypeImage = VolumeType("images")

VolumeTypeImage represents an image storage volume.

View Source
const VolumeTypeVM = VolumeType("virtual-machines")

VolumeTypeVM represents a virtual-machine storage volume.

Variables

View Source
var BaseDirectories = map[VolumeType][]string{
	VolumeTypeBucket:    {"buckets"},
	VolumeTypeContainer: {"containers", "containers-snapshots"},
	VolumeTypeCustom:    {"custom", "custom-snapshots"},
	VolumeTypeImage:     {"images"},
	VolumeTypeVM:        {"virtual-machines", "virtual-machines-snapshots"},
}

BaseDirectories maps volume types to the expected directories.

View Source
var ErrCannotBeShrunk = fmt.Errorf("Cannot be shrunk")

ErrCannotBeShrunk is the "Cannot be shrunk" error.

View Source
var ErrInUse = fmt.Errorf("In use")

ErrInUse indicates operation cannot proceed as resource is in use.

View Source
var ErrNotSupported = fmt.Errorf("Not supported")

ErrNotSupported is the "Not supported" error.

View Source
var ErrSnapshotDoesNotMatchIncrementalSource = fmt.Errorf("Snapshot does not match incremental source")

ErrSnapshotDoesNotMatchIncrementalSource in the "Snapshot does not match incremental source" error.

View Source
var ErrUnknownDriver = fmt.Errorf("Unknown driver")

ErrUnknownDriver is the "Unknown driver" error.

Functions

func AllDriverNames

func AllDriverNames() []string

AllDriverNames returns a list of all storage driver names.

func BTRFSSubVolumeIsRo

func BTRFSSubVolumeIsRo(path string) bool

BTRFSSubVolumeIsRo returns if subvolume is read only.

func BTRFSSubVolumeMakeRo

func BTRFSSubVolumeMakeRo(path string) error

BTRFSSubVolumeMakeRo makes a subvolume read only. Deprecated use btrfs.setSubvolumeReadonlyProperty().

func BTRFSSubVolumeMakeRw

func BTRFSSubVolumeMakeRw(path string) error

BTRFSSubVolumeMakeRw makes a sub volume read/write. Deprecated use btrfs.setSubvolumeReadonlyProperty().

func BTRFSSubVolumesGet

func BTRFSSubVolumesGet(path string) ([]string, error)

BTRFSSubVolumesGet gets subvolumes.

func BlockDiskSizeBytes

func BlockDiskSizeBytes(blockDiskPath string) (int64, error)

BlockDiskSizeBytes returns the size of a block disk (path can be either block device or raw file).

func CephGetRBDImageName

func CephGetRBDImageName(vol Volume, snapName string, zombie bool) string

CephGetRBDImageName returns the RBD image name as it is used in ceph. Example: A custom block volume named vol1 in project default will return custom_default_vol1.block.

func CephKeyring

func CephKeyring(cluster string, client string) (string, error)

CephKeyring gets the key for a particular Ceph cluster and client name.

func CephMonitors

func CephMonitors(cluster string) ([]string, error)

CephMonitors gets the mon-host field for the relevant cluster and extracts the list of addresses and ports.

func GetPoolMountPath

func GetPoolMountPath(poolName string) string

GetPoolMountPath returns the mountpoint of the given pool. {LXD_DIR}/storage-pools/<pool>.

func GetSnapshotVolumeName

func GetSnapshotVolumeName(parentName, snapshotName string) string

GetSnapshotVolumeName returns the full volume name for a parent volume and snapshot name.

func GetVolumeMountPath

func GetVolumeMountPath(poolName string, volType VolumeType, volName string) string

GetVolumeMountPath returns the mount path for a specific volume based on its pool and type and whether it is a snapshot or not. For VolumeTypeImage the volName is the image fingerprint.

func GetVolumeSnapshotDir

func GetVolumeSnapshotDir(poolName string, volType VolumeType, volName string) string

GetVolumeSnapshotDir gets the snapshot mount directory for the parent volume.

func IsContentBlock

func IsContentBlock(contentType ContentType) bool

IsContentBlock returns true if the content type is either block or iso.

func OperationLockName

func OperationLockName(operationName string, poolName string, volType VolumeType, contentType ContentType, volName string) string

OperationLockName returns the storage specific lock name to use with locking package.

func RemoteDriverNames

func RemoteDriverNames() []string

RemoteDriverNames returns a list of remote storage driver names.

func ShiftBtrfsRootfs

func ShiftBtrfsRootfs(path string, diskIdmap *idmap.IdmapSet) error

ShiftBtrfsRootfs shifts the BTRFS root filesystem.

func ShiftZFSSkipper

func ShiftZFSSkipper(dir string, absPath string, fi os.FileInfo) bool

ShiftZFSSkipper indicates which files not to shift for ZFS.

func TryMount

func TryMount(src string, dst string, fs string, flags uintptr, options string) error

TryMount tries mounting a filesystem multiple times. This is useful for unreliable backends.

func TryUnmount

func TryUnmount(path string, flags int) error

TryUnmount tries unmounting a filesystem multiple times. This is useful for unreliable backends.

func UnshiftBtrfsRootfs

func UnshiftBtrfsRootfs(path string, diskIdmap *idmap.IdmapSet) error

UnshiftBtrfsRootfs unshifts the BTRFS root filesystem.

func ValidateZfsBlocksize

func ValidateZfsBlocksize(value string) error

ValidateZfsBlocksize validates blocksize property value on the pool.

Types

type BTRFSMetaDataHeader

type BTRFSMetaDataHeader struct {
	Subvolumes []BTRFSSubVolume `json:"subvolumes" yaml:"subvolumes"` // Sub volumes inside the volume (including the top level ones).
}

BTRFSMetaDataHeader is the meta data header about the volumes being sent/stored. Note: This is used by both migration and backup subsystems so do not modify without considering both!

type BTRFSSubVolume

type BTRFSSubVolume struct {
	Path     string `json:"path" yaml:"path"`         // Path inside the volume where the subvolume belongs (so / is the top of the volume tree).
	Snapshot string `json:"snapshot" yaml:"snapshot"` // Snapshot name the subvolume belongs to.
	Readonly bool   `json:"readonly" yaml:"readonly"` // Is the sub volume read only or not.
	UUID     string `json:"uuid" yaml:"uuid"`         // The subvolume UUID.
}

BTRFSSubVolume is the structure used to store information about a subvolume. Note: This is used by both migration and backup subsystems so do not modify without considering both!

type ContentType

type ContentType string

ContentType indicates the format of the volume.

type Driver

type Driver interface {
	// Internal.
	Info() Info
	HasVolume(vol Volume) (bool, error)

	// Export struct details.
	Name() string
	Config() map[string]string
	Logger() logger.Logger

	// Pool.
	FillConfig() error
	Create() error
	Delete(op *operations.Operation) error
	// Mount mounts a storage pool if needed, returns true if we caused a new mount, false if already mounted.
	Mount() (bool, error)

	// Unmount unmounts a storage pool if needed, returns true if unmounted, false if was not mounted.
	Unmount() (bool, error)
	GetResources() (*api.ResourcesStoragePool, error)
	Validate(config map[string]string) error
	Update(changedConfig map[string]string) error
	ApplyPatch(name string) error

	// Buckets.
	ValidateBucket(bucket Volume) error
	GetBucketURL(bucketName string) *url.URL
	CreateBucket(bucket Volume, op *operations.Operation) error
	DeleteBucket(bucket Volume, op *operations.Operation) error
	UpdateBucket(bucket Volume, changedConfig map[string]string) error
	ValidateBucketKey(keyName string, creds S3Credentials, roleName string) error
	CreateBucketKey(bucket Volume, keyName string, creds S3Credentials, roleName string, op *operations.Operation) (*S3Credentials, error)
	UpdateBucketKey(bucket Volume, keyName string, creds S3Credentials, roleName string, op *operations.Operation) (*S3Credentials, error)
	DeleteBucketKey(bucket Volume, keyName string, op *operations.Operation) error

	// Volumes.
	FillVolumeConfig(vol Volume) error
	ValidateVolume(vol Volume, removeUnknownKeys bool) error
	CreateVolume(vol Volume, filler *VolumeFiller, op *operations.Operation) error
	CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots bool, allowInconsistent bool, op *operations.Operation) error
	RefreshVolume(vol Volume, srcVol Volume, srcSnapshots []Volume, allowInconsistent bool, op *operations.Operation) error
	DeleteVolume(vol Volume, op *operations.Operation) error
	RenameVolume(vol Volume, newName string, op *operations.Operation) error
	UpdateVolume(vol Volume, changedConfig map[string]string) error
	GetVolumeUsage(vol Volume) (int64, error)
	SetVolumeQuota(vol Volume, size string, allowUnsafeResize bool, op *operations.Operation) error
	GetVolumeDiskPath(vol Volume) (string, error)
	ListVolumes() ([]Volume, error)

	// MountVolume mounts a storage volume (if not mounted) and increments reference counter.
	MountVolume(vol Volume, op *operations.Operation) error

	// MountVolumeSnapshot mounts a storage volume snapshot as readonly.
	MountVolumeSnapshot(snapVol Volume, op *operations.Operation) error

	// UnmountVolume unmounts a storage volume, returns true if unmounted, false if was not
	// mounted.
	UnmountVolume(vol Volume, keepBlockDev bool, op *operations.Operation) (bool, error)

	// UnmountVolume unmounts a storage volume snapshot, returns true if unmounted, false if was
	// not mounted.
	UnmountVolumeSnapshot(snapVol Volume, op *operations.Operation) (bool, error)

	CreateVolumeSnapshot(snapVol Volume, op *operations.Operation) error
	DeleteVolumeSnapshot(snapVol Volume, op *operations.Operation) error
	RenameVolumeSnapshot(snapVol Volume, newSnapshotName string, op *operations.Operation) error
	VolumeSnapshots(vol Volume, op *operations.Operation) ([]string, error)
	RestoreVolume(vol Volume, snapshotName string, op *operations.Operation) error

	// Migration.
	MigrationTypes(contentType ContentType, refresh bool, copySnapshots bool) []migration.Type
	MigrateVolume(vol Volume, conn io.ReadWriteCloser, volSrcArgs *migration.VolumeSourceArgs, op *operations.Operation) error
	CreateVolumeFromMigration(vol Volume, conn io.ReadWriteCloser, volTargetArgs migration.VolumeTargetArgs, preFiller *VolumeFiller, op *operations.Operation) error

	// Backup.
	BackupVolume(vol Volume, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots []string, op *operations.Operation) error
	CreateVolumeFromBackup(vol Volume, srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) (VolumePostHook, revert.Hook, error)
	// contains filtered or unexported methods
}

Driver represents a low-level storage driver.

func Load

func Load(state *state.State, driverName string, name string, config map[string]string, logger logger.Logger, volIDFunc func(volType VolumeType, volName string) (int64, error), commonRules *Validators) (Driver, error)

Load returns a Driver for an existing low-level storage pool.

type ErrDeleteSnapshots

type ErrDeleteSnapshots struct {
	Snapshots []string
}

ErrDeleteSnapshots is a special error used to tell the backend to delete more recent snapshots.

func (ErrDeleteSnapshots) Error

func (e ErrDeleteSnapshots) Error() string

type Info

type Info struct {
	Name                  string
	Version               string
	VolumeTypes           []VolumeType // Supported volume types.
	Buckets               bool         // Buckets supported.
	Remote                bool         // Whether the driver uses a remote backing store.
	VolumeMultiNode       bool         // Whether volumes can be used on multiple nodes concurrently.
	OptimizedImages       bool         // Whether driver stores images as separate volume.
	OptimizedBackups      bool         // Whether driver supports optimized volume backups.
	OptimizedBackupHeader bool         // Whether driver generates an optimised backup header file in backup.
	PreservesInodes       bool         // Whether driver preserves inodes when volumes are moved hosts.
	BlockBacking          bool         // Whether driver uses block devices as backing store.
	RunningCopyFreeze     bool         // Whether instance should be frozen during snapshot if running.
	DirectIO              bool         // Whether the driver supports direct I/O.
	IOUring               bool         // Whether the driver supports io_uring.
	MountedRoot           bool         // Whether the pool directory itself is a mount.
}

Info represents information about a storage driver.

func SupportedDrivers

func SupportedDrivers(s *state.State) []Info

SupportedDrivers returns a list of supported storage drivers by loading each storage driver and running its compatibility inspection process. This can take a long time if a driver is not supported.

type S3Credentials

type S3Credentials struct {
	AccessKey string `json:"access_key"`
	SecretKey string `json:"secret_key"`
}

S3Credentials represents the credentials to access a bucket.

type Validators

type Validators struct {
	PoolRules   func() map[string]func(string) error
	VolumeRules func(vol Volume) map[string]func(string) error
}

Validators contains functions used for validating a drivers's config.

type Volume

type Volume struct {
	// contains filtered or unexported fields
}

Volume represents a storage volume, and provides functions to mount and unmount it.

func NewVolume

func NewVolume(driver Driver, poolName string, volType VolumeType, contentType ContentType, volName string, volConfig map[string]string, poolConfig map[string]string) Volume

NewVolume instantiates a new Volume struct.

func (Volume) Clone

func (v Volume) Clone() Volume

Clone returns a copy of the volume.

func (Volume) Config

func (v Volume) Config() map[string]string

Config returns the volume's (unexpanded) config.

func (Volume) ConfigBlockFilesystem

func (v Volume) ConfigBlockFilesystem() string

ConfigBlockFilesystem returns the filesystem to use for block volumes. Returns config value "block.filesystem" if defined in volume or pool's volume config, otherwise the DefaultFilesystem.

func (Volume) ConfigBlockMountOptions

func (v Volume) ConfigBlockMountOptions() string

ConfigBlockMountOptions returns the filesystem mount options to use for block volumes. Returns config value "block.mount_options" if defined in volume or pool's volume config, otherwise defaultFilesystemMountOptions.

func (Volume) ConfigSize

func (v Volume) ConfigSize() string

ConfigSize returns the size to use when creating new a volume. Returns config value "size" if defined in volume or pool's volume config, otherwise for block volumes and block-backed volumes the defaultBlockSize. For other volumes an empty string is returned if no size is defined.

func (Volume) ConfigSizeFromSource

func (v Volume) ConfigSizeFromSource(srcVol Volume) (string, error)

ConfigSizeFromSource derives the volume size to use for a new volume when copying from a source volume. Where possible (if the source volume has a volatile.rootfs.size property), it checks that the source volume isn't larger than the volume's "size" setting and the pool's "volume.size" setting.

func (Volume) ContentType

func (v Volume) ContentType() ContentType

ContentType returns the content type.

func (Volume) EnsureMountPath

func (v Volume) EnsureMountPath() error

EnsureMountPath creates the volume's mount path if missing, then sets the correct permission for the type. If permission setting fails and the volume is a snapshot then the error is ignored as snapshots are read only.

func (Volume) ExpandedConfig

func (v Volume) ExpandedConfig(key string) string

ExpandedConfig returns either the value of the volume's config key or the pool's config "volume.{key}" value.

func (Volume) IsBlockBacked

func (v Volume) IsBlockBacked() bool

IsBlockBacked indicates whether storage device is block backed.

func (Volume) IsCustomBlock

func (v Volume) IsCustomBlock() bool

IsCustomBlock returns true if volume is a custom block volume.

func (Volume) IsSnapshot

func (v Volume) IsSnapshot() bool

IsSnapshot indicates if volume is a snapshot.

func (Volume) IsVMBlock

func (v Volume) IsVMBlock() bool

IsVMBlock returns true if volume is a block volume for virtual machines or associated images.

func (Volume) MountInUse

func (v Volume) MountInUse() bool

MountInUse returns whether the volume has a mount ref counter >0.

func (Volume) MountLock

func (v Volume) MountLock() locking.UnlockFunc

MountLock attempts to lock the mount lock for the volume and returns the UnlockFunc.

func (Volume) MountPath

func (v Volume) MountPath() string

MountPath returns the path where the volume will be mounted.

func (Volume) MountRefCountDecrement

func (v Volume) MountRefCountDecrement() uint

MountRefCountDecrement decrements the mount ref counter for the volume and returns the new value.

func (Volume) MountRefCountIncrement

func (v Volume) MountRefCountIncrement() uint

MountRefCountIncrement increments the mount ref counter for the volume and returns the new value.

func (Volume) MountTask

func (v Volume) MountTask(task func(mountPath string, op *operations.Operation) error, op *operations.Operation) error

MountTask runs the supplied task after mounting the volume if needed. If the volume was mounted for this then it is unmounted when the task finishes.

func (Volume) Name

func (v Volume) Name() string

Name returns volume's name.

func (Volume) NewSnapshot

func (v Volume) NewSnapshot(snapshotName string) (Volume, error)

NewSnapshot instantiates a new Volume struct representing a snapshot of the parent volume.

func (Volume) NewVMBlockFilesystemVolume

func (v Volume) NewVMBlockFilesystemVolume() Volume

NewVMBlockFilesystemVolume returns a copy of the volume with the content type set to ContentTypeFS and the config "size" property set to "size.state" or DefaultVMBlockFilesystemSize if not set.

func (Volume) Pool

func (v Volume) Pool() string

Pool returns the volume's pool name.

func (Volume) SetConfigSize

func (v Volume) SetConfigSize(size string)

SetConfigSize sets the size config property on the Volume (does not resize volume).

func (Volume) SetConfigStateSize

func (v Volume) SetConfigStateSize(size string)

SetConfigStateSize sets the size.state config property on the Volume (does not resize volume).

func (*Volume) SetHasSource

func (v *Volume) SetHasSource(hasSource bool)

SetHasSource indicates whether the Volume is created from a source.

func (*Volume) SetMountFilesystemProbe

func (v *Volume) SetMountFilesystemProbe(probe bool)

SetMountFilesystemProbe enables or disables the probing mode when mounting the filesystem volume.

func (Volume) SetQuota

func (v Volume) SetQuota(size string, allowUnsafeResize bool, op *operations.Operation) error

SetQuota calls SetVolumeQuota on the Volume's driver.

func (Volume) Snapshots

func (v Volume) Snapshots(op *operations.Operation) ([]Volume, error)

Snapshots returns a list of snapshots for the volume (in no particular order).

func (Volume) SnapshotsMatch

func (v Volume) SnapshotsMatch(snapNames []string, op *operations.Operation) error

SnapshotsMatch checks that the snapshots, according to the storage driver, match those provided (although not necessarily in the same order).

func (Volume) Type

func (v Volume) Type() VolumeType

Type returns the volume type.

func (Volume) UnmountTask

func (v Volume) UnmountTask(task func(op *operations.Operation) error, keepBlockDev bool, op *operations.Operation) error

UnmountTask runs the supplied task after unmounting the volume if needed. If the volume was unmounted for this then it is mounted when the task finishes. keepBlockDev indicates if backing block device should be not be deactivated if volume is unmounted.

type VolumeFiller

type VolumeFiller struct {
	Fill func(vol Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) // Function to fill the volume.
	Size int64                                                                         // Size of the unpacked volume in bytes.

	Fingerprint string // If the Filler will unpack an image, it should be this fingerprint.
}

VolumeFiller provides a struct for filling a volume.

type VolumePostHook

type VolumePostHook func(vol Volume) error

VolumePostHook function returned from a storage action that should be run later to complete the action.

type VolumeType

type VolumeType string

VolumeType represents a storage volume type.

func (VolumeType) IsInstance

func (t VolumeType) IsInstance() bool

IsInstance indicates if the VolumeType represents an instance type.

type ZFSDataset

type ZFSDataset struct {
	Name string `json:"name" yaml:"name"`
	GUID string `json:"guid" yaml:"guid"`
}

ZFSDataset is the structure used to store information about a dataset.

type ZFSMetaDataHeader

type ZFSMetaDataHeader struct {
	SnapshotDatasets []ZFSDataset `json:"snapshot_datasets" yaml:"snapshot_datasets"`
}

ZFSMetaDataHeader is the meta data header about the datasets being sent/stored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL