config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2016 License: Apache-2.0 Imports: 21 Imported by: 0

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 (
	// RuntimeSchema defines json schema for runtime configuration
	RuntimeSchema = `` /* 459-byte string literal not displayed */

	// PolicySchema defines the json schema for policy
	PolicySchema = `` /* 614-byte string literal not displayed */

	//VolumeSchema defines the json schema for volume
	VolumeSchema = `` /* 578-byte string literal not displayed */

)
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) CreatePolicyRevision added in v0.3.0

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

CreatePolicyRevision creates an revision entry in a policy's history.

func (*Client) CreateVolume

func (c *Client) CreateVolume(rc *VolumeRequest) (*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) GetPolicyRevision added in v0.3.0

func (c *Client) GetPolicyRevision(name, revision string) (string, error)

GetPolicyRevision returns a single revision for a given policy.

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) IsVolumeInUse added in v0.3.0

func (c *Client) IsVolumeInUse(cfg *Volume) (bool, error)

IsVolumeInUse checks if the given volume is mounted in any container

func (*Client) ListAllVolumes

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

ListAllVolumes returns an array with all the named policies and volumes the apiserver 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) ListPolicyRevisions added in v0.3.0

func (c *Client) ListPolicyRevisions(name string) ([]string, error)

ListPolicyRevisions returns a list of all the revisions for a given 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) WatchForPolicyChanges added in v0.3.0

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

WatchForPolicyChanges creates a watch which returns the policy name and revision whenever a new policy is uploaded.

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 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 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.

func (*Global) Canonical added in v0.2.0

func (global *Global) Canonical() *Global

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 added in v0.2.0

func (global *Global) Published() *Global

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.

func (*Global) SetEmpty added in v0.2.0

func (global *Global) SetEmpty() *Global

SetEmpty sets any emptied parameters. This is typically used during the creation of the object accepted from user input.

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

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.

func (*Policy) ValidateJSON added in v0.3.0

func (cfg *Policy) ValidateJSON() error

ValidateJSON validates the given policy against its defined schema

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

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

func (*RuntimeOptions) ValidateJSON added in v0.3.0

func (cfg *RuntimeOptions) ValidateJSON() error

ValidateJSON validates the given runtime against its defined schema

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

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.

func (*Volume) ValidateJSON added in v0.3.0

func (cfg *Volume) ValidateJSON() error

ValidateJSON validates the given volume against its defined schema

type VolumeRequest added in v0.3.0

type VolumeRequest struct {
	Name    string            `json:"name"`
	Policy  string            `json:"policy"`
	Options map[string]string `json:"options"`
}

VolumeRequest provides a request structure for communicating volumes to the apiserver or internally. it is the basic representation of a volume.

func (*VolumeRequest) String added in v0.3.0

func (v *VolumeRequest) String() string

Jump to

Keyboard shortcuts

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