Documentation
¶
Index ¶
Constants ¶
const ( // DefaultFilesystem is the default filesystem in volplugin. Overridden by policy. DefaultFilesystem = "ext4" // GlobalConfigName is the path to the global configuration under the db prefix. GlobalConfigName = "global-config" // DefaultGlobalTTL is the TTL used when no TTL exists. DefaultGlobalTTL = 30 * time.Second // DefaultTimeout is the standard command timeout when none is provided. DefaultTimeout = 10 * time.Minute // TimeoutFixBase is our base timeout -- timeouts supplied to the user are multiplied against this for storage and evaluation. TimeoutFixBase = time.Minute // TTLFixBase is our base TTL. TTLs supplied to the user are multipled against this for storage and evaulation. TTLFixBase = time.Second // DefaultMountPath is the standard mount path for all mounts. DefaultMountPath = "/mnt" )
Variables ¶
var ( // RuntimeSchema defines json schema for runtime configuration RuntimeSchema = `` /* 459-byte string literal not displayed */ // PolicySchema defines the json schema for policy PolicySchema = `` /* 612-byte string literal not displayed */ //VolumeSchema defines the json schema for volume VolumeSchema = `` /* 578-byte string literal not displayed */ )
var DefaultDrivers = map[string]*BackendDrivers{
"ceph": {"ceph", "ceph", "ceph"},
"nfs": {"", "nfs", ""},
}
DefaultDrivers are macro type definitions for backend drivers.
var DefaultFilesystems = map[string]string{
"ext4": "mkfs.ext4 -m0 %",
}
DefaultFilesystems is a map of our default supported filesystems. Overridden by policy.
Functions ¶
This section is empty.
Types ¶
type BackendDrivers ¶
type BackendDrivers struct { CRUD string `json:"crud"` Mount string `json:"mount"` Snapshot string `json:"snapshot"` }
BackendDrivers is a struct containing all the drivers used under this policy
type Client ¶
type Client interface { // Get the entity. Will copy the contents of the JSON into the entity for // use. Get(Entity) error // Set the entity. Will persist the entity to etcd based on the path it // provides. (See Path()) Set(Entity) error // Delete the entity from the database. Does nothing to the underlying // Object. Delete(Entity) error // Watch the Entity; just the entity and nothing else. Returns a channel for // Entity updates and one for errors. Watch(Entity) (chan Entity, chan error) // watch of entity // WatchStop stops a watch on a specific Entity. WatchStop(Entity) error // WatchAll watches the prefix of the entity for changes, watching all of the // specific type. WatchAll(Entity) (chan Entity, chan error) // watch of subtree // WatchAllStop stops a WatchAll. WatchAllStop(Entity) error // Dump dumps a tarball make with mktemp() to the specified directory. Dump(string) (string, error) // Prefix returns the base prefix for our keyspace. Prefix() string // List takes an Entity which it will then populate an []Entity with a list of objects. List(Entity) ([]Entity, error) }
Client provides a method of hooking into our data stores. It processes entities (see below) and their pipeline between them and k/v stores such as etcd and consul.
type CreateOptions ¶
type CreateOptions struct { Size string `json:"size" merge:"size"` FileSystem string `json:"filesystem" merge:"filesystem"` }
CreateOptions are the set of options used by apiserver during the volume create operation.
func (*CreateOptions) ActualSize ¶
func (co *CreateOptions) ActualSize() (uint64, error)
ActualSize returns the size of the volume as an integer of megabytes.
type Entity ¶
type Entity interface { // Prefix is the base path for all keys; used for watchall and list Prefix() string // Path to object; used for watch and i/o operations. Path() (string, error) // Validate the object and ensure it is safe to write, and to use after read. Validate() error // Copy the object and returns Entity. Typically used to work around // interface polymorphism idioms in go. Copy() Entity // Hooks returns a db.Hooks which contains several functions for the Entity // lifecycle, such as pre-set and post-get. Hooks() *Hooks }
Entity provides an abstraction on our types and how they are persisted to k/v stores. They are capable of describing all they need to be written to the database, which Client above is trained to do.
type Global ¶
Global is the global configuration.
func (*Global) Canonical ¶
Canonical returns a copy of the current global with the parameters adjusted to fit the internal (or canonical) representation. To see the published version, see Published() above.
It is very important that you do not run this function multiple times against the same data set. It will adjust the parameters twice.
func (*Global) Published ¶
Published returns a copy of the current global with the parameters adjusted to fit the published representation. To see the internal/system/canonical version, please see Canonical() below.
It is very important that you do not run this function multiple times against the same data set. It will adjust the parameters twice.
type Hook ¶
Hook is the type that represents a client hook in our entities system. Hooks are fired at certain client operations (see Hooks below) to cleanup or reconcile work.
type Hooks ¶
type Hooks struct { PreSet Hook PostSet Hook PreGet Hook PostGet Hook PreDelete Hook PostDelete Hook PreValidate Hook PostValidate Hook }
Hooks for CRUD operations. See Entity.Hooks()
type Policy ¶
type Policy struct { Name string `json:"name"` Unlocked bool `json:"unlocked,omitempty" merge:"unlocked"` CreateOptions CreateOptions `json:"create"` RuntimeOptions *RuntimeOptions `json:"runtime"` DriverOptions map[string]string `json:"driver"` FileSystems map[string]string `json:"filesystems"` Backends *BackendDrivers `json:"backends,omitempty"` Backend string `json:"backend,omitempty"` }
Policy is the configuration of the policy. It includes default information for items such as pool and volume configuration.
func NewPolicy ¶
NewPolicy creates a policy struct with the required parameters for using it. It will not pass validation.
type RateLimitConfig ¶
type RateLimitConfig struct { WriteBPS uint64 `json:"write-bps" merge:"rate-limit.write.bps"` ReadBPS uint64 `json:"read-bps" merge:"rate-limit.read.bps"` }
RateLimitConfig is the configuration for limiting the rate of disk access.
type RuntimeOptions ¶
type RuntimeOptions struct { UseSnapshots bool `json:"snapshots" merge:"snapshots"` Snapshot SnapshotConfig `json:"snapshot"` RateLimit RateLimitConfig `json:"rate-limit,omitempty"` // contains filtered or unexported fields }
RuntimeOptions are the set of options used by volplugin when mounting the volume, and by volsupervisor for calculating periodic work.
func NewRuntimeOptions ¶
func NewRuntimeOptions(policy, volume string) *RuntimeOptions
NewRuntimeOptions creates a new runtime options struct with a path so it can be found or written to.
func (*RuntimeOptions) Copy ¶
func (ro *RuntimeOptions) Copy() Entity
Copy returns a copy of this RuntimeOptions.
func (*RuntimeOptions) Hooks ¶
func (ro *RuntimeOptions) Hooks() *Hooks
Hooks returns nothing for RuntimeOptions.
func (*RuntimeOptions) Path ¶
func (ro *RuntimeOptions) Path() (string, error)
Path returns a combined path of the runtime payload.
func (*RuntimeOptions) Prefix ¶
func (ro *RuntimeOptions) Prefix() string
Prefix returns the path of the base directory where these entities are stored.
func (*RuntimeOptions) Validate ¶
func (ro *RuntimeOptions) Validate() error
Validate the Runtime Options.
type SnapshotConfig ¶
type SnapshotConfig struct { Frequency string `json:"frequency" merge:"snapshots.frequency"` Keep uint `json:"keep" merge:"snapshots.keep"` }
SnapshotConfig is the configuration for snapshots.
type UseLocker ¶
type UseLocker interface { // GetVolume gets the volume name for this use. GetVolume() string // GetReason gets the reason for this use. GetReason() string // Type returns the type of lock. Type() string // MayExist determines if a key may exist during initial write MayExist() bool }
UseLocker is an interface to locks controlled in etcd, or what we call "users".
type UseMount ¶
UseMount is the mount locking mechanism for users. Users are hosts, consumers of a volume. Examples of uses are: creating a volume, using a volume, removing a volume, snapshotting a volume. These are supplied in the `Reason` field as text.
type UseSnapshot ¶
UseSnapshot is similar to UseMount in that it is a locking mechanism, just for snapshots this time. Taking snapshots can block certain actions such as taking other snapshots or deleting snapshots.
type Volume ¶
type Volume struct { PolicyName string `json:"policy"` VolumeName string `json:"name"` Unlocked bool `json:"unlocked,omitempty" merge:"unlocked"` DriverOptions map[string]string `json:"driver"` MountSource string `json:"mount" merge:"mount"` CreateOptions CreateOptions `json:"create"` RuntimeOptions *RuntimeOptions `json:"runtime"` Backends *BackendDrivers `json:"backends,omitempty"` }
Volume is the configuration of the policy. It includes pool and snapshot information.
func CreateVolume ¶
func CreateVolume(vr *VolumeRequest) (*Volume, error)
CreateVolume creates a volume from parameters, including the policy to copy.
func (*Volume) Hooks ¶
Hooks provides hooks into the volume CRUD lifecycle. Currently this is used to split runtime parameters out from the rest of the volume information.
func (*Volume) ToDriverOptions ¶
ToDriverOptions converts a volume to a storage.DriverOptions.