volume

package
v0.0.0-...-cef01b0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	File  = DriverType("FileDriver")
	Block = DriverType("BlockDriver")
	Objec = DriverType("ObjectDriver")
)

Variables

View Source
var (
	ErrExist          = errors.New("Driver already exists")
	ErrDriverNotFound = errors.New("Driver implementation not found")
	ErrEnoEnt         = errors.New("Volume does not exist.")
	ErrVolDetached    = errors.New("Volume is detached")
	ErrVolAttached    = errors.New("Volume is attached")
	ErrVolHasSnaps    = errors.New("Volume has snapshots associated")
	ErrNotSupported   = errors.New("Operation not supported")
)

Functions

func Register

func Register(name string, driverType DriverType, initFunc InitFunc) error

func Shutdown

func Shutdown()

Types

type BlockDriver

type BlockDriver interface {
	// Attach map device to the host.
	// On success the devicePath specifies location where the device is exported
	// Errors ErrEnoEnt, ErrVolAttached may be returned.
	Attach(volumeID api.VolumeID) (string, error)

	// Format volume according to spec provided in Create
	// Errors ErrEnoEnt, ErrVolDetached may be returned.
	Format(volumeID api.VolumeID) error

	// Detach device from the host.
	// Errors ErrEnoEnt, ErrVolDetached may be returned.
	Detach(volumeID api.VolumeID) error
}

BlockDriver needs to be implemented by block volume drivers. Filesystem volume drivers can ignore this interface and include the builtin DefaultBlockDriver.

type DefaultBlockDriver

type DefaultBlockDriver struct {
}

DefaultBlockDriver is a default (null) block driver implementation. This can be used by drivers that do not want to (or care about) implement the attach, format and detach interfaces.

func (*DefaultBlockDriver) Attach

func (d *DefaultBlockDriver) Attach(volumeID api.VolumeID) (path string, err error)

func (*DefaultBlockDriver) Detach

func (d *DefaultBlockDriver) Detach(volumeID api.VolumeID) error

func (*DefaultBlockDriver) Format

func (d *DefaultBlockDriver) Format(volumeID api.VolumeID) error

type DefaultEnumerator

type DefaultEnumerator struct {
	// contains filtered or unexported fields
}

DefaultEnumerator for volume information. Implements the Enumerator Interface

func NewDefaultEnumerator

func NewDefaultEnumerator(driver string, kvdb kvdb.Kvdb) *DefaultEnumerator

NewDefaultEnumerator initializes store with specified kvdb.

func (*DefaultEnumerator) CreateSnap

func (e *DefaultEnumerator) CreateSnap(snap *api.VolumeSnap) error

CreateSnap with new snap

func (*DefaultEnumerator) CreateVol

func (e *DefaultEnumerator) CreateVol(vol *api.Volume) error

CreateVol returns error if volume with the same ID already existe.

func (*DefaultEnumerator) DeleteSnap

func (e *DefaultEnumerator) DeleteSnap(snapID api.SnapID) error

DeleteSnap with new snap

func (*DefaultEnumerator) DeleteVol

func (e *DefaultEnumerator) DeleteVol(volID api.VolumeID) error

DeleteVol. Returns error if volume does not exist.

func (*DefaultEnumerator) Enumerate

func (e *DefaultEnumerator) Enumerate(locator api.VolumeLocator,
	labels api.Labels) ([]api.Volume, error)

Enumerate volumes that map to the volumeLocator. Locator fields may be regexp. If locator fields are left blank, this will return all volumee.

func (*DefaultEnumerator) GetSnap

func (e *DefaultEnumerator) GetSnap(snapID api.SnapID) (*api.VolumeSnap, error)

GetSnap from snapID

func (*DefaultEnumerator) GetVol

func (e *DefaultEnumerator) GetVol(volID api.VolumeID) (*api.Volume, error)

GetVol from volID.

func (*DefaultEnumerator) Inspect

func (e *DefaultEnumerator) Inspect(ids []api.VolumeID) ([]api.Volume, error)

Inspect specified volumee. Errors ErrEnoEnt may be returned.

func (*DefaultEnumerator) Lock

func (e *DefaultEnumerator) Lock(volID api.VolumeID) (interface{}, error)

Lock volume specified by volID.

func (*DefaultEnumerator) SnapEnumerate

func (e *DefaultEnumerator) SnapEnumerate(
	volIDs []api.VolumeID,
	snapLabels api.Labels) ([]api.VolumeSnap, error)

Enumerate snaps for specified volume

func (*DefaultEnumerator) SnapInspect

func (e *DefaultEnumerator) SnapInspect(ids []api.SnapID) ([]api.VolumeSnap, error)

SnapInspect provides details on this snapshot. Errors ErrEnoEnt may be returned

func (*DefaultEnumerator) Unlock

