Documentation
¶
Overview ¶
Package storagecommon provides common storage-related services for API server facades.
Index ¶
- func BlockDeviceInfoToState(in params.BlockDevice) state.BlockDeviceInfo
- func ClassifyDetachedStorage(stVolume VolumeAccess, stFile FilesystemAccess, ...) (destroyed, detached []params.Entity, _ error)
- func FilesystemAttachmentFromState(v state.FilesystemAttachment) (params.FilesystemAttachment, error)
- func FilesystemAttachmentInfoFromState(info state.FilesystemAttachmentInfo) params.FilesystemAttachmentInfo
- func FilesystemAttachmentToState(in params.FilesystemAttachment) (names.MachineTag, names.FilesystemTag, state.FilesystemAttachmentInfo, error)
- func FilesystemDetails(ctx context.Context, sb DetailsBackend, blockDeviceGetter BlockDeviceGetter, ...) (*params.FilesystemDetails, error)
- func FilesystemFromState(f state.Filesystem) (params.Filesystem, error)
- func FilesystemInfoFromState(info state.FilesystemInfo) params.FilesystemInfo
- func FilesystemParams(ctx context.Context, f state.Filesystem, storageInstance state.StorageInstance, ...) (params.FilesystemParams, error)
- func FilesystemToState(v params.Filesystem) (names.FilesystemTag, state.FilesystemInfo, error)
- func MatchingFilesystemBlockDevice(blockDevices []blockdevice.BlockDevice, volumeInfo state.VolumeInfo, ...) (*blockdevice.BlockDevice, bool)
- func MatchingVolumeBlockDevice(blockDevices []blockdevice.BlockDevice, volumeInfo state.VolumeInfo, ...) (*blockdevice.BlockDevice, bool)
- func MaybeAssignedStorageInstance(getTag func() (names.StorageTag, error), ...) (state.StorageInstance, error)
- func ParseFilesystemAttachmentIds(stringIds []string) ([]params.MachineStorageId, error)
- func ParseVolumeAttachmentIds(stringIds []string) ([]params.MachineStorageId, error)
- func StorageAttachmentInfo(ctx context.Context, st StorageAccess, stVolume VolumeAccess, ...) (*storage.StorageAttachmentInfo, error)
- func StorageDetails(ctx context.Context, sb DetailsBackend, blockDeviceGetter BlockDeviceGetter, ...) (*params.StorageDetails, error)
- func StoragePoolConfig(ctx context.Context, name string, storagePoolGetter StoragePoolGetter, ...) (storage.ProviderType, *storage.Config, error)
- func StorageTags(storageInstance state.StorageInstance, modelUUID, controllerUUID string, ...) (map[string]string, error)
- func UnitStorage(st StorageAccess, unit names.UnitTag) ([]state.StorageInstance, error)
- func VolumeAttachmentFromState(v state.VolumeAttachment) (params.VolumeAttachment, error)
- func VolumeAttachmentInfoFromState(info state.VolumeAttachmentInfo) params.VolumeAttachmentInfo
- func VolumeAttachmentInfoToState(in params.VolumeAttachmentInfo) state.VolumeAttachmentInfo
- func VolumeAttachmentInfosToState(in map[string]params.VolumeAttachmentInfo) (map[names.VolumeTag]state.VolumeAttachmentInfo, error)
- func VolumeAttachmentPlanBlockInfoFromState(blockInfo state.BlockDeviceInfo) blockdevice.BlockDevice
- func VolumeAttachmentPlanBlockParamsFromState(blockInfo state.BlockDeviceInfo) params.BlockDevice
- func VolumeAttachmentPlanFromState(v state.VolumeAttachmentPlan) (params.VolumeAttachmentPlan, error)
- func VolumeAttachmentPlanInfoFromState(planInfo state.VolumeAttachmentPlanInfo) params.VolumeAttachmentPlanInfo
- func VolumeAttachmentPlanInfoToState(in params.VolumeAttachmentPlanInfo) state.VolumeAttachmentPlanInfo
- func VolumeAttachmentPlanToState(in params.VolumeAttachmentPlan) (names.MachineTag, names.VolumeTag, state.VolumeAttachmentPlanInfo, ...)
- func VolumeAttachmentToState(in params.VolumeAttachment) (names.MachineTag, names.VolumeTag, state.VolumeAttachmentInfo, error)
- func VolumeDetails(ctx context.Context, sb DetailsBackend, blockDeviceGetter BlockDeviceGetter, ...) (*params.VolumeDetails, error)
- func VolumeFromState(v state.Volume) (params.Volume, error)
- func VolumeInfoFromState(info state.VolumeInfo) params.VolumeInfo
- func VolumeParams(ctx context.Context, v state.Volume, storageInstance state.StorageInstance, ...) (params.VolumeParams, error)
- func VolumeToState(v params.Volume) (names.VolumeTag, state.VolumeInfo, error)
- func VolumesToState(in []params.Volume) (map[names.VolumeTag]state.VolumeInfo, error)
- type BlockDeviceGetter
- type DetailsBackend
- type FilesystemAccess
- type StorageAccess
- type StoragePoolGetter
- type UnitAssignedMachineFunc
- type VolumeAccess
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlockDeviceInfoToState ¶
func BlockDeviceInfoToState(in params.BlockDevice) state.BlockDeviceInfo
func ClassifyDetachedStorage ¶
func ClassifyDetachedStorage( stVolume VolumeAccess, stFile FilesystemAccess, storage []state.StorageInstance, ) (destroyed, detached []params.Entity, _ error)
ClassifyDetachedStorage classifies storage instances into those that will be destroyed, and those that will be detached, when their attachment is removed. Any storage that is not found will be omitted.
func FilesystemAttachmentFromState ¶
func FilesystemAttachmentFromState(v state.FilesystemAttachment) (params.FilesystemAttachment, error)
FilesystemAttachmentFromState converts a state.FilesystemAttachment to params.FilesystemAttachment.
func FilesystemAttachmentInfoFromState ¶
func FilesystemAttachmentInfoFromState(info state.FilesystemAttachmentInfo) params.FilesystemAttachmentInfo
FilesystemAttachmentInfoFromState converts a state.FilesystemAttachmentInfo to params.FilesystemAttachmentInfo.
func FilesystemAttachmentToState ¶
func FilesystemAttachmentToState(in params.FilesystemAttachment) (names.MachineTag, names.FilesystemTag, state.FilesystemAttachmentInfo, error)
FilesystemAttachmentToState converts a storage.FilesystemAttachment to a state.FilesystemAttachmentInfo.
func FilesystemDetails ¶
func FilesystemDetails( ctx context.Context, sb DetailsBackend, blockDeviceGetter BlockDeviceGetter, unitToMachine UnitAssignedMachineFunc, f state.Filesystem, attachments []state.FilesystemAttachment, ) (*params.FilesystemDetails, error)
FilesystemDetails returns the filesystem and its attachments as a params FilesystemDetails.
func FilesystemFromState ¶
func FilesystemFromState(f state.Filesystem) (params.Filesystem, error)
FilesystemFromState converts a state.Filesystem to params.Filesystem.
func FilesystemInfoFromState ¶
func FilesystemInfoFromState(info state.FilesystemInfo) params.FilesystemInfo
FilesystemInfoFromState converts a state.FilesystemInfo to params.FilesystemInfo.
func FilesystemParams ¶
func FilesystemParams( ctx context.Context, f state.Filesystem, storageInstance state.StorageInstance, modelUUID, controllerUUID string, environConfig *config.Config, storagePoolGetter StoragePoolGetter, registry storage.ProviderRegistry, ) (params.FilesystemParams, error)
FilesystemParams returns the parameters for creating or destroying the given filesystem.
func FilesystemToState ¶
func FilesystemToState(v params.Filesystem) (names.FilesystemTag, state.FilesystemInfo, error)
FilesystemToState converts a params.Filesystem to state.FilesystemInfo and names.FilesystemTag.
func MatchingFilesystemBlockDevice ¶
func MatchingFilesystemBlockDevice( blockDevices []blockdevice.BlockDevice, volumeInfo state.VolumeInfo, attachmentInfo state.VolumeAttachmentInfo, planBlockInfo blockdevice.BlockDevice, ) (*blockdevice.BlockDevice, bool)
MatchingFilesystemBlockDevice finds the block device that matches the provided volume info and volume attachment info, preferring a matching device of type partition.
func MatchingVolumeBlockDevice ¶
func MatchingVolumeBlockDevice( blockDevices []blockdevice.BlockDevice, volumeInfo state.VolumeInfo, attachmentInfo state.VolumeAttachmentInfo, planBlockInfo blockdevice.BlockDevice, ) (*blockdevice.BlockDevice, bool)
MatchingVolumeBlockDevice finds the block device that matches the provided volume info and volume attachment info.
func MaybeAssignedStorageInstance ¶
func MaybeAssignedStorageInstance( getTag func() (names.StorageTag, error), getStorageInstance func(names.StorageTag) (state.StorageInstance, error), ) (state.StorageInstance, error)
MaybeAssignedStorageInstance calls the provided function to get a StorageTag, and returns the corresponding state.StorageInstance if it didn't return an errors.IsNotAssigned error, or nil if it did.
func ParseFilesystemAttachmentIds ¶
func ParseFilesystemAttachmentIds(stringIds []string) ([]params.MachineStorageId, error)
ParseFilesystemAttachmentIds parses the strings, returning machine storage IDs.
func ParseVolumeAttachmentIds ¶
func ParseVolumeAttachmentIds(stringIds []string) ([]params.MachineStorageId, error)
ParseVolumeAttachmentIds parses the strings, returning machine storage IDs.
func StorageAttachmentInfo ¶
func StorageAttachmentInfo( ctx context.Context, st StorageAccess, stVolume VolumeAccess, stFile FilesystemAccess, blockDeviceGetter BlockDeviceGetter, att state.StorageAttachment, hostTag names.Tag, ) (*storage.StorageAttachmentInfo, error)
StorageAttachmentInfo returns the StorageAttachmentInfo for the specified StorageAttachment by gathering information from related entities (volumes, filesystems).
StorageAttachmentInfo returns an error satisfying errors.IsNotProvisioned if the storage attachment is not yet fully provisioned and ready for use by a charm.
func StorageDetails ¶
func StorageDetails( ctx context.Context, sb DetailsBackend, blockDeviceGetter BlockDeviceGetter, unitToMachine UnitAssignedMachineFunc, si state.StorageInstance, ) (*params.StorageDetails, error)
StorageDetails returns the storage instance as a params StorageDetails.
func StoragePoolConfig ¶
func StoragePoolConfig(ctx context.Context, name string, storagePoolGetter StoragePoolGetter, registry storage.ProviderRegistry) (storage.ProviderType, *storage.Config, error)
StoragePoolConfig returns the storage provider type and configuration for a named storage pool. If there is no such pool with the specified name, but it identifies a storage provider, then that type will be returned with a nil configuration.
func StorageTags ¶
func StorageTags( storageInstance state.StorageInstance, modelUUID, controllerUUID string, tagger tags.ResourceTagger, ) (map[string]string, error)
StorageTags returns the tags that should be set on a volume or filesystem, if the provider supports them.
func UnitStorage ¶
func UnitStorage(st StorageAccess, unit names.UnitTag) ([]state.StorageInstance, error)
UnitStorage returns the storage instances attached to the specified unit.
func VolumeAttachmentFromState ¶
func VolumeAttachmentFromState(v state.VolumeAttachment) (params.VolumeAttachment, error)
VolumeAttachmentFromState converts a state.VolumeAttachment to params.VolumeAttachment.
func VolumeAttachmentInfoFromState ¶
func VolumeAttachmentInfoFromState(info state.VolumeAttachmentInfo) params.VolumeAttachmentInfo
VolumeAttachmentInfoFromState converts a state.VolumeAttachmentInfo to params.VolumeAttachmentInfo.
func VolumeAttachmentInfoToState ¶
func VolumeAttachmentInfoToState(in params.VolumeAttachmentInfo) state.VolumeAttachmentInfo
VolumeAttachmentInfoToState converts a params.VolumeAttachmentInfo to a state.VolumeAttachmentInfo.
func VolumeAttachmentInfosToState ¶
func VolumeAttachmentInfosToState(in map[string]params.VolumeAttachmentInfo) (map[names.VolumeTag]state.VolumeAttachmentInfo, error)
VolumeAttachmentInfosToState converts a map of volume tags to params.VolumeAttachmentInfo to a map of volume tags to state.VolumeAttachmentInfo.
func VolumeAttachmentPlanBlockInfoFromState ¶
func VolumeAttachmentPlanBlockInfoFromState(blockInfo state.BlockDeviceInfo) blockdevice.BlockDevice
func VolumeAttachmentPlanBlockParamsFromState ¶
func VolumeAttachmentPlanBlockParamsFromState(blockInfo state.BlockDeviceInfo) params.BlockDevice
func VolumeAttachmentPlanFromState ¶
func VolumeAttachmentPlanFromState(v state.VolumeAttachmentPlan) (params.VolumeAttachmentPlan, error)
VolumeAttachmentPlanFromState converts a state.VolumeAttachmentPlan to params.VolumeAttachmentPlan.
func VolumeAttachmentPlanInfoFromState ¶
func VolumeAttachmentPlanInfoFromState(planInfo state.VolumeAttachmentPlanInfo) params.VolumeAttachmentPlanInfo
func VolumeAttachmentPlanInfoToState ¶
func VolumeAttachmentPlanInfoToState(in params.VolumeAttachmentPlanInfo) state.VolumeAttachmentPlanInfo
func VolumeAttachmentPlanToState ¶
func VolumeAttachmentPlanToState(in params.VolumeAttachmentPlan) (names.MachineTag, names.VolumeTag, state.VolumeAttachmentPlanInfo, state.BlockDeviceInfo, error)
func VolumeAttachmentToState ¶
func VolumeAttachmentToState(in params.VolumeAttachment) (names.MachineTag, names.VolumeTag, state.VolumeAttachmentInfo, error)
VolumeAttachmentToState converts a params.VolumeAttachment to a state.VolumeAttachmentInfo and tags.
func VolumeDetails ¶
func VolumeDetails( ctx context.Context, sb DetailsBackend, blockDeviceGetter BlockDeviceGetter, unitToMachine UnitAssignedMachineFunc, v state.Volume, attachments []state.VolumeAttachment, ) (*params.VolumeDetails, error)
VolumeDetails returns the volume and its attachments as a params VolumeDetails.
func VolumeFromState ¶
VolumeFromState converts a state.Volume to params.Volume.
func VolumeInfoFromState ¶
func VolumeInfoFromState(info state.VolumeInfo) params.VolumeInfo
VolumeInfoFromState converts a state.VolumeInfo to params.VolumeInfo.
func VolumeParams ¶
func VolumeParams( ctx context.Context, v state.Volume, storageInstance state.StorageInstance, modelUUID, controllerUUID string, environConfig *config.Config, storagePoolGetter StoragePoolGetter, registry storage.ProviderRegistry, ) (params.VolumeParams, error)
VolumeParams returns the parameters for creating or destroying the given volume.
func VolumeToState ¶
func VolumeToState(v params.Volume) (names.VolumeTag, state.VolumeInfo, error)
VolumeToState converts a params.Volume to state.VolumeInfo and names.VolumeTag.
func VolumesToState ¶
func VolumesToState(in []params.Volume) (map[names.VolumeTag]state.VolumeInfo, error)
VolumesToState converts a slice of params.Volume to a mapping of volume tags to state.VolumeInfo.
Types ¶
type BlockDeviceGetter ¶
type BlockDeviceGetter interface {
BlockDevices(ctx context.Context, machineId string) ([]blockdevice.BlockDevice, error)
}
BlockDeviceGetter instances can fetch block devices for a machine.
type DetailsBackend ¶
type DetailsBackend interface { StorageAccess VolumeAccess FilesystemAccess StorageAttachments(names.StorageTag) ([]state.StorageAttachment, error) }
DetailsBacked is used by StorageDetails, VolumeDetails and FilesystemDetails to access state for collecting all the required information to send back over the wire.
type FilesystemAccess ¶
type FilesystemAccess interface { // StorageInstanceFilesystem returns the state.Filesystem assigned // to the storage instance with the specified storage tag. StorageInstanceFilesystem(names.StorageTag) (state.Filesystem, error) // FilesystemAttachment returns the state.FilesystemAttachment // corresponding to the specified host and filesystem. FilesystemAttachment(names.Tag, names.FilesystemTag) (state.FilesystemAttachment, error) }
FilesystemAccess is an interface for obtaining information about filesystem storage instances and related entities.
type StorageAccess ¶
type StorageAccess interface { // StorageInstance returns the state.StorageInstance corresponding // to the specified storage tag. StorageInstance(names.StorageTag) (state.StorageInstance, error) // UnitStorageAttachments returns the storage attachments for the // specified unit. UnitStorageAttachments(names.UnitTag) ([]state.StorageAttachment, error) }
StorageAccess is an interface for obtaining information about storage instances and any associated volume and/or filesystem instances.
type StoragePoolGetter ¶
type StoragePoolGetter interface {
GetStoragePoolByName(ctx context.Context, name string) (*storage.Config, error)
}
StoragePoolGetter instances get a storage pool by name.
type UnitAssignedMachineFunc ¶
type UnitAssignedMachineFunc func(names.UnitTag) (names.MachineTag, error)
type VolumeAccess ¶
type VolumeAccess interface { // StorageInstanceVolume returns the state.Volume assigned to the // storage instance with the specified storage tag. StorageInstanceVolume(names.StorageTag) (state.Volume, error) // VolumeAttachment returns the state.VolumeAttachment corresponding // to the specified host and volume. VolumeAttachment(names.Tag, names.VolumeTag) (state.VolumeAttachment, error) // VolumeAttachmentPlan returns state.VolumeAttachmentPlan corresponding // to the specified machine and volume VolumeAttachmentPlan(names.Tag, names.VolumeTag) (state.VolumeAttachmentPlan, error) }
VolumeAccess is an interface for obtaining information about block storage instances and related entities.