config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2016 License: Apache-2.0 Imports: 21 Imported by: 34

Documentation

Index

Constants

View Source
const (
	// 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
)

Variables

View Source
var (
	// UseTypeMount is the string type of mount use locks
	UseTypeMount = "mount"
	// UseTypeSnapshot is the string type of snapshot use locks
	UseTypeSnapshot = "snapshot"
)

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 struct {
	// contains filtered or unexported fields
}

Client is the top-level struct for communicating with the intent store.

func NewClient

func NewClient(prefix string, etcdHosts []string) (*Client, error)

NewClient creates a Client struct which can drive communication with the configuration store.

func (*Client) CreateVolume

func (c *Client) CreateVolume(rc Request) (*Volume, error)

CreateVolume sets the appropriate config metadata for a volume creation operation, and returns the Volume that was copied in.

func (*Client) DeletePolicy

func (c *Client) DeletePolicy(name string) error

DeletePolicy removes a policy from the configuration store.

func (*Client) DumpTarball

func (c *Client) DumpTarball() (string, error)

DumpTarball dumps all the keys under the current etcd prefix into a gzip'd tarball'd directory-based representation of the namespace.

func (*Client) GetGlobal

func (tlc *Client) GetGlobal() (*Global, error)

GetGlobal retrieves the global configuration.

func (*Client) GetPolicy

func (c *Client) GetPolicy(name string) (*Policy, error)

GetPolicy retrieves a policy from the configuration store.

func (*Client) GetUse

func (c *Client) GetUse(ut UseLocker, vc *Volume) error

GetUse retrieves the UseMount for the given volume name.

func (*Client) GetVolume

func (c *Client) GetVolume(policy, name string) (*Volume, error)

GetVolume returns the Volume for a given volume.

func (*Client) GetVolumeRuntime

func (c *Client) GetVolumeRuntime(policy, name string) (RuntimeOptions, error)

GetVolumeRuntime retrieves only the runtime parameters for the volume.

func (*Client) ListAllVolumes

func (c *Client) ListAllVolumes() ([]string, error)

ListAllVolumes returns an array with all the named policies and volumes the volmaster knows about. Volumes have syntax: policy/volumeName which will be reflected in the returned string.

func (*Client) ListPolicies

func (c *Client) ListPolicies() ([]Policy, error)

ListPolicies provides an array of strings corresponding to the name of each policy.

func (*Client) ListUses

func (c *Client) ListUses(typ string) ([]string, error)

ListUses lists the items in use.

func (*Client) ListVolumes

func (c *Client) ListVolumes(policy string) (map[string]*Volume, error)

ListVolumes returns a map of volume name -> Volume.

func (*Client) PublishGlobal

func (tlc *Client) PublishGlobal(g *Global) error

PublishGlobal publishes the global configuration.

func (*Client) PublishPolicy

func (c *Client) PublishPolicy(name string, cfg *Policy) error

PublishPolicy publishes policy intent to the configuration store.

func (*Client) PublishUse

func (c *Client) PublishUse(ut UseLocker) error

PublishUse pushes the use to etcd.

func (*Client) PublishUseWithTTL

func (c *Client) PublishUseWithTTL(ut UseLocker, ttl time.Duration, exist client.PrevExistType) error

PublishUseWithTTL pushes the use to etcd, with a TTL that expires the record if it has not been updated within that time.

func (*Client) PublishVolume

func (c *Client) PublishVolume(vc *Volume) error

PublishVolume writes a volume to etcd.

func (*Client) PublishVolumeRuntime

func (c *Client) PublishVolumeRuntime(vo *Volume, ro RuntimeOptions) error

PublishVolumeRuntime publishes the runtime parameters for each volume.

func (*Client) RemoveTakeSnapshot

func (c *Client) RemoveTakeSnapshot(name string) error

RemoveTakeSnapshot removes a reference to a taken snapshot, intended to be used by volsupervisor

func (*Client) RemoveUse

func (c *Client) RemoveUse(ut UseLocker, force bool) error

RemoveUse will remove a user from etcd. Does not fail if the user does not exist.

func (*Client) RemoveVolume

func (c *Client) RemoveVolume(policy, name string) error

RemoveVolume removes a volume from configuration.

func (*Client) TakeSnapshot

