storageops

package
v5.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrVolDetached is code for a volume is detached on the instance
	ErrVolDetached
	// ErrVolInval is the code for a invalid volume
	ErrVolInval
	// ErrVolAttachedOnRemoteNode is code when a volume is not attached locally
	// but attached on a remote node
	ErrVolAttachedOnRemoteNode
	// ErrVolNotFound is code when a volume is not found
	ErrVolNotFound
	// ErrInvalidDevicePath is code when a volume/disk has invalid device path
	ErrInvalidDevicePath
)

Custom storage operation error codes.

View Source
const ProviderOpsMaxRetries = 10

ProviderOpsMaxRetries is the number of retries to use for provider ops

View Source
const ProviderOpsRetryInterval = 3 * time.Second

ProviderOpsRetryInterval is the time to wait before each retry of provider ops

View Source
const ProviderOpsTimeout = time.Minute

ProviderOpsTimeout is the default timeout of storage provider ops

View Source
const (
	// SetIdentifierNone is a default identifier to group all disks from a
	// particular set
	SetIdentifierNone = "None"
)

Variables

View Source
var ErrNotSupported = fmt.Errorf("operation not supported")

ErrNotSupported is returned when a particular operation is not supported

Functions

func AddElementToMap

func AddElementToMap(
	sets map[string][]interface{},
	elem interface{},
	key string,
)

AddElementToMap adds to the given 'elem' to the 'sets' map with given 'key'

func GetEnvValueStrict

func GetEnvValueStrict(key string) (string, error)

GetEnvValueStrict fetches value for env variable "key". Returns error if not found or empty

func NewStorageError

func NewStorageError(code int, msg string, instance string) error

NewStorageError creates a new custom storage error instance

Types

type Ops

type Ops interface {
	// Name returns name of the storage operations driver
	Name() string
	// InstanceID returns the ID of the instance of the default instance the operations are performed on
	InstanceID() string
	// Create volume based on input template volume and also apply given labels.
	Create(template interface{}, labels map[string]string) (interface{}, error)
	// GetDeviceID returns ID/Name of the given device/disk or snapshot
	GetDeviceID(template interface{}) (string, error)
	// Attach volumeID.
	// Return attach path.
	Attach(volumeID string) (string, error)
	// Detach volumeID.
	Detach(volumeID string) error
	// DetachFrom detaches the disk/volume with given ID from the given instance ID
	DetachFrom(volumeID, instanceID string) error
	// Delete volumeID.
	Delete(volumeID string) error
	// DeleteFrom deletes the given volume/disk from the given instanceID
	DeleteFrom(volumeID, instanceID string) error
	// Desribe an instance
	Describe() (interface{}, error)
	// FreeDevices returns free block devices on the instance.
	// blockDeviceMappings is a data structure that contains all block devices on
	// the instance and where they are mapped to
	FreeDevices(blockDeviceMappings []interface{}, rootDeviceName string) ([]string, error)
	// Inspect volumes specified by volumeID
	Inspect(volumeIds []*string) ([]interface{}, error)
	// DeviceMappings returns map[local_attached_volume_path]->volume ID/NAME
	DeviceMappings() (map[string]string, error)
	// Enumerate volumes that match given filters. Organize them into
	// sets identified by setIdentifier.
	// labels can be nil, setIdentifier can be empty string.
	Enumerate(volumeIds []*string,
		labels map[string]string,
		setIdentifier string,
	) (map[string][]interface{}, error)
	// DevicePath for the given volume i.e path where it's attached
	DevicePath(volumeID string) (string, error)
	// Snapshot the volume with given volumeID
	Snapshot(volumeID string, readonly bool) (interface{}, error)
	// SnapshotDelete deletes the snapshot with given ID
	SnapshotDelete(snapID string) error
	// ApplyTags will apply given labels/tags on the given volume
	ApplyTags(volumeID string, labels map[string]string) error
	// RemoveTags removes labels/tags from the given volume
	RemoveTags(volumeID string, labels map[string]string) error
	// Tags will list the existing labels/tags on the given volume
	Tags(volumeID string) (map[string]string, error)
}

Ops interface to perform basic storage operations.

type StorageError

type StorageError struct {
	// Code is one of storage operation driver error codes.
	Code int
	// Msg is human understandable error message.
	Msg string
	// Instance provides more information on the error.
	Instance string
}

StorageError error returned for storage operations

func (*StorageError) Error

func (e *StorageError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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