lxd: github.com/lxc/lxd/lxd/storage Index | Files | Directories

package storage

import "github.com/lxc/lxd/lxd/storage"

Index

Package Files

backend_lxd.go backend_lxd_patches.go backend_mock.go cgo.go errors.go load.go pool_interface.go storage.go utils.go

Variables

var ErrBackupSnapshotsMismatch = fmt.Errorf("Backup snapshots mismatch")

ErrBackupSnapshotsMismatch is the "Backup snapshots mismatch" error.

var ErrNilValue = fmt.Errorf("Nil value provided")

ErrNilValue is the "Nil value provided" error

var ErrNotImplemented = fmt.Errorf("Not implemented")

ErrNotImplemented is the "Not implemented" error

var ErrRunningQuotaResizeNotSupported = fmt.Errorf("Running quota resize not supported")

ErrRunningQuotaResizeNotSupported is the "Running quota resize not supported" error.

var StorageVolumeConfigKeys = map[string]func(value string) ([]string, error){
    "block.filesystem": func(value string) ([]string, error) {
        err := shared.IsOneOf(value, []string{"btrfs", "ext4", "xfs"})
        if err != nil {
            return nil, err
        }

        return []string{"ceph", "lvm"}, nil
    },
    "block.mount_options": func(value string) ([]string, error) {
        return []string{"ceph", "lvm"}, shared.IsAny(value)
    },
    "security.shifted": func(value string) ([]string, error) {
        return SupportedPoolTypes, shared.IsBool(value)
    },
    "security.unmapped": func(value string) ([]string, error) {
        return SupportedPoolTypes, shared.IsBool(value)
    },
    "size": func(value string) ([]string, error) {
        if value == "" {
            return SupportedPoolTypes, nil
        }

        _, err := units.ParseByteSizeString(value)
        if err != nil {
            return nil, err
        }

        return SupportedPoolTypes, nil
    },
    "volatile.idmap.last": func(value string) ([]string, error) {
        return SupportedPoolTypes, shared.IsAny(value)
    },
    "volatile.idmap.next": func(value string) ([]string, error) {
        return SupportedPoolTypes, shared.IsAny(value)
    },
    "zfs.remove_snapshots": func(value string) ([]string, error) {
        err := shared.IsBool(value)
        if err != nil {
            return nil, err
        }

        return []string{"zfs"}, nil
    },
    "zfs.use_refquota": func(value string) ([]string, error) {
        err := shared.IsBool(value)
        if err != nil {
            return nil, err
        }

        return []string{"zfs"}, nil
    },
}

StorageVolumeConfigKeys config validation for btrfs, ceph, cephfs, dir, lvm, zfs types. Deprecated: these are being moved to the per-storage-driver implementations.

var SupportedPoolTypes = []string{"btrfs", "ceph", "cephfs", "dir", "lvm", "zfs"}

SupportedPoolTypes the types of pools supported. Deprecated: this is being replaced with drivers.SupportedDrivers()

func ConfigDiff Uses

func ConfigDiff(oldConfig map[string]string, newConfig map[string]string) ([]string, bool)

ConfigDiff returns a diff of the provided configs. Additionally, it returns whether or not only user properties have been changed.

func CreateContainerMountpoint Uses

func CreateContainerMountpoint(mountPoint string, mountPointSymlink string, privileged bool) error

CreateContainerMountpoint creates the provided container mountpoint and symlink.

func CreateSnapshotMountpoint Uses

func CreateSnapshotMountpoint(snapshotMountpoint string, snapshotsSymlinkTarget string, snapshotsSymlink string) error

CreateSnapshotMountpoint creates the provided container snapshot mountpoint and symlink.

func FallbackMigrationType Uses

func FallbackMigrationType(contentType drivers.ContentType) migration.MigrationFSType

FallbackMigrationType returns the fallback migration transport to use based on volume content type.

func GetContainerMountPoint Uses

func GetContainerMountPoint(projectName string, poolName string, containerName string) string

