Documentation
¶
Index ¶
- 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 Enumerator
- type IODriver
- type InitFunc
- type IoNotSupported
- type ProtoDriver
- type SnapshotNotSupported
- type Store
- type VolumeDriver
Constants ¶
This section is empty.
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)
// 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) implementing the attach, format and detach interfaces.
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 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 IODriver ¶
type IODriver interface {
// Read sz bytes from specified volume at specified offset.
// Return number of bytes read and error.
Read(volumeID api.VolumeID,
buf []byte,
sz uint64,
offset int64) (int64, error)
// Write sz bytes from specified volume at specified offset.
// Return number of bytes written and error.
Write(volumeID api.VolumeID,
buf []byte,
sz uint64,
offset int64) (int64, error)
// Flush writes to stable storage.
// Return error.
Flush(volumeID api.VolumeID) error
}
IODriver interfaces applicable to object store interfaces.
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() api.DriverType
// Create a new Vol for the specific volume spec.
// It returns a system generated VolumeID that uniquely identifies the volume
Create(locator api.VolumeLocator,
Source *api.Source,
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
// Update not all fields of the spec are supported, ErrNotSupported will be thrown for unsupported
// updates.
Set(volumeID api.VolumeID, locator *api.VolumeLocator, spec *api.VolumeSpec) 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 {
IODriver
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)