storagecommon

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package storagecommon provides common storage-related services for API server facades.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockDeviceFromState

func BlockDeviceFromState(in state.BlockDeviceInfo) storage.BlockDevice

BlockDeviceFromState translates a state.BlockDeviceInfo to a storage.BlockDevice.

func BlockDeviceInfoToState

func BlockDeviceInfoToState(in storage.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 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(
	f state.Filesystem,
	storageInstance state.StorageInstance,
	modelUUID, controllerUUID string,
	environConfig *config.Config,
	poolManager poolmanager.PoolManager,
	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 MatchingBlockDevice

func MatchingBlockDevice(
	blockDevices []state.BlockDeviceInfo,
	volumeInfo state.VolumeInfo,
	attachmentInfo state.VolumeAttachmentInfo,
	planBlockInfo state.BlockDeviceInfo,
) (*state.BlockDeviceInfo, bool)

MatchingBlockDevice 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(
	st StorageAccess,
	stVolume VolumeAccess,
	stFile FilesystemAccess,
	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 StoragePoolConfig

func StoragePoolConfig(name string, poolManager poolmanager.PoolManager, 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) storage.BlockDevice

func VolumeAttachmentPlanFromState

func VolumeAttachmentPlanFromState(v state.VolumeAttachmentPlan) (params.VolumeAttachmentPlan, error)

VolumeAttachmentPlanFromState converts a state.VolumeAttachmentPlan to params.VolumeAttachmentPlan.

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 VolumeFromState

func VolumeFromState(v state.Volume) (params.Volume, error)

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(
	v state.Volume,
	storageInstance state.StorageInstance,
	modelUUID, controllerUUID string,
	environConfig *config.Config,
	poolManager poolmanager.PoolManager,
	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 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 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)

	// BlockDevices returns information about block devices published
	// for the specified machine.
	BlockDevices(names.MachineTag) ([]state.BlockDeviceInfo, error)
}

VolumeAccess is an interface for obtaining information about block storage instances and related entities.

Jump to

Keyboard shortcuts

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