GetContainerMountPoint returns the mountpoint of the given container. ${LXD_DIR}/storage-pools/<pool>/containers/[<project_name>_]<container_name>

func GetImageMountPoint Uses

func GetImageMountPoint(poolName string, fingerprint string) string

GetImageMountPoint returns the mountpoint of the given image. ${LXD_DIR}/storage-pools/<pool>/images/<fingerprint>

func GetSnapshotMountPoint Uses

func GetSnapshotMountPoint(projectName, poolName string, snapshotName string) string

GetSnapshotMountPoint returns the mountpoint of the given container snapshot. ${LXD_DIR}/storage-pools/<pool>/containers-snapshots/<snapshot_name>

func GetStoragePoolMountPoint Uses

func GetStoragePoolMountPoint(poolName string) string

GetStoragePoolMountPoint returns the mountpoint of the given pool. {LXD_DIR}/storage-pools/<pool> Deprecated, use GetPoolMountPath in storage/drivers package.

func GetStoragePoolVolumeSnapshotMountPoint Uses

func GetStoragePoolVolumeSnapshotMountPoint(poolName string, snapshotName string) string

GetStoragePoolVolumeSnapshotMountPoint returns the mountpoint of the given pool volume snapshot. ${LXD_DIR}/storage-pools/<pool>/custom-snapshots/<custom volume name>/<snapshot name>

func ImageUnpack Uses

func ImageUnpack(imageFile, destPath, destBlockFile string, blockBackend, runningInUserns bool, tracker *ioprogress.ProgressTracker) error

ImageUnpack unpacks a filesystem image into the destination path. There are several formats that images can come in: Container Format A: Separate metadata tarball and root squashfs file.

- Unpack metadata tarball into mountPath.
- Unpack root squashfs file into mountPath/rootfs.

Container Format B: Combined tarball containing metadata files and root squashfs.

- Unpack combined tarball into mountPath.

VM Format A: Separate metadata tarball and root qcow2 file.

- Unpack metadata tarball into mountPath.
- Check rootBlockPath is a file and convert qcow2 file into raw format in rootBlockPath.

func InstanceContentType Uses

func InstanceContentType(inst instance.Instance) drivers.ContentType

InstanceContentType returns the instance's content type.

func InstanceImportingFilePath Uses

func InstanceImportingFilePath(instanceType instancetype.Type, poolName, projectName, instanceName string) string

InstanceImportingFilePath returns the file path used to indicate an instance import is in progress. This marker file is created when using `lxd import` to import an instance that exists on the storage device but does not exist in the LXD database. The presence of this file causes the instance not to be removed from the storage device if the import should fail for some reason.

func InstancePath Uses

func InstancePath(instanceType instancetype.Type, projectName, instanceName string, isSnapshot bool) string

InstancePath returns the directory of an instance or snapshot.

func InstanceTypeToVolumeType Uses

func InstanceTypeToVolumeType(instType instancetype.Type) (drivers.VolumeType, error)

InstanceTypeToVolumeType converts instance type to volume type.

func RenderSnapshotUsage Uses

func RenderSnapshotUsage(s *state.State, snapInst instance.Instance) func(response interface{}) error

RenderSnapshotUsage can be used as an optional argument to Instance.Render() to return snapshot usage. As this is a relatively expensive operation it is provided as an optional feature rather than on by default.

func ValidName Uses

func ValidName(value string) error

ValidName validates the provided name, and returns an error if it's not a valid storage name.

func VolumeDBCreate Uses

func VolumeDBCreate(s *state.State, project, poolName, volumeName, volumeDescription, volumeTypeName string, snapshot bool, volumeConfig map[string]string, expiryDate time.Time) error

VolumeDBCreate creates a volume in the database.

func VolumeFillDefault Uses

func VolumeFillDefault(name string, config map[string]string, parentPool *api.StoragePool) error

VolumeFillDefault fills default settings into a volume config.

func VolumePropertiesTranslate Uses

func VolumePropertiesTranslate(targetConfig map[string]string, targetParentPoolDriver string) (map[string]string, error)