func (e *DefaultEnumerator) Unlock(token interface{}) error

Lock volume with token obtained from call to Lock.

func (*DefaultEnumerator) UpdateSnap

func (e *DefaultEnumerator) UpdateSnap(snap *api.VolumeSnap) error

Update snap with snap

func (*DefaultEnumerator) UpdateVol

func (e *DefaultEnumerator) UpdateVol(vol *api.Volume) error

UpdateVol with vol

type DefaultEnumeratorUpdate

type DefaultEnumeratorUpdate interface {
	// Lock volume specified by volID.
	Lock(volID api.VolumeID) (interface{}, error)

	// Lock volume with token obtained from call to Lock.
	Unlock(token interface{}) error

	// CreateVol returns error if volume with the same ID already existe.
	CreateVol(vol *api.Volume) error

	// GetVol from volID.
	GetVol(volID api.VolumeID) (*api.Volume, error)

	// UpdateVol with vol
	UpdateVol(vol *api.Volume) error

	// DeleteVol. Returns error if volume does not exist.
	DeleteVol(volID api.VolumeID) error

	// GetSnap from snapID
	GetSnap(snapID api.SnapID) (*api.VolumeSnap, error)

	// Update snap with snap
	UpdateSnap(snap *api.VolumeSnap) error

	// CreateSnap with new snap
	CreateSnap(snap *api.VolumeSnap) error

	// DeleteSnap with new snap
	DeleteSnap(snapID api.SnapID) error
}

type DriverParams

type DriverParams map[string]string

type DriverType

type DriverType string

type Enumerator

type Enumerator interface {
	// Inspect specified volumes.
	// Errors ErrEnoEnt may be returned.
	Inspect(volumeIDs []api.VolumeID) ([]api.Volume, error)

	// Enumerate volumes that map to the volumeLocator. Locator fields may be regexp.
	// If locator fields are left blank, this will return all volumes.
	Enumerate(locator api.VolumeLocator, labels api.Labels) ([]api.Volume, error)

	// SnapInspect provides details on this snapshot.
	// Errors ErrEnoEnt may be returned
	SnapInspect(snapID []api.SnapID) ([]api.VolumeSnap, error)

	// Enumerate snaps for specified volumes
	SnapEnumerate(volID []api.VolumeID, snapLabels api.Labels) ([]api.VolumeSnap, error)
}

Enumerator provides a set of interfaces to get details on a set of volumes.

type InitFunc

type InitFunc func(params DriverParams) (VolumeDriver, error)

type ProtoDriver

type ProtoDriver interface {
	// String description of this driver.
	String() string

	// Create a new Vol for the specific volume spec.
	// It returns a system generated VolumeID that uniquely identifies the volume
	// If CreateOptions.FailIfExists is set and a volume matching the locator
	// exists then this will fail with ErrEexist. Otherwise if a matching available
	// volume is found then it is returned instead of creating a new volume.
	Create(locator api.VolumeLocator,
		options *api.CreateOptions,
		spec *api.VolumeSpec) (api.VolumeID, error)

	// Delete volume.
	// Errors ErrEnoEnt, ErrVolHasSnaps may be returned.
	Delete(volumeID api.VolumeID) error

	// Mount volume at specified path
	// Errors ErrEnoEnt, ErrVolDetached may be returned.
	Mount(volumeID api.VolumeID, mountpath string) error

	// Unmount volume at specified path
	// Errors ErrEnoEnt, ErrVolDetached may be returned.
	Unmount(volumeID api.VolumeID, mountpath string) error

	// Snap specified volume. IO to the underlying volume should be quiesced before
	// calling this function.
	// Errors ErrEnoEnt may be returned
	Snapshot(volumeID api.VolumeID, labels api.Labels) (api.SnapID, error)

	// SnapDelete snap specified by snapID.
	// Errors ErrEnoEnt may be returned
	SnapDelete(snapID api.SnapID) error

	// Stats for specified volume.
	// Errors ErrEnoEnt may be returned
	Stats(volumeID api.VolumeID) (api.VolumeStats, error)

	// Alerts on this volume.
	// Errors ErrEnoEnt may be returned
	Alerts(volumeID api.VolumeID) (api.VolumeAlerts, error)

	// Status returns a set of key-value pairs which give low
	// level diagnostic status about this driver.
	Status() [][2]string

	// Shutdown and cleanup.
	Shutdown()
}

ProtoDriver must be implemented by all volume drivers. It specifies the most basic functionality, such as creating and deleting volumes.

type VolumeDriver

type VolumeDriver interface {
	ProtoDriver
	BlockDriver
	Enumerator
}

func Get

func Get(name string) (VolumeDriver, error)

func New

func New(name string, params DriverParams) (VolumeDriver, error)

Jump to

Keyboard shortcuts

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