Documentation ¶
Index ¶
- Variables
- func ConfigDiff(oldConfig map[string]string, newConfig map[string]string) ([]string, bool)
- func CreateContainerMountpoint(mountPoint string, mountPointSymlink string, privileged bool) error
- func CreateSnapshotMountpoint(snapshotMountpoint string, snapshotsSymlinkTarget string, ...) error
- func FallbackMigrationType(contentType drivers.ContentType) migration.MigrationFSType
- func GetContainerMountPoint(projectName string, poolName string, containerName string) string
- func GetImageMountPoint(poolName string, fingerprint string) string
- func GetSnapshotMountPoint(projectName, poolName string, snapshotName string) string
- func GetStoragePoolMountPoint(poolName string) string
- func GetStoragePoolVolumeSnapshotMountPoint(poolName string, snapshotName string) string
- func ImageUnpack(imageFile string, vol drivers.Volume, destBlockFile string, ...) (int64, error)
- func InstanceContentType(inst instance.Instance) drivers.ContentType
- func InstanceDiskBlockSize(pool Pool, inst instance.Instance, op *operations.Operation) (int64, error)
- func InstanceImportingFilePath(instanceType instancetype.Type, poolName, projectName, instanceName string) string
- func InstancePath(instanceType instancetype.Type, projectName, instanceName string, ...) string
- func InstanceTypeToVolumeType(instType instancetype.Type) (drivers.VolumeType, error)
- func InstanceUnmount(pool Pool, inst instance.Instance, op *operations.Operation) (bool, error)
- func RenderSnapshotUsage(s *state.State, snapInst instance.Instance) func(response interface{}) error
- func ValidName(value string) error
- func VolumeContentTypeNameToContentType(contentTypeName string) (int, error)
- func VolumeContentTypeToDBContentType(contentType drivers.ContentType) (int, error)
- func VolumeDBContentTypeToContentType(volDBType int) (drivers.ContentType, error)
- func VolumeDBCreate(s *state.State, pool Pool, projectName string, volumeName string, ...) error
- func VolumeDBTypeToType(volDBType int) (drivers.VolumeType, error)
- func VolumeDBTypeToTypeName(volumeDBType int) (string, error)
- func VolumePropertiesTranslate(targetConfig map[string]string, targetParentPoolDriver string) (map[string]string, error)
- func VolumeSnapshotsGet(s *state.State, projectName string, pool string, volume string, volType int) ([]db.StorageVolumeArgs, error)
- func VolumeTypeNameToDBType(volumeTypeName string) (int, error)
- func VolumeTypeToDBType(volType drivers.VolumeType) (int, error)
- func VolumeUsedByDaemon(s *state.State, poolName string, volumeName string) (bool, error)
- func VolumeUsedByExclusiveRemoteInstancesWithProfiles(s *state.State, poolName string, projectName string, vol *api.StorageVolume) (*db.Instance, error)
- func VolumeUsedByInstanceDevices(s *state.State, poolName string, projectName string, vol *api.StorageVolume, ...) error
- func VolumeUsedByProfileDevices(s *state.State, poolName string, projectName string, vol *api.StorageVolume, ...) error
- type MountInfo
- type Pool
Constants ¶
This section is empty.
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 StorageVolumeConfigKeys = map[string]func(value string) ([]string, error){ "block.filesystem": func(value string) ([]string, error) { err := validate.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"}, validate.IsAny(value) }, "security.shifted": func(value string) ([]string, error) { return SupportedPoolTypes, validate.Optional(validate.IsBool)(value) }, "security.unmapped": func(value string) ([]string, error) { return SupportedPoolTypes, validate.Optional(validate.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, validate.IsAny(value) }, "volatile.idmap.next": func(value string) ([]string, error) { return SupportedPoolTypes, validate.IsAny(value) }, "zfs.remove_snapshots": func(value string) ([]string, error) { err := validate.Optional(validate.IsBool)(value) if err != nil { return nil, err } return []string{"zfs"}, nil }, "zfs.use_refquota": func(value string) ([]string, error) { err := validate.Optional(validate.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()
Functions ¶
func ConfigDiff ¶
ConfigDiff returns a diff of the provided configs. Additionally, it returns whether or not only user properties have been changed.
func CreateContainerMountpoint ¶
CreateContainerMountpoint creates the provided container mountpoint and symlink.
func CreateSnapshotMountpoint ¶
func CreateSnapshotMountpoint(snapshotMountpoint string, snapshotsSymlinkTarget string, snapshotsSymlink string) error
CreateSnapshotMountpoint creates the provided container snapshot mountpoint and symlink.
func FallbackMigrationType ¶
func FallbackMigrationType(contentType drivers.ContentType) migration.MigrationFSType
FallbackMigrationType returns the fallback migration transport to use based on volume content type.
func GetContainerMountPoint ¶
GetContainerMountPoint returns the mountpoint of the given container. ${LXD_DIR}/storage-pools/<pool>/containers/[<project_name>_]<container_name>
func GetImageMountPoint ¶
GetImageMountPoint returns the mountpoint of the given image. ${LXD_DIR}/storage-pools/<pool>/images/<fingerprint>
func GetSnapshotMountPoint ¶
GetSnapshotMountPoint returns the mountpoint of the given container snapshot. ${LXD_DIR}/storage-pools/<pool>/containers-snapshots/<snapshot_name>
func GetStoragePoolMountPoint ¶
GetStoragePoolMountPoint returns the mountpoint of the given pool. {LXD_DIR}/storage-pools/<pool> Deprecated, use GetPoolMountPath in storage/drivers package.
func GetStoragePoolVolumeSnapshotMountPoint ¶
GetStoragePoolVolumeSnapshotMountPoint returns the mountpoint of the given pool volume snapshot. ${LXD_DIR}/storage-pools/<pool>/custom-snapshots/<custom volume name>/<snapshot name>
func ImageUnpack ¶
func ImageUnpack(imageFile string, vol drivers.Volume, destBlockFile string, blockBackend, runningInUserns bool, tracker *ioprogress.ProgressTracker) (int64, 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 ¶
func InstanceContentType(inst instance.Instance) drivers.ContentType
InstanceContentType returns the instance's content type.
func InstanceDiskBlockSize ¶
func InstanceDiskBlockSize(pool Pool, inst instance.Instance, op *operations.Operation) (int64, error)
InstanceDiskBlockSize returns the block device size for the instance's disk. This will mount the instance if not already mounted and will unmount at the end if needed.
func InstanceImportingFilePath ¶
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 ¶
func InstancePath(instanceType instancetype.Type, projectName, instanceName string, isSnapshot bool) string
InstancePath returns the directory of an instance or snapshot.
func InstanceTypeToVolumeType ¶
func InstanceTypeToVolumeType(instType instancetype.Type) (drivers.VolumeType, error)
InstanceTypeToVolumeType converts instance type to storage driver volume type.
func InstanceUnmount ¶
InstanceUnmount unmounts an instance's storage volume (if not in use). Returns if we unmounted the volume.
func RenderSnapshotUsage ¶
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 ¶
ValidName validates the provided name, and returns an error if it's not a valid storage name.
func VolumeContentTypeNameToContentType ¶
VolumeContentTypeNameToContentType converts volume content type string internal code.
func VolumeContentTypeToDBContentType ¶
func VolumeContentTypeToDBContentType(contentType drivers.ContentType) (int, error)
VolumeContentTypeToDBContentType converts volume type to internal code.
func VolumeDBContentTypeToContentType ¶
func VolumeDBContentTypeToContentType(volDBType int) (drivers.ContentType, error)
VolumeDBContentTypeToContentType converts internal content type DB code to driver representation.
func VolumeDBCreate ¶
func VolumeDBCreate(s *state.State, pool Pool, projectName string, volumeName string, volumeDescription string, volumeType drivers.VolumeType, snapshot bool, volumeConfig map[string]string, expiryDate time.Time, contentType drivers.ContentType) error
VolumeDBCreate creates a volume in the database.
func VolumeDBTypeToType ¶
func VolumeDBTypeToType(volDBType int) (drivers.VolumeType, error)
VolumeDBTypeToType converts internal volume type DB code to storage driver volume type.
func VolumeDBTypeToTypeName ¶
VolumeDBTypeToTypeName converts an internal volume DB type code string to a volume type string.
func VolumePropertiesTranslate ¶
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 ¶
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 VolumeTypeNameToDBType ¶
VolumeTypeNameToDBType converts a volume type string to internal volume type DB code.
func VolumeTypeToDBType ¶
func VolumeTypeToDBType(volType drivers.VolumeType) (int, error)
VolumeTypeToDBType converts volume type to internal volume type DB code.
func VolumeUsedByDaemon ¶
VolumeUsedByDaemon indicates whether the volume is used by daemon storage.
func VolumeUsedByExclusiveRemoteInstancesWithProfiles ¶
func VolumeUsedByExclusiveRemoteInstancesWithProfiles(s *state.State, poolName string, projectName string, vol *api.StorageVolume) (*db.Instance, error)
VolumeUsedByExclusiveRemoteInstancesWithProfiles checks if custom volume is exclusively attached to a remote instance. Returns the remote instance that has the volume exclusively attached. Returns nil if volume available.
func VolumeUsedByInstanceDevices ¶
func VolumeUsedByInstanceDevices(s *state.State, poolName string, projectName string, vol *api.StorageVolume, expandDevices bool, instanceFunc func(inst db.Instance, project api.Project, profiles []api.Profile, usedByDevices []string) error) error
VolumeUsedByInstanceDevices finds instances using a volume (either directly or via their expanded profiles if expandDevices is true) and passes them to instanceFunc for evaluation. If instanceFunc returns an error then it is returned immediately. The instanceFunc is executed during a DB transaction, so DB queries are not permitted. The instanceFunc is provided with a instance config, project config, instance's profiles and a list of device names that are using the volume.
func VolumeUsedByProfileDevices ¶
func VolumeUsedByProfileDevices(s *state.State, poolName string, projectName string, vol *api.StorageVolume, profileFunc func(profile db.Profile, project api.Project, usedByDevices []string) error) error
VolumeUsedByProfileDevices finds profiles using a volume and passes them to profileFunc for evaluation. The profileFunc is provided with a profile config, project config and a list of device names that are using the volume.
Types ¶
type MountInfo ¶
type MountInfo struct {
DiskPath string // The location of the block disk (if supported).
}
MountInfo represents info about the result of a mount operation.
func InstanceMount ¶
InstanceMount mounts an instance's storage volume (if not already mounted). Please call InstanceUnmount when finished.
type Pool ¶
type Pool interface { // Pool. ID() int64 Name() string Driver() drivers.Driver Description() string Status() string LocalStatus() string GetResources() (*api.ResourcesStoragePool, error) IsUsed() (bool, error) Delete(clientType request.ClientType, op *operations.Operation) error Update(clientType request.ClientType, newDesc string, newConfig map[string]string, op *operations.Operation) error Create(clientType request.ClientType, op *operations.Operation) error Mount() (bool, error) Unmount() (bool, error) ApplyPatch(name string) error // Instances. FillInstanceConfig(inst instance.Instance, config map[string]string) error 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.Config, 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, vmStateSize string, op *operations.Operation) error MountInstance(inst instance.Instance, op *operations.Operation) (*MountInfo, error) UnmountInstance(inst instance.Instance, op *operations.Operation) (bool, 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) (*MountInfo, 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, contentType drivers.ContentType, 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 GetCustomVolumeDisk(projectName string, volName string) (string, error) GetCustomVolumeUsage(projectName string, volName string) (int64, error) MountCustomVolume(projectName string, volName string, op *operations.Operation) 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 // Custom volume backups. BackupCustomVolume(projectName string, volName string, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots bool, op *operations.Operation) error CreateCustomVolumeFromBackup(srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) error }
Pool represents a LXD storage pool.
func CreatePool ¶
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. Deprecated, used only by patches.
func GetPoolByInstance ¶
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.