VolumePropertiesTranslate validates the supplied volume config and removes any keys that are not suitable for the volume's driver type.

func VolumeSnapshotsGet Uses

func VolumeSnapshotsGet(s *state.State, projectName string, pool string, volume string, volType int) ([]db.StorageVolumeArgs, error)

VolumeSnapshotsGet returns a list of snapshots of the form <volume>/<snapshot-name>.

func VolumeTypeNameToType Uses

func VolumeTypeNameToType(volumeTypeName string) (int, error)

VolumeTypeNameToType converts a volume type string to internal code.

func VolumeTypeToDBType Uses

func VolumeTypeToDBType(volType drivers.VolumeType) (int, error)

VolumeTypeToDBType converts volume type to internal code.

func VolumeUsedByDaemon Uses

func VolumeUsedByDaemon(s *state.State, poolName string, volumeName string) (bool, error)

VolumeUsedByDaemon indicates whether the volume is used by daemon storage.

func VolumeUsedByInstancesGet Uses

func VolumeUsedByInstancesGet(s *state.State, projectName string, poolName string, volumeName string) ([]string, error)

VolumeUsedByInstancesGet gets a list of instance names using a volume.

func VolumeUsedByRunningInstancesWithProfilesGet Uses

func VolumeUsedByRunningInstancesWithProfilesGet(s *state.State, projectName string, poolName string, volumeName string, volumeTypeName string, runningOnly bool) ([]string, error)

VolumeUsedByRunningInstancesWithProfilesGet gets list of running instances using a volume.

func VolumeValidateConfig Uses

func VolumeValidateConfig(s *state.State, name string, config map[string]string, parentPool *api.StoragePool) error

VolumeValidateConfig validations volume config. Deprecated.

type Pool Uses