func (c *Client) TakeSnapshot(name string) error

TakeSnapshot immediately takes a snapshot by signalling the volsupervisor through etcd.

func (*Client) WatchGlobal

func (tlc *Client) WatchGlobal(activity chan *watch.Watch)

WatchGlobal watches a global and updates it as soon as the config changes.

func (*Client) WatchSnapshotSignal

func (c *Client) WatchSnapshotSignal(activity chan *watch.Watch)

WatchSnapshotSignal watches for a signal to be provided to /volplugin/snapshots via writing an empty file to the policy/volume name.

func (*Client) WatchVolumeRuntimes

func (c *Client) WatchVolumeRuntimes(activity chan *watch.Watch)

WatchVolumeRuntimes watches the runtime portions of the volume and yields back any information received through the activity channel.

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 volmaster 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 Global

type Global struct {
	Debug     bool
	Timeout   time.Duration
	TTL       time.Duration
	MountPath string
}

Global is the global configuration.

func NewGlobalConfig

func NewGlobalConfig() *Global

NewGlobalConfig returns global config with preset defaults

func NewGlobalConfigFromJSON

func NewGlobalConfigFromJSON(content []byte) (*Global, error)

NewGlobalConfigFromJSON transforms json into a global.

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"`
}

Policy is the configuration of the policy. It includes default information for items such as pool and volume configuration.

func NewPolicy

func NewPolicy() *Policy

NewPolicy return policy config with specified backend preset

func (*Policy) String

func (cfg *Policy) String() string

func (*Policy) Validate

func (cfg *Policy) Validate() error

Validate ensures the structure of the policy is sane.

type RateLimitConfig

type RateLimitConfig struct {
	WriteIOPS uint   `json:"write-iops" merge:"rate-limit.write.iops"`
	ReadIOPS  uint   `json:"read-iops" merge:"rate-limit.read.iops"`
	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 Request

type Request struct {
	Volume  string            `json:"volume"`
	Policy  string            `json:"policy"`
	Options map[string]string `json:"options"`
}

Request provides a request structure for communicating with the volmaster.

type RuntimeOptions

type RuntimeOptions struct {
	UseSnapshots bool            `json:"snapshots" merge:"snapshots"`
	Snapshot     SnapshotConfig  `json:"snapshot"`
	RateLimit    RateLimitConfig `json:"rate-limit,omitempty"`
}

RuntimeOptions are the set of options used by volplugin when mounting the volume, and by volsupervisor for calculating periodic work.

func (*RuntimeOptions) Validate

func (ro *RuntimeOptions) Validate() error

Validate options for a volume. Should be called anytime options are considered.

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

type UseMount struct {
	Volume   string
	Hostname string
	Reason   string
}

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.

func (*UseMount) GetReason

func (um *UseMount) GetReason() string

GetReason gets the reason for this use.

func (*UseMount) GetVolume

func (um *UseMount) GetVolume() string

GetVolume gets the *Volume for this use.

func (*UseMount) MayExist

func (um *UseMount) MayExist() bool

MayExist determines if a key may exist during initial write

func (*UseMount) Type

func (um *UseMount) Type() string

Type returns the type of lock.

type UseSnapshot

type UseSnapshot struct {
	Volume string
	Reason string
}

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.

func (*UseSnapshot) GetReason

func (us *UseSnapshot) GetReason() string

GetReason gets the reason for this use.

func (*UseSnapshot) GetVolume

func (us *UseSnapshot) GetVolume() string

GetVolume gets the *Volume for this use.

func (*UseSnapshot) MayExist

func (us *UseSnapshot) MayExist() bool

MayExist determines if a key may exist during initial write

func (*UseSnapshot) Type

func (us *UseSnapshot) Type() string

Type returns the type of lock.

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"`
}

Volume is the configuration of the policy. It includes pool and snapshot information.

func (*Volume) String

func (cfg *Volume) String() string

func (*Volume) ToDriverOptions

func (cfg *Volume) ToDriverOptions(timeout time.Duration) (storage.DriverOptions, error)

ToDriverOptions converts a volume to a storage.DriverOptions.

func (*Volume) Validate

func (cfg *Volume) Validate() error

Validate validates a volume configuration, returning error on any issue.

Jump to

Keyboard shortcuts

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