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 ¶
- Constants
- Variables
- func AllDriverNames() []string
- func CanUseOptimizedImage(vol Volume) (bool, error)
- func CephBuildMount(user string, key string, fsid string, monitors Monitors, fsName string, ...) (source string, options []string)
- func CephFSID(ctx context.Context, cluster string) (string, error)
- func CephGetRBDImageName(vol Volume, zombie bool) (imageName string, snapName string)
- func CephKeyring(ctx context.Context, cluster string, client string) (string, error)
- func CephMSMode(ctx context.Context, cluster string) (string, error)
- func DefaultVMBlockFilesystemSize(driverName string) (string, error)
- func GetPoolMountPath(poolName string) string
- func GetSnapshotVolumeName(parentName, snapshotName string) string
- func GetVolumeMountPath(poolName string, volType VolumeType, volName string) string
- func GetVolumeSnapshotDir(poolName string, volType VolumeType, volName string) string
- func IsContentBlock(contentType ContentType) bool
- func OperationLockName(operationName string, poolName string, volType VolumeType, ...) string
- func PatchUpdatePowerFlexSnapshotPrefix(d Driver, snapVols []Volume) error
- func RemoteDriverNames() []string
- func ResolveServerName(serverName string) (string, error)
- func ShiftBtrfsRootfs(path string, diskIdmap *idmap.IdmapSet) error
- func ShiftZFSSkipper(dir string, absPath string, fi os.FileInfo) bool
- func TryMount(ctx context.Context, src string, dst string, fs string, flags uintptr, ...) error
- func TryUnmount(path string, flags int) error
- func UnshiftBtrfsRootfs(path string, diskIdmap *idmap.IdmapSet) error
- func ValidPoolName(poolName string) error
- func ValidVolumeName(volumeName string) error
- func ValidateZfsBlocksize(value string) error
- func ZFSSupportsDelegation() bool
- type BTRFSMetaDataHeader
- type BTRFSSubVolume
- type ContentType
- type Driver
- type ErrDeleteSnapshots
- type Info
- type Monitors
- type S3Credentials
- type Validators
- type Volume
- func (v Volume) Clone() Volume
- func (v Volume) Config() map[string]string
- func (v Volume) ConfigBlockFilesystem() string
- func (v Volume) ConfigBlockMountOptions() string
- func (v Volume) ConfigSize() string
- func (v Volume) ConfigSizeFromSource(srcVol Volume) (string, error)
- func (v Volume) ContentType() ContentType
- func (v Volume) EnsureMountPath() error
- func (v Volume) ExpandedConfig(key string) string
- func (v *Volume) GetParent() Volume
- func (v Volume) IsBlockBacked() bool
- func (v Volume) IsCustomBlock() bool
- func (v Volume) IsSnapshot() bool
- func (v Volume) IsVMBlock() bool
- func (v Volume) MountInUse() bool
- func (v Volume) MountLock() (locking.UnlockFunc, error)
- func (v Volume) MountPath() string
- func (v Volume) MountRefCountDecrement() uint
- func (v Volume) MountRefCountIncrement() uint
- func (v Volume) MountTask(...) error
- func (v Volume) Name() string
- func (v Volume) NewSnapshot(snapshotName string) (Volume, error)
- func (v Volume) NewVMBlockFilesystemVolume() Volume
- func (v Volume) Pool() string
- func (v Volume) SetConfigSize(size string)
- func (v Volume) SetConfigStateSize(size string)
- func (v *Volume) SetHasSource(hasSource bool)
- func (v *Volume) SetMountCustomPath(path string)
- func (v *Volume) SetMountFilesystemProbe(probe bool)
- func (v *Volume) SetParentUUID(parentUUID string)
- func (v Volume) SetQuota(size string, allowUnsafeResize bool, ...) error
- func (v Volume) Snapshots(progressReporter ioprogress.ProgressReporter) ([]Volume, error)
- func (v Volume) Type() VolumeType
- func (v Volume) UnmountTask(task func(progressReporter ioprogress.ProgressReporter) error, ...) error
- type VolumeCopy
- type VolumeFiller
- type VolumePostHook
- type VolumeType
- type ZFSDataset
- type ZFSMetaDataHeader
Examples ¶
Constants ¶
const CephDefaultCluster = "ceph"
CephDefaultCluster represents the default ceph cluster name.
const CephDefaultUser = "admin"
CephDefaultUser represents the default ceph user name.
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.
const ContentTypeFS = ContentType("filesystem")
ContentTypeFS indicates the volume will be populated with a mountabble filesystem.
const ContentTypeISO = ContentType("iso")
ContentTypeISO indicates the volume will be an ISO which is read-only, and uses the ISO 9660 filesystem.
const DefaultFilesystem = "ext4"
DefaultFilesystem filesytem to use for block devices by default.
const MinBlockBoundary = 8192
MinBlockBoundary minimum block boundary size to use.
const VolumeTypeBucket = VolumeType("buckets")
VolumeTypeBucket represents a bucket storage volume.
const VolumeTypeContainer = VolumeType("containers")
VolumeTypeContainer represents a container storage volume.
const VolumeTypeCustom = VolumeType("custom")
VolumeTypeCustom represents a custom storage volume.
const VolumeTypeImage = VolumeType("images")
VolumeTypeImage represents an image storage volume.
const VolumeTypeVM = VolumeType("virtual-machines")
VolumeTypeVM represents a virtual-machine storage volume.
Variables ¶
var BaseDirectories = map[VolumeType]baseDirectory{ VolumeTypeContainer: {Paths: []string{"containers", "containers-snapshots"}, Mode: 0o711}, VolumeTypeCustom: {Paths: []string{"custom", "custom-snapshots"}, Mode: 0o700}, VolumeTypeImage: {Paths: []string{"images"}, Mode: 0o700}, VolumeTypeVM: {Paths: []string{"virtual-machines", "virtual-machines-snapshots"}, Mode: 0o700}, }
BaseDirectories maps volume types to the expected directories.
var ErrCannotBeShrunk = errors.New("Cannot be shrunk")
ErrCannotBeShrunk is the "Cannot be shrunk" error.
var ErrImageVariantNotSupported = errors.New("Image variant not supported by driver")
ErrImageVariantNotSupported indicates a driver cannot represent the requested cached image variant alongside the existing on-disk shape. Callers are expected to fall back to slow-unpacking a per-instance volume rather than mutating a shared image dataset.
var ErrInUse = errors.New("In use")
ErrInUse indicates operation cannot proceed as resource is in use.
var ErrNotSupported = errors.New("Not supported")
ErrNotSupported is the "Not supported" error.
var ErrSnapshotDoesNotMatchIncrementalSource = errors.New("Snapshot does not match incremental source")
ErrSnapshotDoesNotMatchIncrementalSource in the "Snapshot does not match incremental source" error.
var ErrUnknownDriver = errors.New("Unknown driver")
ErrUnknownDriver is the "Unknown driver" error.
Functions ¶
func AllDriverNames ¶
func AllDriverNames() []string
AllDriverNames returns a list of all storage driver names.
func CanUseOptimizedImage ¶
CanUseOptimizedImage reports whether the driver supports optimized image volumes and the instance volume's config is compatible with the pool's image-volume defaults. Both conditions must hold: if the driver doesn't cache images at all, or if the instance's config would prevent cloning from a cached image, there's no benefit in maintaining a separate image volume.
func CephBuildMount ¶
func CephBuildMount(user string, key string, fsid string, monitors Monitors, fsName string, path string, msMode string, modernMountSyntax bool) (source string, options []string)
CephBuildMount creates a mount string and option list from mount parameters.
func CephGetRBDImageName ¶
CephGetRBDImageName returns the RBD image name as it is used in ceph.
Separate the snapshot component because of the two ways LXD uses Ceph:
- The `rbd` cli utility
- Via Qemu QMP
The rbd utility requires the snapshot's name to be appended to the volume name with an '@'. QMP expects a snapshot name to be passed as a separate parameter.
Example: A custom block volume named vol1 in project default will return custom_default_vol1.block.
func CephKeyring ¶
CephKeyring gets the key for a particular Ceph cluster and client name.
func CephMSMode ¶
CephMSMode queries the cluster for the client messenger mode and maps it to the equivalent kernel ms_mode mount option. The Ceph config key ms_client_mode is a space-separated preference list (e.g. "crc secure"); the first entry is the preferred mode which maps to a kernel "prefer-*" variant.
func DefaultVMBlockFilesystemSize ¶
DefaultVMBlockFilesystemSize returns the default size of VM Block Filesystems created using the named driver.
func GetPoolMountPath ¶
GetPoolMountPath returns the mountpoint of the given pool. {LXD_DIR}/storage-pools/<pool>.
func GetSnapshotVolumeName ¶
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 PatchUpdatePowerFlexSnapshotPrefix ¶
PatchUpdatePowerFlexSnapshotPrefix patches the given snapshot volumes by adding the dedicated snapshot prefix. On the driver level we don't know if a snapshot on the storage array is an actual snapshot of a volume in LXD or a copied volume which was created by taking a snapshot (powerflex.snapshot_copy=true). Therefore this function is exported so it can be invoked from outside with the knowledge of which are the snapshots that require patching.
func RemoteDriverNames ¶
func RemoteDriverNames() []string
RemoteDriverNames returns a list of remote storage driver names.
func ResolveServerName ¶
ResolveServerName returns the given server name if it is not "none". If the server name is "none", it retrieves and returns the server's hostname.
func ShiftBtrfsRootfs ¶
ShiftBtrfsRootfs shifts the BTRFS root filesystem.
func ShiftZFSSkipper ¶
ShiftZFSSkipper indicates which files not to shift for ZFS.
func TryMount ¶
func TryMount(ctx context.Context, src string, dst string, fs string, flags uintptr, options string) error
TryMount tries mounting a filesystem multiple times. This is useful for unreliable backends. By default the mount operation will be retried until the context expires. If no deadline is configured, a default timeout of 10 seconds is used. In case the mount operation doesn't return within the defined deadline, TryMount waits and doesn't return in case the context expired before that.
func TryUnmount ¶
TryUnmount tries unmounting a filesystem multiple times. This is useful for unreliable backends.
func UnshiftBtrfsRootfs ¶
UnshiftBtrfsRootfs unshifts the BTRFS root filesystem.
func ValidVolumeName ¶
ValidVolumeName validates a volume name.
func ValidateZfsBlocksize ¶
ValidateZfsBlocksize validates blocksize property value on the pool.
func ZFSSupportsDelegation ¶
func ZFSSupportsDelegation() bool
ZFSSupportsDelegation returns true if the ZFS version on the system supports user namespace delegation.
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 Driver ¶
type Driver interface {
// Internal.
Info() Info
HasVolume(vol Volume) (bool, error)
ImageVolumeConfigMatch(vol1 Volume, vol2 Volume) bool
// Export struct details.
Name() string
SourceIdentifier() (string, error)
Config() map[string]string
Logger() logger.Logger
// Pool.
FillConfig() error
Create() error
Delete(progressReporter ioprogress.ProgressReporter) 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
ValidateSource() error
Update(changedConfig map[string]string) error
ApplyPatch(name string) error
// Buckets.
ValidateBucket(bucket Volume) error
GetBucketURL(bucketName string) *url.URL
CreateBucket(bucket Volume) error
DeleteBucket(bucket Volume) 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) (*S3Credentials, error)
UpdateBucketKey(bucket Volume, keyName string, creds S3Credentials, roleName string) (*S3Credentials, error)
DeleteBucketKey(bucket Volume, keyName string) error
// Volumes.
FillVolumeConfig(vol Volume) error
ValidateVolume(vol Volume, removeUnknownKeys bool) error
CreateVolume(vol Volume, filler *VolumeFiller, progressReporter ioprogress.ProgressReporter) error
CreateVolumeFromCopy(vol VolumeCopy, srcVol VolumeCopy, allowInconsistent bool, progressReporter ioprogress.ProgressReporter) error
EnsureImage(imgVol Volume, filler *VolumeFiller, progressReporter ioprogress.ProgressReporter) error
RefreshVolume(vol VolumeCopy, srcVol VolumeCopy, refreshSnapshots []string, allowInconsistent bool, progressReporter ioprogress.ProgressReporter) error
DeleteVolume(vol Volume, progressReporter ioprogress.ProgressReporter) error
RenameVolume(vol Volume, newName string, progressReporter ioprogress.ProgressReporter) error
UpdateVolume(vol Volume, changedConfig map[string]string) error
GetVolumeUsage(vol Volume) (int64, error)
SetVolumeQuota(vol Volume, size string, allowUnsafeResize bool, progressReporter ioprogress.ProgressReporter) error
GetVolumeDiskPath(vol Volume) (string, error)
ListVolumes() ([]Volume, error)
// MountVolume mounts a storage volume (if not mounted) and increments reference counter.
MountVolume(vol Volume, progressReporter ioprogress.ProgressReporter) error
// MountVolumeSnapshot mounts a storage volume snapshot as readonly.
MountVolumeSnapshot(snapVol Volume, progressReporter ioprogress.ProgressReporter) error
// CanDelegateVolume checks whether the volume can be delegated.
CanDelegateVolume(vol Volume) bool
// DelegateVolume allows for the volume to be managed by the instance.
DelegateVolume(vol Volume, pid int) error
// UnmountVolume unmounts a storage volume, returns true if unmounted, false if was not
// mounted.
UnmountVolume(vol Volume, keepBlockDev bool, progressReporter ioprogress.ProgressReporter) (bool, error)
// UnmountVolume unmounts a storage volume snapshot, returns true if unmounted, false if was
// not mounted.
UnmountVolumeSnapshot(snapVol Volume, progressReporter ioprogress.ProgressReporter) (bool, error)
CreateVolumeSnapshot(snapVol Volume, progressReporter ioprogress.ProgressReporter) error
DeleteVolumeSnapshot(snapVol Volume, progressReporter ioprogress.ProgressReporter) error
RenameVolumeSnapshot(snapVol Volume, newSnapshotName string, progressReporter ioprogress.ProgressReporter) error
VolumeSnapshots(vol Volume) ([]string, error)
CheckVolumeSnapshots(vol Volume, snapVols []Volume) error
RestoreVolume(vol Volume, snapVol Volume, progressReporter ioprogress.ProgressReporter) error
// Migration.
MigrationTypes(contentType ContentType, refresh bool, copySnapshots bool) []migration.Type
MigrateVolume(vol VolumeCopy, conn io.ReadWriteCloser, volSrcArgs *migration.VolumeSourceArgs, progressReporter ioprogress.ProgressReporter) error
CreateVolumeFromMigration(vol VolumeCopy, conn io.ReadWriteCloser, volTargetArgs migration.VolumeTargetArgs, preFiller *VolumeFiller, progressReporter ioprogress.ProgressReporter) error
// Backup.
BackupVolume(vol VolumeCopy, projectName string, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots []string, progressReporter ioprogress.ProgressReporter) error
CreateVolumeFromBackup(vol VolumeCopy, srcBackup backup.Info, srcData io.ReadSeeker, progressReporter ioprogress.ProgressReporter) (VolumePostHook, revert.Hook, error)
// contains filtered or unexported methods
}
Driver represents a low-level storage driver.
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 of the storage driver.
Name string
// Version of the storage driver.
Version string
// Supported volume types.
VolumeTypes []VolumeType
// Default block volume size.
DefaultBlockSize string
// Default volume size for VM block filesystems.
DefaultVMBlockFilesystemSize string
// Buckets supported.
Buckets bool
// Whether the driver uses a remote backing store.
Remote bool
// Whether volumes can be used on multiple nodes concurrently.
VolumeMultiNode bool
// Whether driver stores images as separate volume.
OptimizedImages bool
// Whether driver supports optimized volume backups.
OptimizedBackups bool
// Whether driver generates an optimised backup header file in backup.
OptimizedBackupHeader bool
// Whether driver preserves inodes when volumes are moved hosts.
PreservesInodes bool
// Whether driver uses block devices as backing store.
BlockBacking bool
// Whether instance should be frozen during snapshot if running.
RunningCopyFreeze bool
// Whether the driver supports direct I/O.
DirectIO bool
// Whether the driver supports io_uring.
IOUring bool
// Whether the pool directory itself is a mount.
MountedRoot bool
// Whether the volume should have parent UUID populated before any action.
PopulateParentVolumeUUID bool
// Whether the volume name is translated using its UUID.
// If set to true, any volume returned by the driver's ListVolumes function
// has to be handled with care because the name of the volume on storage does not
// relate to the volume's actual name inside LXD's database.
// Drivers usually take the volume's UUID and translate it to a base64 encoded string.
UUIDVolumeNames bool
}
Info represents information about a storage driver.
func SupportedDrivers ¶
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 Monitors ¶
Monitors holds a list of Ceph monitor addresses based on which protocol they expect.
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 {
// Regular list of rules valid for all pools.
PoolRules func() map[string]func(string) error
// List of rules valid for local pools.
LocalPoolRules func() map[string]func(string) error
// List of rules valid for pool volumes.
VolumeRules func(vol Volume) map[string]func(string) error
}
Validators contains functions used for validating a driver'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) ConfigBlockFilesystem ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
ExpandedConfig returns either the value of the volume's config key or the pool's config "volume.{key}" value.
func (*Volume) GetParent ¶
GetParent returns a parent volume that has volatile.uuid set to the current's volume parent UUID.
func (Volume) IsBlockBacked ¶
IsBlockBacked indicates whether storage device is block backed.
func (Volume) IsCustomBlock ¶
IsCustomBlock returns true if volume is a custom block volume.
func (Volume) IsSnapshot ¶
IsSnapshot indicates if volume is a snapshot.
func (Volume) IsVMBlock ¶
IsVMBlock returns true if volume is a block volume for virtual machines or associated images.
func (Volume) MountInUse ¶
MountInUse returns whether the volume has a mount ref counter >0.
func (Volume) MountLock ¶
func (v Volume) MountLock() (locking.UnlockFunc, error)
MountLock attempts to lock the mount lock for the volume and returns the UnlockFunc.
func (Volume) MountRefCountDecrement ¶
MountRefCountDecrement decrements the mount ref counter for the volume and returns the new value.
func (Volume) MountRefCountIncrement ¶
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, progressReporter ioprogress.ProgressReporter) error, progressReporter ioprogress.ProgressReporter) 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) NewSnapshot ¶
NewSnapshot instantiates a new Volume struct representing a snapshot of the parent volume. This creates a logical representation of the snapshot with the cloned config from its parent volume. The parent's UUID is not included. Load the snapshot from the database instead if you want to access its own UUID.
func (Volume) NewVMBlockFilesystemVolume ¶
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) SetConfigSize ¶
SetConfigSize sets the size config property on the Volume (does not resize volume).
func (Volume) SetConfigStateSize ¶
SetConfigStateSize sets the size.state config property on the Volume (does not resize volume).
func (*Volume) SetHasSource ¶
SetHasSource indicates whether the Volume is created from a source.
func (*Volume) SetMountCustomPath ¶
SetMountCustomPath sets a custom path for mounting the volume.
func (*Volume) SetMountFilesystemProbe ¶
SetMountFilesystemProbe enables or disables the probing mode when mounting the filesystem volume.
func (*Volume) SetParentUUID ¶
SetParentUUID sets the parent volume's UUID for snapshots.
func (Volume) SetQuota ¶
func (v Volume) SetQuota(size string, allowUnsafeResize bool, progressReporter ioprogress.ProgressReporter) error
SetQuota calls SetVolumeQuota on the Volume's driver.
func (Volume) Snapshots ¶
func (v Volume) Snapshots(progressReporter ioprogress.ProgressReporter) ([]Volume, error)
Snapshots returns a list of snapshots for the volume (in no particular order).
func (Volume) UnmountTask ¶
func (v Volume) UnmountTask(task func(progressReporter ioprogress.ProgressReporter) error, keepBlockDev bool, progressReporter ioprogress.ProgressReporter) 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 VolumeCopy ¶
VolumeCopy represents a volume and its snapshots for copy and refresh operations.
func NewVolumeCopy ¶
func NewVolumeCopy(vol Volume, snapshots ...Volume) VolumeCopy
NewVolumeCopy returns a container for copying a volume and its snapshots.
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 ¶
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.
Source Files
¶
- bucket.go
- driver_alletra.go
- driver_alletra_volumes.go
- driver_btrfs.go
- driver_btrfs_utils.go
- driver_btrfs_volumes.go
- driver_ceph.go
- driver_ceph_utils.go
- driver_ceph_volumes.go
- driver_cephfs.go
- driver_cephfs_utils.go
- driver_cephfs_volumes.go
- driver_cephobject.go
- driver_cephobject_buckets.go
- driver_cephobject_utils.go
- driver_common.go
- driver_dir.go
- driver_dir_utils.go
- driver_dir_volumes.go
- driver_lvm.go
- driver_lvm_patches.go
- driver_lvm_utils.go
- driver_lvm_volumes.go
- driver_mock.go
- driver_powerflex.go
- driver_powerflex_utils.go
- driver_powerflex_volumes.go
- driver_powerstore.go
- driver_powerstore_volumes.go
- driver_pure.go
- driver_pure_util.go
- driver_pure_volumes.go
- driver_types.go
- driver_zfs.go
- driver_zfs_patches.go
- driver_zfs_utils.go
- driver_zfs_volumes.go
- errors.go
- generic_vfs.go
- interface.go
- load.go
- patches.go
- utils.go
- utils_ceph.go
- utils_image.go
- volume.go