type Pool interface {
    // Pool.
    ID() int64
    Name() string
    Driver() drivers.Driver

    GetResources() (*api.ResourcesStoragePool, error)
    Delete(localOnly bool, op *operations.Operation) error
    Update(driverOnly bool, newDesc string, newConfig map[string]string, op *operations.Operation) error

    Mount() (bool, error)
    Unmount() (bool, error)

    ApplyPatch(name string) error

    // Instances.
    CreateInstance(inst instance.Instance, op *operations.Operation) error
    CreateInstanceFromBackup(srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) (func(instance.Instance) error, func(), error)
    CreateInstanceFromCopy(inst instance.Instance, src instance.Instance, snapshots bool, op *operations.Operation) error
    CreateInstanceFromImage(inst instance.Instance, fingerprint string, op *operations.Operation) error
    CreateInstanceFromMigration(inst instance.Instance, conn io.ReadWriteCloser, args migration.VolumeTargetArgs, op *operations.Operation) error
    RenameInstance(inst instance.Instance, newName string, op *operations.Operation) error
    DeleteInstance(inst instance.Instance, op *operations.Operation) error
    UpdateInstance(inst instance.Instance, newDesc string, newConfig map[string]string, op *operations.Operation) error
    UpdateInstanceBackupFile(inst instance.Instance, op *operations.Operation) error
    CheckInstanceBackupFileSnapshots(backupConf *backup.InstanceConfig, projectName string, deleteMissing bool, op *operations.Operation) ([]*api.InstanceSnapshot, error)

    MigrateInstance(inst instance.Instance, conn io.ReadWriteCloser, args *migration.VolumeSourceArgs, op *operations.Operation) error
    RefreshInstance(inst instance.Instance, src instance.Instance, srcSnapshots []instance.Instance, op *operations.Operation) error
    BackupInstance(inst instance.Instance, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots bool, op *operations.Operation) error

    GetInstanceUsage(inst instance.Instance) (int64, error)
    SetInstanceQuota(inst instance.Instance, size string, op *operations.Operation) error

    MountInstance(inst instance.Instance, op *operations.Operation) (bool, error)
    UnmountInstance(inst instance.Instance, op *operations.Operation) (bool, error)
    GetInstanceDisk(inst instance.Instance) (string, error)

    // Instance snapshots.
    CreateInstanceSnapshot(inst instance.Instance, src instance.Instance, op *operations.Operation) error
    RenameInstanceSnapshot(inst instance.Instance, newName string, op *operations.Operation) error
    DeleteInstanceSnapshot(inst instance.Instance, op *operations.Operation) error
    RestoreInstanceSnapshot(inst instance.Instance, src instance.Instance, op *operations.Operation) error
    MountInstanceSnapshot(inst instance.Instance, op *operations.Operation) (bool, error)
    UnmountInstanceSnapshot(inst instance.Instance, op *operations.Operation) (bool, error)
    UpdateInstanceSnapshot(inst instance.Instance, newDesc string, newConfig map[string]string, op *operations.Operation) error

    // Images.
    EnsureImage(fingerprint string, op *operations.Operation) error
    DeleteImage(fingerprint string, op *operations.Operation) error
    UpdateImage(fingerprint string, newDesc string, newConfig map[string]string, op *operations.Operation) error

    // Custom volumes.
    CreateCustomVolume(projectName string, volName string, desc string, config map[string]string, op *operations.Operation) error
    CreateCustomVolumeFromCopy(projectName string, volName, desc string, config map[string]string, srcPoolName, srcVolName string, srcVolOnly bool, op *operations.Operation) error
    UpdateCustomVolume(projectName string, volName string, newDesc string, newConfig map[string]string, op *operations.Operation) error
    RenameCustomVolume(projectName string, volName string, newVolName string, op *operations.Operation) error
    DeleteCustomVolume(projectName string, volName string, op *operations.Operation) error
    GetCustomVolumeUsage(projectName string, volName string) (int64, error)
    MountCustomVolume(projectName string, volName string, op *operations.Operation) (bool, error)
    UnmountCustomVolume(projectName string, volName string, op *operations.Operation) (bool, error)

    // Custom volume snapshots.
    CreateCustomVolumeSnapshot(projectName string, volName string, newSnapshotName string, newExpiryDate time.Time, op *operations.Operation) error
    RenameCustomVolumeSnapshot(projectName string, volName string, newSnapshotName string, op *operations.Operation) error
    DeleteCustomVolumeSnapshot(projectName string, volName string, op *operations.Operation) error
    UpdateCustomVolumeSnapshot(projectName string, volName string, newDesc string, newConfig map[string]string, newExpiryDate time.Time, op *operations.Operation) error
    RestoreCustomVolume(projectName string, volName string, snapshotName string, op *operations.Operation) error

    // Custom volume migration.
    MigrationTypes(contentType drivers.ContentType, refresh bool) []migration.Type
    CreateCustomVolumeFromMigration(projectName string, conn io.ReadWriteCloser, args migration.VolumeTargetArgs, op *operations.Operation) error
    MigrateCustomVolume(projectName string, conn io.ReadWriteCloser, args *migration.VolumeSourceArgs, op *operations.Operation) error
}

Pool represents a LXD storage pool.

func CreatePool Uses

func CreatePool(state *state.State, poolID int64, dbPool *api.StoragePoolsPost, localOnly bool, op *operations.Operation) (Pool, error)

CreatePool creates a new storage pool on disk and returns a Pool interface. If the pool's driver is not recognised then drivers.ErrUnknownDriver is returned.

func GetPoolByInstance Uses

func GetPoolByInstance(s *state.State, inst instance.Instance) (Pool, error)

GetPoolByInstance retrieves the pool from the database using the instance's pool. If the pool's driver is not recognised then drivers.ErrUnknownDriver is returned. If the pool's driver does not support the instance's type then drivers.ErrNotImplemented is returned.

func GetPoolByName Uses

func GetPoolByName(state *state.State, name string) (Pool, error)

GetPoolByName retrieves the pool from the database by its name and returns a Pool interface. If the pool's driver is not recognised then drivers.ErrUnknownDriver is returned.

Directories

PathSynopsis
drivers
locking
memorypipe
quota

Package storage imports 34 packages (graph) and is imported by 10 packages. Updated 2020-04-06. Refresh now. Tools for package owners.