common

package
v0.0.0-...-65247a5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2014 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadId          = stderrors.New("id not found")
	ErrBadCreds       = stderrors.New("invalid entity name or password")
	ErrPerm           = stderrors.New("permission denied")
	ErrNotLoggedIn    = stderrors.New("not logged in")
	ErrUnknownWatcher = stderrors.New("unknown watcher id")
	ErrUnknownPinger  = stderrors.New("unknown pinger id")
	ErrStoppedWatcher = stderrors.New("watcher has been stopped")
	ErrBadRequest     = stderrors.New("invalid request")
)

Functions

func IsNoAddressSetError

func IsNoAddressSetError(err error) bool

func NoAddressSetError

func NoAddressSetError(unitTag, addressName string) error

func NotSupportedError

func NotSupportedError(entity, operation string) error

func ServerError

func ServerError(err error) *params.Error

ServerError returns an error suitable for returning to an API client, with an error code suitable for various kinds of errors generated in packages outside the API.

Types

type APIAddresser

type APIAddresser struct {
	// contains filtered or unexported fields
}

APIAddresser implements the APIAddresses method

func NewAPIAddresser

func NewAPIAddresser(getter AddressAndCertGetter) *APIAddresser

NewAPIAddresser returns a new APIAddresser that uses the given getter to fetch its addresses.

func (*APIAddresser) APIAddresses

func (a *APIAddresser) APIAddresses() (params.StringsResult, error)

APIAddresses returns the list of addresses used to connect to the API.

type AddressAndCertGetter

type AddressAndCertGetter interface {
	Addresses() ([]string, error)
	APIAddresses() ([]string, error)
	CACert() []byte
}

AddressAndCertGetter can be used to find out state server addresses and the CA public certificate.

type AgentEntityWatcher

type AgentEntityWatcher struct {
	// contains filtered or unexported fields
}

AgentEntityWatcher implements a common Watch method for use by various facades.

func NewAgentEntityWatcher

func NewAgentEntityWatcher(st state.EntityFinder, resources *Resources, getCanWatch GetAuthFunc) *AgentEntityWatcher

NewAgentEntityWatcher returns a new AgentEntityWatcher. The GetAuthFunc will be used on each invocation of Watch to determine current permissions.

func (*AgentEntityWatcher) Watch

Watch starts an NotifyWatcher for each given entity.

type AuthFunc

type AuthFunc func(tag string) bool

AuthFunc returns whether the given entity is available to some operation.

type Authorizer

type Authorizer interface {
	// AuthMachineAgent returns whether the authenticated entity is a
	// machine agent.
	AuthMachineAgent() bool

	// AuthUnitAgent returns whether the authenticated entity is a
	// unit agent.
	AuthUnitAgent() bool

	// AuthOwner returns whether the authenticated entity is the same
	// as the given entity.
	AuthOwner(tag string) bool

	// AuthEnvironManager returns whether the authenticated entity is
	// a machine running the environment manager job.
	AuthEnvironManager() bool

	// AuthClient returns whether the authenticated entity
	// is a client user.
	AuthClient() bool

	// GetAuthTag returns the tag of the authenticated entity.
	GetAuthTag() string

	// GetAuthEntity returns the authenticated entity.
	GetAuthEntity() state.Entity
}

Authorizer represents a value that can be asked for authorization information on its associated authenticated entity. It is implemented by an API server to allow an API implementation to ask questions about the client that is currently connected.

type DeadEnsurer

type DeadEnsurer struct {
	// contains filtered or unexported fields
}

DeadEnsurer implements a common EnsureDead method for use by various facades.

func NewDeadEnsurer

func NewDeadEnsurer(st state.EntityFinder, getCanModify GetAuthFunc) *DeadEnsurer

NewDeadEnsurer returns a new DeadEnsurer. The GetAuthFunc will be used on each invocation of EnsureDead to determine current permissions.

func (*DeadEnsurer) EnsureDead

func (d *DeadEnsurer) EnsureDead(args params.Entities) (params.ErrorResults, error)

EnsureDead calls EnsureDead on each given entity from state. It will fail if the entity is not present. If it's Alive, nothing will happen (see state/EnsureDead() for units or machines).

type EntityFinderEnvironConfigGetter

type EntityFinderEnvironConfigGetter interface {
	state.EntityFinder
	EnvironConfig() (*config.Config, error)
}

type EnvironMachinesWatcher

type EnvironMachinesWatcher struct {
	// contains filtered or unexported fields
}

EnvironMachinesWatcher implements a common WatchEnvironMachines method for use by various facades.

