Documentation
¶
Index ¶
- Constants
- Variables
- func Register(name string, initFunc InitFunc) error
- func Shutdown()
- type BlockDriver
- type DefaultBlockDriver
- type DefaultEnumerator
- func (e *DefaultEnumerator) CreateVol(vol *api.Volume) error
- func (e *DefaultEnumerator) DeleteVol(volID api.VolumeID) error
- func (e *DefaultEnumerator) Enumerate(locator api.VolumeLocator, labels api.Labels) ([]api.Volume, error)
- func (e *DefaultEnumerator) GetVol(volID api.VolumeID) (*api.Volume, error)
- func (e *DefaultEnumerator) Inspect(ids []api.VolumeID) ([]api.Volume, error)
- func (e *DefaultEnumerator) Lock(volID api.VolumeID) (interface{}, error)
- func (e *DefaultEnumerator) SnapEnumerate(volIDs []api.VolumeID, labels api.Labels) ([]api.Volume, error)
- func (e *DefaultEnumerator) Unlock(token interface{}) error
- func (e *DefaultEnumerator) UpdateVol(vol *api.Volume) error
- type DriverParams
- type DriverType
- type Enumerator
- type InitFunc
- type ProtoDriver
- type SnapshotNotSupported
- type Store
- type VolumeDriver
Constants ¶
const ( File = 1 << iota Block Object Clustered )
Variables ¶
var ( ErrExist = errors.New("Driver already exists") ErrDriverNotFound = errors.New("Driver implementation not found") ErrEnoEnt = errors.New("Volume does not exist.") ErrEnomem = errors.New("Out of memory.") ErrEinval = errors.New("Invalid argument") 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 ¶
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)
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) CreateVol ¶
func (e *DefaultEnumerator) CreateVol(vol *api.Volume) error
CreateVol returns error if volume with the same ID already existe.
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) Inspect ¶
Inspect specified volumes. Returns slice of volumes that were found.
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, labels api.Labels) ([]api.Volume, error)
SnapEnumerate for specified volume
func (*DefaultEnumerator) Unlock ¶
func (e *DefaultEnumerator) Unlock(token interface{}) error
Lock volume with token obtained from call to Lock.
type DriverParams ¶
type DriverType ¶
type DriverType int
type Enumerator ¶
type Enumerator interface {
// Inspect specified volumes.
// Returns slice of volumes that were found.
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)
// Enumerate snaps for specified volumes
SnapEnumerate(volID []api.VolumeID, snapLabels api.Labels) ([]api.Volume, 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
// Type of this driver
Type() DriverType
// 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
// Snapshot create volume snapshot.
// Errors ErrEnoEnt may be returned
Snapshot(volumeID api.VolumeID, readonly bool, locator api.VolumeLocator) (api.VolumeID, error)
// Stats for specified volume.
// Errors ErrEnoEnt may be returned
Stats(volumeID api.VolumeID) (api.Stats, error)
// Alerts on this volume.
// Errors ErrEnoEnt may be returned
Alerts(volumeID api.VolumeID) (api.Alerts, 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 SnapshotNotSupported ¶
type SnapshotNotSupported struct {
}
type Store ¶
type Store 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
}
type VolumeDriver ¶
type VolumeDriver interface {
ProtoDriver
BlockDriver
Enumerator
}
VolumeDriver is the main interface to be implemented by any storage driver. Every driver must at minimum implement the ProtoDriver sub interface.
func Get ¶
func Get(name string) (VolumeDriver, error)
func New ¶
func New(name string, params DriverParams) (VolumeDriver, error)