func NewEnvironMachinesWatcher

func NewEnvironMachinesWatcher(st state.EnvironMachinesWatcher, resources *Resources, getCanWatch GetAuthFunc) *EnvironMachinesWatcher

NewEnvironMachinesWatcher returns a new EnvironMachinesWatcher. The GetAuthFunc will be used on each invocation of WatchUnits to determine current permissions.

func (*EnvironMachinesWatcher) WatchEnvironMachines

func (e *EnvironMachinesWatcher) WatchEnvironMachines() (params.StringsWatchResult, error)

WatchEnvironMachines returns a StringsWatcher that notifies of changes to the life cycles of the top level machines in the current environment.

type EnvironWatcher

type EnvironWatcher struct {
	// contains filtered or unexported fields
}

EnvironWatcher implements two common methods for use by various facades - WatchForEnvironConfigChanges and EnvironConfig.

func NewEnvironWatcher

func NewEnvironWatcher(st state.EnvironAccessor, resources *Resources, getCanWatch, getCanReadSecrets GetAuthFunc) *EnvironWatcher

NewEnvironWatcher returns a new EnvironWatcher. Active watchers will be stored in the provided Resources. The two GetAuthFunc callbacks will be used on each invocation of the methods to determine current permissions. Right now, environment tags are not used, so both created AuthFuncs are called with "" for tag, which means "the current environment".

func (*EnvironWatcher) EnvironConfig

func (e *EnvironWatcher) EnvironConfig() (params.EnvironConfigResult, error)

EnvironConfig returns the current environment's configuration.

func (*EnvironWatcher) WatchForEnvironConfigChanges

func (e *EnvironWatcher) WatchForEnvironConfigChanges() (params.NotifyWatchResult, error)

WatchForEnvironConfigChanges returns a NotifyWatcher that observes changes to the environment configuration.

type GetAuthFunc

type GetAuthFunc func() (AuthFunc, error)

GetAuthFunc returns an AuthFunc.

func AuthAlways

func AuthAlways(ok bool) GetAuthFunc

AuthAlways returns an authentication function that always returns the given permission.

func AuthEither

func AuthEither(a, b GetAuthFunc) GetAuthFunc

AuthEither returns an AuthFunc generator that returns and AuthFunc that accepts any tag authorized by either of its arguments.

type InstanceIdGetter

type InstanceIdGetter struct {
	// contains filtered or unexported fields
}

InstanceIdGetter implements a common InstanceId method for use by various facades.

func NewInstanceIdGetter

func NewInstanceIdGetter(st state.EntityFinder, getCanRead GetAuthFunc) *InstanceIdGetter

NewInstanceIdGetter returns a new InstanceIdGetter. The GetAuthFunc will be used on each invocation of InstanceId to determine current permissions.

func (*InstanceIdGetter) InstanceId

func (ig *InstanceIdGetter) InstanceId(args params.Entities) (params.StringResults, error)

InstanceId returns the provider specific instance id for each given machine or an CodeNotProvisioned error, if not set.

type LifeGetter

type LifeGetter struct {
	// contains filtered or unexported fields
}

LifeGetter implements a common Life method for use by various facades.

func NewLifeGetter

func NewLifeGetter(st state.EntityFinder, getCanRead GetAuthFunc) *LifeGetter

NewLifeGetter returns a new LifeGetter. The GetAuthFunc will be used on each invocation of Life to determine current permissions.

func (*LifeGetter) Life

func (lg *LifeGetter) Life(args params.Entities) (params.LifeResults, error)

Life returns the life status of every supplied entity, where available.

type PasswordChanger

type PasswordChanger struct {
	// contains filtered or unexported fields
}

PasswordChanger implements a common SetPasswords method for use by various facades.

func NewPasswordChanger

func NewPasswordChanger(st state.EntityFinder, getCanChange GetAuthFunc) *PasswordChanger

NewPasswordChanger returns a new PasswordChanger. The GetAuthFunc will be used on each invocation of SetPasswords to determine current permissions.

func (*PasswordChanger) SetPasswords

func (pc *PasswordChanger) SetPasswords(args params.PasswordChanges) (params.ErrorResults, error)

SetPasswords sets the given password for each supplied entity, if possible.

type Remover

type Remover struct {
	// contains filtered or unexported fields
}

Remover implements a common Remove method for use by various facades.

func NewRemover

func NewRemover(st state.EntityFinder, callEnsureDead bool, getCanModify GetAuthFunc) *Remover

NewRemover returns a new Remover. The callEnsureDead flag specifies whether EnsureDead should be called on an entity before removing. The GetAuthFunc will be used on each invocation of Remove to determine current permissions.

func (*Remover) Remove

func (r *Remover) Remove(args params.Entities) (params.ErrorResults, error)

Remove removes every given entity from state, calling EnsureDead first, then Remove. It will fail if the entity is not present.

type Resource

type Resource interface {
	Stop() error
}

Resource represents any resource that should be cleaned up when an API connection terminates. The Stop method will be called when that happens.

type Resources

type Resources struct {
	// contains filtered or unexported fields
}

Resources holds all the resources for a connection. It allows the registration of resources that will be cleaned up when a connection terminates.

func NewResources

func NewResources() *Resources

func (*Resources) Count

func (rs *Resources) Count() int

Count returns the number of resources currently held.

func (*Resources) Get

func (rs *Resources) Get(id string) Resource

Get returns the resource for the given id, or nil if there is no such resource.

func (*Resources) Register

func (rs *Resources) Register(r Resource) string

Register registers the given resource. It returns a unique identifier for the resource which can then be used in subsequent API requests to refer to the resource.

func (*Resources) Stop

func (rs *Resources) Stop(id string) error

Stop stops the resource with the given id and unregisters it. It returns any error from the underlying Stop call. It does not return an error if the resource has already been unregistered.

func (*Resources) StopAll

func (rs *Resources) StopAll()

StopAll stops all the resources.

type StateAddresser

type StateAddresser struct {
	// contains filtered or unexported fields
}

StateAddresser implements a common set of methods for getting state server addresses, and the CA certificate used to authenticate them.

func NewStateAddresser

func NewStateAddresser(getter AddressAndCertGetter) *StateAddresser

NewAddresser returns a new StateAddresser that uses the given st value to fetch its addresses.

func (*StateAddresser) CACert

func (a *StateAddresser) CACert() params.BytesResult

CACert returns the certificate used to validate the state connection. Note: there is an open bug that Uniter (which uses only APIAddresser) should add CACert to its interface. When it does, this API si likely to move to APIAddresser instead of StateAddresser. (All other users of StateAddresser already also expose APIAddresser)

func (*StateAddresser) StateAddresses

func (a *StateAddresser) StateAddresses() (params.StringsResult, error)

StateAddresses returns the list of addresses used to connect to the state.

type StatusSetter

type StatusSetter struct {
	// contains filtered or unexported fields
}

StatusSetter implements a common SetStatus method for use by various facades.

func NewStatusSetter

func NewStatusSetter(st state.EntityFinder, getCanModify GetAuthFunc) *StatusSetter

NewStatusSetter returns a new StatusSetter. The GetAuthFunc will be used on each invocation of SetStatus to determine current permissions.

func (*StatusSetter) SetStatus

func (s *StatusSetter) SetStatus(args params.SetStatus) (params.ErrorResults, error)

SetStatus sets the status of each given entity.

type ToolsGetter

type ToolsGetter struct {
	// contains filtered or unexported fields
}

ToolsGetter implements a common Tools method for use by various facades.

func NewToolsGetter

func NewToolsGetter(st EntityFinderEnvironConfigGetter, getCanRead GetAuthFunc) *ToolsGetter

NewToolsGetter returns a new ToolsGetter. The GetAuthFunc will be used on each invocation of Tools to determine current permissions.

func (*ToolsGetter) Tools

func (t *ToolsGetter) Tools(args params.Entities) (params.ToolsResults, error)

Tools finds the tools necessary for the given agents.

type ToolsSetter

type ToolsSetter struct {
	// contains filtered or unexported fields
}

ToolsSetter implements a common Tools method for use by various facades.

func NewToolsSetter

func NewToolsSetter(st state.EntityFinder, getCanWrite GetAuthFunc) *ToolsSetter

NewToolsGetter returns a new ToolsGetter. The GetAuthFunc will be used on each invocation of Tools to determine current permissions.

func (*ToolsSetter) SetTools

SetTools updates the recorded tools version for the agents.

type UnitsWatcher

type UnitsWatcher struct {
	// contains filtered or unexported fields
}

UnitsWatcher implements a common WatchUnits method for use by various facades.

func NewUnitsWatcher

func NewUnitsWatcher(st state.EntityFinder, resources *Resources, getCanWatch GetAuthFunc) *UnitsWatcher

NewUnitsWatcher returns a new UnitsWatcher. The GetAuthFunc will be used on each invocation of WatchUnits to determine current permissions.

func (*UnitsWatcher) WatchUnits

WatchUnits starts a StringsWatcher to watch all units belonging to to any entity (machine or service) passed in args.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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