Documentation ¶
Overview ¶
The state package enables reading, observing, and changing the state stored in MongoDB of a whole environment managed by juju.
Index ¶
- Constants
- Variables
- func ContainerTypeFromId(machineId string) instance.ContainerType
- func IsCharmAlreadyUploadedError(err interface{}) bool
- func IsHasAssignedUnitsError(err error) bool
- func IsHasContainersError(err error) bool
- func IsNotAssigned(err error) bool
- func IsNotProvisionedError(err error) bool
- func IsVersionInconsistentError(e interface{}) bool
- func NestingLevel(machineId string) int
- func NotProvisionedError(machineId string) error
- func ParentId(machineId string) string
- func TopParentId(machineId string) string
- type AgentEntity
- type AgentLiving
- type AgentTooler
- type Annotator
- type AssignmentPolicy
- type Authenticator
- type Charm
- func (c *Charm) BundleSha256() string
- func (c *Charm) BundleURL() *url.URL
- func (c *Charm) Config() *charm.Config
- func (c *Charm) IsPlaceholder() bool
- func (c *Charm) IsUploaded() bool
- func (c *Charm) Meta() *charm.Meta
- func (c *Charm) Revision() int
- func (c *Charm) String() string
- func (c *Charm) URL() *charm.URL
- type D
- type DeployerConnectionValues
- type DialOpts
- type Endpoint
- type EnsureDeader
- type Entity
- type EntityFinder
- type EnvironAccessor
- type EnvironConfigWatcher
- type EnvironMachinesWatcher
- type Environment
- func (a *Environment) Annotation(key string) (string, error)
- func (a *Environment) Annotations() (map[string]string, error)
- func (e *Environment) Destroy() error
- func (e *Environment) Life() Life
- func (e *Environment) Name() string
- func (e *Environment) Refresh() error
- func (a *Environment) SetAnnotations(pairs map[string]string) (err error)
- func (e *Environment) Tag() string
- func (e *Environment) UUID() string
- func (e *Environment) Watch() NotifyWatcher
- type ErrCharmAlreadyUploaded
- type HasAssignedUnitsError
- type HasContainersError
- type Info
- type InstanceIdGetter
- type ItemChange
- type Life
- type Lifer
- type Living
- type Machine
- func (m *Machine) Addresses() (addresses []instance.Address)
- func (m *Machine) AgentAlive() (bool, error)
- func (m *Machine) AgentTools() (*tools.Tools, error)
- func (a *Machine) Annotation(key string) (string, error)
- func (a *Machine) Annotations() (map[string]string, error)
- func (m *Machine) CheckProvisioned(nonce string) bool
- func (m *Machine) Clean() bool
- func (m *Machine) Constraints() (constraints.Value, error)
- func (m *Machine) ContainerType() instance.ContainerType
- func (m *Machine) Containers() ([]string, error)
- func (m *Machine) Destroy() error
- func (m *Machine) EnsureDead() error
- func (m *Machine) ForceDestroy() error
- func (m *Machine) HardwareCharacteristics() (*instance.HardwareCharacteristics, error)
- func (m *Machine) HasVote() bool
- func (m *Machine) Id() string
- func (m *Machine) InstanceId() (instance.Id, error)
- func (m *Machine) InstanceStatus() (string, error)
- func (m *Machine) IsManager() bool
- func (m *Machine) IsManual() (bool, error)
- func (m *Machine) Jobs() []MachineJob
- func (m *Machine) Life() Life
- func (m *Machine) MachineAddresses() (addresses []instance.Address)
- func (m *Machine) ParentId() (string, bool)
- func (m *Machine) PasswordValid(password string) bool
- func (m *Machine) Refresh() error
- func (m *Machine) Remove() (err error)
- func (m *Machine) Series() string
- func (m *Machine) SetAddresses(addresses []instance.Address) (err error)
- func (m *Machine) SetAgentAlive() (*presence.Pinger, error)
- func (m *Machine) SetAgentVersion(v version.Binary) (err error)
- func (a *Machine) SetAnnotations(pairs map[string]string) (err error)
- func (m *Machine) SetConstraints(cons constraints.Value) (err error)
- func (m *Machine) SetHasVote(hasVote bool) error
- func (m *Machine) SetInstanceStatus(status string) (err error)
- func (m *Machine) SetMachineAddresses(addresses []instance.Address) (err error)
- func (m *Machine) SetMongoPassword(password string) error
- func (m *Machine) SetPassword(password string) error
- func (m *Machine) SetProvisioned(id instance.Id, nonce string, ...) (err error)
- func (m *Machine) SetStatus(status params.Status, info string, data params.StatusData) error
- func (m *Machine) SetSupportedContainers(containers []instance.ContainerType) (err error)
- func (m *Machine) Status() (status params.Status, info string, data params.StatusData, err error)
- func (m *Machine) String() string
- func (m *Machine) SupportedContainers() ([]instance.ContainerType, bool)
- func (m *Machine) SupportsNoContainers() (err error)
- func (m *Machine) Tag() string
- func (m *Machine) Units() (units []*Unit, err error)
- func (m *Machine) WaitAgentAlive(timeout time.Duration) (err error)
- func (m *Machine) WantsVote() bool
- func (m *Machine) Watch() NotifyWatcher
- func (m *Machine) WatchAllContainers() StringsWatcher
- func (m *Machine) WatchContainers(ctype instance.ContainerType) StringsWatcher
- func (m *Machine) WatchHardwareCharacteristics() NotifyWatcher
- func (m *Machine) WatchPrincipalUnits() StringsWatcher
- func (m *Machine) WatchUnits() StringsWatcher
- type MachineJob
- type MachineTemplate
- type MongoPassworder
- type NotAssignedError
- type NotifyWatcher
- type NotifyWatcherFactory
- type Policy
- type Prechecker
- type Relation
- func (r *Relation) Destroy() (err error)
- func (r *Relation) Endpoint(serviceName string) (Endpoint, error)
- func (r *Relation) Id() int
- func (r *Relation) Life() Life
- func (r *Relation) Refresh() error
- func (r *Relation) RelatedEndpoints(serviceName string) ([]Endpoint, error)
- func (r *Relation) String() string
- func (r *Relation) Tag() string
- func (r *Relation) Unit(u *Unit) (*RelationUnit, error)
- type RelationScopeChange
- type RelationScopeWatcher
- type RelationUnit
- func (ru *RelationUnit) Endpoint() Endpoint
- func (ru *RelationUnit) EnterScope(settings map[string]interface{}) error
- func (ru *RelationUnit) InScope() (bool, error)
- func (ru *RelationUnit) LeaveScope() error
- func (ru *RelationUnit) PrivateAddress() (string, bool)
- func (ru *RelationUnit) ReadSettings(uname string) (m map[string]interface{}, err error)
- func (ru *RelationUnit) Relation() *Relation
- func (ru *RelationUnit) Settings() (*Settings, error)
- func (ru *RelationUnit) Watch() RelationUnitsWatcher
- func (ru *RelationUnit) WatchScope() *RelationScopeWatcher
- type RelationUnitsWatcher
- type Remover
- type ResolvedMode
- type Service
- func (s *Service) AddUnit() (unit *Unit, err error)
- func (s *Service) AllUnits() (units []*Unit, err error)
- func (a *Service) Annotation(key string) (string, error)
- func (a *Service) Annotations() (map[string]string, error)
- func (s *Service) Charm() (ch *Charm, force bool, err error)
- func (s *Service) CharmURL() (curl *charm.URL, force bool)
- func (s *Service) ClearExposed() error
- func (s *Service) ConfigSettings() (charm.Settings, error)
- func (s *Service) Constraints() (constraints.Value, error)
- func (s *Service) Destroy() (err error)
- func (s *Service) Endpoint(relationName string) (Endpoint, error)
- func (s *Service) Endpoints() (eps []Endpoint, err error)
- func (s *Service) EnsureMinUnits() (err error)
- func (s *Service) GetOwnerTag() string
- func (s *Service) IsExposed() bool
- func (s *Service) IsPrincipal() bool
- func (s *Service) Life() Life
- func (s *Service) MinUnits() int
- func (s *Service) Name() string
- func (s *Service) Refresh() error
- func (s *Service) Relations() (relations []*Relation, err error)
- func (a *Service) SetAnnotations(pairs map[string]string) (err error)
- func (s *Service) SetCharm(ch *Charm, force bool) (err error)
- func (s *Service) SetConstraints(cons constraints.Value) (err error)
- func (s *Service) SetExposed() error
- func (s *Service) SetMinUnits(minUnits int) (err error)
- func (s *Service) String() string
- func (s *Service) Tag() string
- func (s *Service) Unit(name string) (*Unit, error)
- func (s *Service) UpdateConfigSettings(changes charm.Settings) error
- func (s *Service) Watch() NotifyWatcher
- func (s *Service) WatchRelations() StringsWatcher
- func (s *Service) WatchUnits() StringsWatcher
- type Settings
- func (c *Settings) Delete(key string)
- func (c *Settings) Get(key string) (value interface{}, found bool)
- func (c *Settings) Keys() []string
- func (c *Settings) Map() map[string]interface{}
- func (c *Settings) Read() error
- func (c *Settings) Set(key string, value interface{})
- func (c *Settings) Update(kv map[string]interface{})
- func (c *Settings) Write() ([]ItemChange, error)
- type State
- func (st *State) APIAddresses() ([]string, error)
- func (st *State) AddCharm(ch charm.Charm, curl *charm.URL, bundleURL *url.URL, bundleSha256 string) (stch *Charm, err error)
- func (st *State) AddMachine(series string, jobs ...MachineJob) (*Machine, error)
- func (st *State) AddMachineInsideMachine(template MachineTemplate, parentId string, ...) (*Machine, error)
- func (st *State) AddMachineInsideNewMachine(template, parentTemplate MachineTemplate, containerType instance.ContainerType) (*Machine, error)
- func (st *State) AddMachines(templates ...MachineTemplate) (_ []*Machine, err error)
- func (st *State) AddOneMachine(template MachineTemplate) (*Machine, error)
- func (st *State) AddRelation(eps ...Endpoint) (r *Relation, err error)
- func (st *State) AddService(name, ownerTag string, ch *Charm) (service *Service, err error)
- func (st *State) AddStoreCharmPlaceholder(curl *charm.URL) (err error)
- func (st *State) AddUser(name, password string) (*User, error)
- func (st *State) Addresses() ([]string, error)
- func (st *State) AllMachines() (machines []*Machine, err error)
- func (st *State) AllServices() (services []*Service, err error)
- func (st *State) AssignUnit(u *Unit, policy AssignmentPolicy) (err error)
- func (st *State) CACert() (cert []byte)
- func (st *State) Charm(curl *charm.URL) (*Charm, error)
- func (st *State) Cleanup() error
- func (st *State) Close() error
- func (st *State) DeployerConnectionInfo() (*DeployerConnectionValues, error)
- func (st *State) EndpointsRelation(endpoints ...Endpoint) (*Relation, error)
- func (st *State) EnsureAvailability(numStateServers int, cons constraints.Value, series string) error
- func (st *State) EnvironConfig() (*config.Config, error)
- func (st *State) EnvironConstraints() (constraints.Value, error)
- func (st *State) Environment() (*Environment, error)
- func (st *State) FindEntity(tag string) (Entity, error)
- func (st *State) InferEndpoints(names []string) ([]Endpoint, error)
- func (st *State) KeyRelation(key string) (*Relation, error)
- func (st *State) LatestPlaceholderCharm(curl *charm.URL) (*Charm, error)
- func (st *State) Machine(id string) (*Machine, error)
- func (st *State) MongoSession() *mgo.Session
- func (st *State) NeedsCleanup() (bool, error)
- func (st *State) Ping() error
- func (st *State) PrepareLocalCharmUpload(curl *charm.URL) (chosenUrl *charm.URL, err error)
- func (st *State) PrepareStoreCharmUpload(curl *charm.URL) (*Charm, error)
- func (st *State) Relation(id int) (*Relation, error)
- func (st *State) ResumeTransactions() error
- func (st *State) Service(name string) (service *Service, err error)
- func (st *State) SetAdminMongoPassword(password string) error
- func (st *State) SetEnvironAgentVersion(newVersion version.Number) error
- func (st *State) SetEnvironConfig(cfg, old *config.Config) error
- func (st *State) SetEnvironConstraints(cons constraints.Value) error
- func (st *State) StartSync()
- func (st *State) StateServerInfo() (*StateServerInfo, error)
- func (st *State) Unit(name string) (*Unit, error)
- func (st *State) UpdateUploadedCharm(ch charm.Charm, curl *charm.URL, bundleURL *url.URL, bundleSha256 string) (*Charm, error)
- func (st *State) User(name string) (*User, error)
- func (st *State) Watch() *multiwatcher.Watcher
- func (st *State) WatchCleanups() NotifyWatcher
- func (s *State) WatchEnvironConfig() *EnvironConfigWatcher
- func (st *State) WatchEnvironMachines() StringsWatcher
- func (st *State) WatchForEnvironConfigChanges() NotifyWatcher
- func (st *State) WatchMinUnits() StringsWatcher
- func (st *State) WatchServices() StringsWatcher
- func (st *State) WatchStateServerInfo() NotifyWatcher
- type StateServerInfo
- type StatusSetter
- type StringsWatcher
- type Unit
- func (u *Unit) AgentAlive() (bool, error)
- func (u *Unit) AgentTools() (*tools.Tools, error)
- func (a *Unit) Annotation(key string) (string, error)
- func (a *Unit) Annotations() (map[string]string, error)
- func (u *Unit) AssignToCleanEmptyMachine() (m *Machine, err error)
- func (u *Unit) AssignToCleanMachine() (m *Machine, err error)
- func (u *Unit) AssignToMachine(m *Machine) (err error)
- func (u *Unit) AssignToNewMachine() (err error)
- func (u *Unit) AssignToNewMachineOrContainer() (err error)
- func (u *Unit) AssignedMachineId() (id string, err error)
- func (u *Unit) CharmURL() (*charm.URL, bool)
- func (u *Unit) ClearResolved() error
- func (u *Unit) ClosePort(protocol string, number int) (err error)
- func (u *Unit) ConfigSettings() (charm.Settings, error)
- func (u *Unit) DeployerTag() (string, bool)
- func (u *Unit) Destroy() (err error)
- func (u *Unit) EnsureDead() (err error)
- func (u *Unit) IsPrincipal() bool
- func (u *Unit) Life() Life
- func (u *Unit) Name() string
- func (u *Unit) OpenPort(protocol string, number int) (err error)
- func (u *Unit) OpenedPorts() []instance.Port
- func (u *Unit) PasswordValid(password string) bool
- func (u *Unit) PrincipalName() (string, bool)
- func (u *Unit) PrivateAddress() (string, bool)
- func (u *Unit) PublicAddress() (string, bool)
- func (u *Unit) Refresh() error
- func (u *Unit) Remove() (err error)
- func (u *Unit) Resolve(retryHooks bool) error
- func (u *Unit) Resolved() ResolvedMode
- func (u *Unit) Series() string
- func (u *Unit) Service() (*Service, error)
- func (u *Unit) ServiceName() string
- func (u *Unit) SetAgentAlive() (*presence.Pinger, error)
- func (u *Unit) SetAgentVersion(v version.Binary) (err error)
- func (a *Unit) SetAnnotations(pairs map[string]string) (err error)
- func (u *Unit) SetCharmURL(curl *charm.URL) (err error)
- func (u *Unit) SetMongoPassword(password string) error
- func (u *Unit) SetPassword(password string) error
- func (u *Unit) SetPrivateAddress(address string) error
- func (u *Unit) SetPublicAddress(address string) (err error)
- func (u *Unit) SetResolved(mode ResolvedMode) (err error)
- func (u *Unit) SetStatus(status params.Status, info string, data params.StatusData) error
- func (u *Unit) Status() (status params.Status, info string, data params.StatusData, err error)
- func (u *Unit) String() string
- func (u *Unit) SubordinateNames() []string
- func (u *Unit) Tag() string
- func (u *Unit) UnassignFromMachine() (err error)
- func (u *Unit) WaitAgentAlive(timeout time.Duration) (err error)
- func (u *Unit) Watch() NotifyWatcher
- func (u *Unit) WatchConfigSettings() (NotifyWatcher, error)
- func (u *Unit) WatchSubordinateUnits() StringsWatcher
- type UnitsWatcher
- type User
- type Watcher
Constants ¶
const ( ItemAdded = iota ItemModified ItemDeleted )
const BootstrapNonce = "user-admin:bootstrap"
BootstrapNonce is used as a nonce for the state server machine.
Variables ¶
var ErrCannotEnterScope = stderrors.New("cannot enter scope: unit or relation is not alive")
ErrCannotEnterScope indicates that a relation unit failed to enter its scope due to either the unit or the relation not being Alive.
var ErrCannotEnterScopeYet = stderrors.New("cannot enter scope yet: non-alive subordinate unit has not been removed")
ErrCannotEnterScopeYet indicates that a relation unit failed to enter its scope due to a required and pre-existing subordinate unit that is not Alive. Once that subordinate has been removed, a new one can be created.
var ErrCharmRevisionAlreadyModified = fmt.Errorf("charm revision already modified")
ErrCharmRevisionAlreadyModified is returned when a pending or placeholder charm is no longer pending or a placeholder, signaling the charm is available in state with its full information.
var ErrExcessiveContention = stderrors.New("state changing too quickly; try again soon")
var ErrStateClosed = fmt.Errorf("state has been closed")
ErrStateClosed is returned from watchers if their underlying state connection has been closed.
var ErrSubordinateConstraints = stderrors.New("constraints do not apply to subordinate services")
var ErrUnitHasSubordinates = stderrors.New("unit has subordinates")
Functions ¶
func ContainerTypeFromId ¶
func ContainerTypeFromId(machineId string) instance.ContainerType
ContainerTypeFromId returns the container type if machineId is a container id, or "" if machineId is not for a container.
func IsCharmAlreadyUploadedError ¶
func IsCharmAlreadyUploadedError(err interface{}) bool
IsCharmAlreadyUploadedError returns if the given error is ErrCharmAlreadyUploaded.
func IsHasAssignedUnitsError ¶
func IsHasContainersError ¶
func IsNotAssigned ¶
func IsNotProvisionedError ¶
IsNotProvisionedError returns true if err is a notProvisionedError.
func IsVersionInconsistentError ¶
func IsVersionInconsistentError(e interface{}) bool
IsVersionInconsistentError returns if the given error is versionInconsistentError.
func NestingLevel ¶
NestingLevel returns how many levels of nesting exist for a machine id.
func NotProvisionedError ¶
func ParentId ¶
ParentId returns the id of the host machine if machineId a container id, or "" if machineId is not for a container.
func TopParentId ¶
TopParentId returns the id of the top level host machine for a container id.
Types ¶
type AgentEntity ¶
type AgentEntity interface { Entity Lifer Authenticator MongoPassworder AgentTooler StatusSetter EnsureDeader Remover NotifyWatcherFactory }
AgentEntity represents an entity that can have an agent responsible for it.
type AgentLiving ¶
AgentLiving describes state entities with a lifecycle and an agent that manages it.
type AgentTooler ¶
type AgentTooler interface { AgentTools() (*tools.Tools, error) SetAgentVersion(version.Binary) error }
AgentTooler is implemented by entities that have associated agent tools.
type Annotator ¶
type Annotator interface { Annotation(key string) (string, error) Annotations() (map[string]string, error) SetAnnotations(pairs map[string]string) error }
Annotator represents entities capable of handling annotations.
type AssignmentPolicy ¶
type AssignmentPolicy string
AssignmentPolicy controls what machine a unit will be assigned to.
const ( // AssignLocal indicates that all service units should be assigned // to machine 0. AssignLocal AssignmentPolicy = "local" // AssignClean indicates that every service unit should be assigned // to a machine which never previously has hosted any units, and that // new machines should be launched if required. AssignClean AssignmentPolicy = "clean" // AssignCleanEmpty indicates that every service unit should be assigned // to a machine which never previously has hosted any units, and which is not // currently hosting any containers, and that new machines should be launched if required. AssignCleanEmpty AssignmentPolicy = "clean-empty" // AssignNew indicates that every service unit should be assigned to a new // dedicated machine. A new machine will be launched for each new unit. AssignNew AssignmentPolicy = "new" )
type Authenticator ¶
type Authenticator interface { Refresh() error SetPassword(pass string) error PasswordValid(pass string) bool }
Authenticator represents entites capable of handling password authentication.
type Charm ¶
type Charm struct {
// contains filtered or unexported fields
}
Charm represents the state of a charm in the environment.
func (*Charm) BundleSha256 ¶
BundleSha256 returns the SHA256 digest of the charm bundle bytes.
func (*Charm) IsPlaceholder ¶
IsPlaceholder returns whether the charm record is just a placeholder rather than representing a deployed charm.
func (*Charm) IsUploaded ¶
IsUploaded returns whether the charm has been uploaded to the provider storage.
type DialOpts ¶
type DialOpts struct { // Timeout is the amount of time to wait contacting // a state server. Timeout time.Duration }
DialOpts holds configuration parameters that control the Dialing behavior when connecting to a state server.
func DefaultDialOpts ¶
func DefaultDialOpts() DialOpts
DefaultDialOpts returns a DialOpts representing the default parameters for contacting a state server.
type Endpoint ¶
Endpoint represents one endpoint of a relation.
func (Endpoint) CanRelateTo ¶
CanRelateTo returns whether a relation may be established between e and other.
type EnsureDeader ¶
type EnsureDeader interface {
EnsureDead() error
}
EnsureDeader with an EnsureDead method.
type Entity ¶
type Entity interface {
Tag() string
}
Entity represents any entity that can be returned by State.FindEntity. All entities have a tag.
type EntityFinder ¶
EntityFinder is implemented by *State. See State.FindEntity for documentation on the method.
type EnvironAccessor ¶
type EnvironAccessor interface { WatchForEnvironConfigChanges() NotifyWatcher EnvironConfig() (*config.Config, error) }
EnvironAccessor defines the methods needed to watch for environment config changes, and read the environment config.
type EnvironConfigWatcher ¶
type EnvironConfigWatcher struct {
// contains filtered or unexported fields
}
EnvironConfigWatcher observes changes to the environment configuration.
func (*EnvironConfigWatcher) Changes ¶
func (w *EnvironConfigWatcher) Changes() <-chan *config.Config
Changes returns a channel that will receive the new environment configuration when a change is detected. Note that multiple changes may be observed as a single event in the channel.
func (*EnvironConfigWatcher) Err ¶
func (w *EnvironConfigWatcher) Err() error
Err returns any error encountered while running or shutting down, or tomb.ErrStillAlive if the watcher is still running.
func (*EnvironConfigWatcher) Kill ¶
func (w *EnvironConfigWatcher) Kill()
Kill kills the watcher without waiting for it to shut down.
type EnvironMachinesWatcher ¶
type EnvironMachinesWatcher interface {
WatchEnvironMachines() StringsWatcher
}
EnvironMachinesWatcher defines a single method - WatchEnvironMachines.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment represents the state of an environment.
func (*Environment) Annotation ¶
Annotation returns the annotation value corresponding to the given key. If the requested annotation is not found, an empty string is returned.
func (*Environment) Annotations ¶
Annotations returns all the annotations corresponding to an entity.
func (*Environment) Destroy ¶
func (e *Environment) Destroy() error
Destroy sets the environment's lifecycle to Dying, preventing addition of services or machines to state.
func (*Environment) Life ¶
func (e *Environment) Life() Life
Life returns whether the environment is Alive, Dying or Dead.
func (*Environment) Name ¶
func (e *Environment) Name() string
Name returns the human friendly name of the environment.
func (*Environment) Refresh ¶
func (e *Environment) Refresh() error
func (*Environment) SetAnnotations ¶
SetAnnotations adds key/value pairs to annotations in MongoDB.
func (*Environment) Tag ¶
func (e *Environment) Tag() string
Tag returns a name identifying the environment. The returned name will be different from other Tag values returned by any other entities from the same state.
func (*Environment) UUID ¶
func (e *Environment) UUID() string
UUID returns the universally unique identifier of the environment.
func (*Environment) Watch ¶
func (e *Environment) Watch() NotifyWatcher
Watch returns a watcher for observing changes to an environment.
type ErrCharmAlreadyUploaded ¶
type ErrCharmAlreadyUploaded struct {
// contains filtered or unexported fields
}
ErrCharmAlreadyUploaded is returned by UpdateUploadedCharm() when the given charm is already uploaded and marked as not pending in state.
func (*ErrCharmAlreadyUploaded) Error ¶
func (e *ErrCharmAlreadyUploaded) Error() string
type HasAssignedUnitsError ¶
func (*HasAssignedUnitsError) Error ¶
func (e *HasAssignedUnitsError) Error() string
type HasContainersError ¶
func (*HasContainersError) Error ¶
func (e *HasContainersError) Error() string
type Info ¶
type Info struct { // Addrs gives the addresses of the MongoDB servers for the state. // Each address should be in the form address:port. Addrs []string // CACert holds the CA certificate that will be used // to validate the state server's certificate, in PEM format. CACert []byte // Tag holds the name of the entity that is connecting. // It should be empty when connecting as an administrator. Tag string // Password holds the password for the connecting entity. Password string }
Info encapsulates information about cluster of servers holding juju state and can be used to make a connection to that cluster.
type InstanceIdGetter ¶
InstanceIdGetter defines a single method - InstanceId.
type ItemChange ¶
ItemChange represents the change of an item in a settings.
func (*ItemChange) String ¶
func (ic *ItemChange) String() string
String returns the item change in a readable format.
type Life ¶
type Life int8
Life represents the lifecycle state of the entities Relation, Unit, Service and Machine.
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine represents the state of a machine.
func (*Machine) Addresses ¶
Addresses returns any hostnames and ips associated with a machine, determined both by the machine itself, and by asking the provider.
The addresses returned by the provider shadow any of the addresses that the machine reported with the same address value.
func (*Machine) AgentAlive ¶
AgentAlive returns whether the respective remote agent is alive.
func (*Machine) AgentTools ¶
AgentTools returns the tools that the agent is currently running. It returns an error that satisfies IsNotFound if the tools have not yet been set.
func (*Machine) Annotation ¶
Annotation returns the annotation value corresponding to the given key. If the requested annotation is not found, an empty string is returned.
func (*Machine) Annotations ¶
Annotations returns all the annotations corresponding to an entity.
func (*Machine) CheckProvisioned ¶
CheckProvisioned returns true if the machine was provisioned with the given nonce.
func (*Machine) Clean ¶
Clean returns true if the machine does not have any deployed units or containers.
func (*Machine) Constraints ¶
func (m *Machine) Constraints() (constraints.Value, error)
Constraints returns the exact constraints that should apply when provisioning an instance for the machine.
func (*Machine) ContainerType ¶
func (m *Machine) ContainerType() instance.ContainerType
ContainerType returns the type of container hosting this machine.
func (*Machine) Containers ¶
Containers returns the container ids belonging to a parent machine. TODO(wallyworld): move this method to a service
func (*Machine) Destroy ¶
Destroy sets the machine lifecycle to Dying if it is Alive. It does nothing otherwise. Destroy will fail if the machine has principal units assigned, or if the machine has JobManageEnviron. If the machine has assigned units, Destroy will return a HasAssignedUnitsError.
func (*Machine) EnsureDead ¶
EnsureDead sets the machine lifecycle to Dead if it is Alive or Dying. It does nothing otherwise. EnsureDead will fail if the machine has principal units assigned, or if the machine has JobManageEnviron. If the machine has assigned units, EnsureDead will return a HasAssignedUnitsError.
func (*Machine) ForceDestroy ¶
ForceDestroy queues the machine for complete removal, including the destruction of all units and containers on the machine.
func (*Machine) HardwareCharacteristics ¶
func (m *Machine) HardwareCharacteristics() (*instance.HardwareCharacteristics, error)
TODO(wallyworld): move this method to a service.
func (*Machine) HasVote ¶
HasVote reports whether that machine is currently a voting member of the replica set.
func (*Machine) InstanceId ¶
InstanceId returns the provider specific instance id for this machine, or a NotProvisionedError, if not set.
func (*Machine) InstanceStatus ¶
InstanceStatus returns the provider specific instance status for this machine, or a NotProvisionedError if instance is not yet provisioned.
func (*Machine) Jobs ¶
func (m *Machine) Jobs() []MachineJob
Jobs returns the responsibilities that must be fulfilled by m's agent.
func (*Machine) MachineAddresses ¶
MachineAddresses returns any hostnames and ips associated with a machine, determined by asking the machine itself.
func (*Machine) ParentId ¶
ParentId returns the Id of the host machine if this machine is a container.
func (*Machine) PasswordValid ¶
PasswordValid returns whether the given password is valid for the given machine.
func (*Machine) Refresh ¶
Refresh refreshes the contents of the machine from the underlying state. It returns an error that satisfies IsNotFound if the machine has been removed.
func (*Machine) Remove ¶
Remove removes the machine from state. It will fail if the machine is not Dead.
func (*Machine) SetAddresses ¶
SetAddresses records any addresses related to the machine, sourced by asking the provider.
func (*Machine) SetAgentAlive ¶
SetAgentAlive signals that the agent for machine m is alive. It returns the started pinger.
func (*Machine) SetAgentVersion ¶
SetAgentVersion sets the version of juju that the agent is currently running.
func (*Machine) SetAnnotations ¶
SetAnnotations adds key/value pairs to annotations in MongoDB.
func (*Machine) SetConstraints ¶
func (m *Machine) SetConstraints(cons constraints.Value) (err error)
SetConstraints sets the exact constraints to apply when provisioning an instance for the machine. It will fail if the machine is Dead, or if it is already provisioned.
func (*Machine) SetHasVote ¶
SetHasVote sets whether the machine is currently a voting member of the replica set. It should only be called from the worker that maintains the replica set.
func (*Machine) SetInstanceStatus ¶
SetInstanceStatus sets the provider specific instance status for a machine.
func (*Machine) SetMachineAddresses ¶
SetMachineAddresses records any addresses related to the machine, sourced by asking the machine.
func (*Machine) SetMongoPassword ¶
SetMongoPassword sets the password the agent responsible for the machine should use to communicate with the state servers. Previous passwords are invalidated.
func (*Machine) SetPassword ¶
SetPassword sets the password for the machine's agent.
func (*Machine) SetProvisioned ¶
func (m *Machine) SetProvisioned(id instance.Id, nonce string, characteristics *instance.HardwareCharacteristics) (err error)
SetProvisioned sets the provider specific machine id, nonce and also metadata for this machine. Once set, the instance id cannot be changed.
When provisioning an instance, a nonce should be created and passed when starting it, before adding the machine to the state. This means that if the provisioner crashes (or its connection to the state is lost) after starting the instance, we can be sure that only a single instance will be able to act for that machine.
func (*Machine) SetSupportedContainers ¶
func (m *Machine) SetSupportedContainers(containers []instance.ContainerType) (err error)
SetSupportedContainers sets the list of containers supported by this machine.
func (*Machine) SupportedContainers ¶
func (m *Machine) SupportedContainers() ([]instance.ContainerType, bool)
SupportedContainers returns any containers this machine is capable of hosting, and a bool indicating if the supported containers have been determined or not.
func (*Machine) SupportsNoContainers ¶
SupportsNoContainers records the fact that this machine doesn't support any containers.
func (*Machine) Tag ¶
Tag returns a name identifying the machine that is safe to use as a file name. The returned name will be different from other Tag values returned by any other entities from the same state.
func (*Machine) WaitAgentAlive ¶
WaitAgentAlive blocks until the respective agent is alive.
func (*Machine) WantsVote ¶
WantsVote reports whether the machine is a state server that wants to take part in peer voting.
func (*Machine) Watch ¶
func (m *Machine) Watch() NotifyWatcher
Watch returns a watcher for observing changes to a machine.
func (*Machine) WatchAllContainers ¶
func (m *Machine) WatchAllContainers() StringsWatcher
WatchAllContainers returns a StringsWatcher that notifies of changes to the lifecycles of all containers on a machine.
func (*Machine) WatchContainers ¶
func (m *Machine) WatchContainers(ctype instance.ContainerType) StringsWatcher
WatchContainers returns a StringsWatcher that notifies of changes to the lifecycles of containers of the specified type on a machine.
func (*Machine) WatchHardwareCharacteristics ¶
func (m *Machine) WatchHardwareCharacteristics() NotifyWatcher
WatchHardwareCharacteristics returns a watcher for observing changes to a machine's hardware characteristics.
func (*Machine) WatchPrincipalUnits ¶
func (m *Machine) WatchPrincipalUnits() StringsWatcher
WatchPrincipalUnits returns a StringsWatcher tracking the machine's principal units.
func (*Machine) WatchUnits ¶
func (m *Machine) WatchUnits() StringsWatcher
WatchUnits returns a new StringsWatcher watching m's units.
type MachineJob ¶
type MachineJob int
MachineJob values define responsibilities that machines may be expected to fulfil.
const ( JobHostUnits MachineJob JobManageEnviron // Deprecated in 1.18. JobManageStateDeprecated )
func MachineJobFromParams ¶
func MachineJobFromParams(job params.MachineJob) (MachineJob, error)
MachineJobFromParams returns the job corresponding to params.MachineJob.
func (MachineJob) String ¶
func (job MachineJob) String() string
func (MachineJob) ToParams ¶
func (job MachineJob) ToParams() params.MachineJob
ToParams returns the job as params.MachineJob.
type MachineTemplate ¶
type MachineTemplate struct { // Series is the series to be associated with the new machine. Series string // Constraints are the constraints to be used when finding // an instance for the machine. Constraints constraints.Value // Jobs holds the jobs to run on the machine's instance. // A machine must have at least one job to do. // JobManageEnviron can only be part of the jobs // when the first (bootstrap) machine is added. Jobs []MachineJob // NoVote holds whether a machine running // a state server should abstain from peer voting. // It is ignored if Jobs does not contain JobManageEnviron. NoVote bool // Addresses holds the addresses to be associated with the // new machine. Addresses []instance.Address // InstanceId holds the instance id to associate with the machine. // If this is empty, the provisioner will try to provision the machine. // If this is non-empty, the HardwareCharacteristics and Nonce // fields must be set appropriately. InstanceId instance.Id // HardwareCharacteristics holds the h/w characteristics to // be associated with the machine. HardwareCharacteristics instance.HardwareCharacteristics // Nonce holds a unique value that can be used to check // if a new instance was really started for this machine. // See Machine.SetProvisioned. This must be set if InstanceId is set. Nonce string // Dirty signifies whether the new machine will be treated // as unclean for unit-assignment purposes. Dirty bool // contains filtered or unexported fields }
MachineTemplate holds attributes that are to be associated with a newly created machine.
type MongoPassworder ¶
MongoPassworder represents an entity that can have a mongo password set for it.
type NotAssignedError ¶
type NotAssignedError struct{ Unit *Unit }
NotAssignedError indicates that a unit is not assigned to a machine (and, in the case of subordinate units, that the unit's principal is not assigned).
func (*NotAssignedError) Error ¶
func (e *NotAssignedError) Error() string
type NotifyWatcher ¶
type NotifyWatcher interface { Watcher Changes() <-chan struct{} }
NotifyWatcher generates signals when something changes, but it does not return any content for those changes
type NotifyWatcherFactory ¶
type NotifyWatcherFactory interface {
Watch() NotifyWatcher
}
NotifyWatcherFactory represents an entity that can be watched.
type Policy ¶
type Policy interface { // Prechecker takes a *config.Config and returns // a (possibly nil) Prechecker or an error. Prechecker(*config.Config) (Prechecker, error) }
Policy is an interface provided to State that may be consulted by State to validate or modify the behaviour of certain operations.
If a Policy implementation does not implement one of the methods, it must return an error that satisfies errors.IsNotImplemented, and will thus be ignored. Any other error will cause an error in the use of the policy.
type Prechecker ¶
type Prechecker interface { // PrecheckInstance performs a preflight check on the specified // series and constraints, ensuring that they are possibly valid for // creating an instance in this environment. // // PrecheckInstance is best effort, and not guaranteed to eliminate // all invalid parameters. If PrecheckInstance returns nil, it is not // guaranteed that the constraints are valid; if a non-nil error is // returned, then the constraints are definitely invalid. PrecheckInstance(series string, cons constraints.Value) error }
Prechecker is a policy interface that is provided to State to perform pre-flight checking of instance creation.
type Relation ¶
type Relation struct {
// contains filtered or unexported fields
}
Relation represents a relation between one or two service endpoints.
func (*Relation) Destroy ¶
Destroy ensures that the relation will be removed at some point; if no units are currently in scope, it will be removed immediately.
func (*Relation) Endpoint ¶
Endpoint returns the endpoint of the relation for the named service. If the service is not part of the relation, an error will be returned.
func (*Relation) Id ¶
Id returns the integer internal relation key. This is exposed because the unit agent needs to expose a value derived from this (as JUJU_RELATION_ID) to allow relation hooks to differentiate between relations with different services.
func (*Relation) Refresh ¶
Refresh refreshes the contents of the relation from the underlying state. It returns an error that satisfies IsNotFound if the relation has been removed.
func (*Relation) RelatedEndpoints ¶
RelatedEndpoints returns the endpoints of the relation r with which units of the named service will establish relations. If the service is not part of the relation r, an error will be returned.
type RelationScopeChange ¶
RelationScopeChange contains information about units that have entered or left a particular scope.
type RelationScopeWatcher ¶
type RelationScopeWatcher struct {
// contains filtered or unexported fields
}
RelationScopeWatcher observes changes to the set of units in a particular relation scope.
func (*RelationScopeWatcher) Changes ¶
func (w *RelationScopeWatcher) Changes() <-chan *RelationScopeChange
Changes returns a channel that will receive changes when units enter and leave a relation scope. The Entered field in the first event on the channel holds the initial state.
func (*RelationScopeWatcher) Err ¶
func (w *RelationScopeWatcher) Err() error
Err returns any error encountered while running or shutting down, or tomb.ErrStillAlive if the watcher is still running.
func (*RelationScopeWatcher) Kill ¶
func (w *RelationScopeWatcher) Kill()
Kill kills the watcher without waiting for it to shut down.
type RelationUnit ¶
type RelationUnit struct {
// contains filtered or unexported fields
}
RelationUnit holds information about a single unit in a relation, and allows clients to conveniently access unit-specific functionality.
func (*RelationUnit) Endpoint ¶
func (ru *RelationUnit) Endpoint() Endpoint
Endpoint returns the relation endpoint that defines the unit's participation in the relation.
func (*RelationUnit) EnterScope ¶
func (ru *RelationUnit) EnterScope(settings map[string]interface{}) error
EnterScope ensures that the unit has entered its scope in the relation. When the unit has already entered its relation scope, EnterScope will report success but make no changes to state.
Otherwise, assuming both the relation and the unit are alive, it will enter scope and create or overwrite the unit's settings in the relation according to the supplied map.
If the unit is a principal and the relation has container scope, EnterScope will also create the required subordinate unit, if it does not already exist; this is because there's no point having a principal in scope if there is no corresponding subordinate to join it.
Once a unit has entered a scope, it stays in scope without further intervention; the relation will not be able to become Dead until all units have departed its scopes.
func (*RelationUnit) InScope ¶
func (ru *RelationUnit) InScope() (bool, error)
InScope returns whether the relation unit has entered scope or not.
func (*RelationUnit) LeaveScope ¶
func (ru *RelationUnit) LeaveScope() error
LeaveScope signals that the unit has left its scope in the relation. After the unit has left its relation scope, it is no longer a member of the relation; if the relation is dying when its last member unit leaves, it is removed immediately. It is not an error to leave a scope that the unit is not, or never was, a member of.
func (*RelationUnit) PrivateAddress ¶
func (ru *RelationUnit) PrivateAddress() (string, bool)
PrivateAddress returns the private address of the unit and whether it is valid.
func (*RelationUnit) ReadSettings ¶
func (ru *RelationUnit) ReadSettings(uname string) (m map[string]interface{}, err error)
ReadSettings returns a map holding the settings of the unit with the supplied name within this relation. An error will be returned if the relation no longer exists, or if the unit's service is not part of the relation, or the settings are invalid; but mere non-existence of the unit is not grounds for an error, because the unit settings are guaranteed to persist for the lifetime of the relation, regardless of the lifetime of the unit.
func (*RelationUnit) Relation ¶
func (ru *RelationUnit) Relation() *Relation
Relation returns the relation associated with the unit.
func (*RelationUnit) Settings ¶
func (ru *RelationUnit) Settings() (*Settings, error)
Settings returns a Settings which allows access to the unit's settings within the relation.
func (*RelationUnit) Watch ¶
func (ru *RelationUnit) Watch() RelationUnitsWatcher
Watch returns a watcher that notifies of changes to conterpart units in the relation.
func (*RelationUnit) WatchScope ¶
func (ru *RelationUnit) WatchScope() *RelationScopeWatcher
WatchScope returns a watcher which notifies of counterpart units entering and leaving the unit's scope.
type RelationUnitsWatcher ¶
type RelationUnitsWatcher interface { Watcher Changes() <-chan params.RelationUnitsChange }
RelationUnitsWatcher generates signals when units enter or leave the scope of a RelationUnit, and changes to the settings of those units known to have entered.
type Remover ¶
type Remover interface {
Remove() error
}
Remover represents entities with a Remove method.
type ResolvedMode ¶
type ResolvedMode string
ResolvedMode describes the way state transition errors are resolved.
const ( ResolvedNone ResolvedMode = "" ResolvedRetryHooks ResolvedMode = "retry-hooks" ResolvedNoHooks ResolvedMode = "no-hooks" )
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents the state of a service.
func (*Service) Annotation ¶
Annotation returns the annotation value corresponding to the given key. If the requested annotation is not found, an empty string is returned.
func (*Service) Annotations ¶
Annotations returns all the annotations corresponding to an entity.
func (*Service) Charm ¶
Charm returns the service's charm and whether units should upgrade to that charm even if they are in an error state.
func (*Service) CharmURL ¶
CharmURL returns the service's charm URL, and whether units should upgrade to the charm with that URL even if they are in an error state.
func (*Service) ClearExposed ¶
ClearExposed removes the exposed flag from the service. See SetExposed and IsExposed.
func (*Service) ConfigSettings ¶
ConfigSettings returns the raw user configuration for the service's charm. Unset values are omitted.
func (*Service) Constraints ¶
func (s *Service) Constraints() (constraints.Value, error)
Constraints returns the current service constraints.
func (*Service) Destroy ¶
Destroy ensures that the service and all its relations will be removed at some point; if the service has no units, and no relation involving the service has any units in scope, they are all removed immediately.
func (*Service) Endpoint ¶
Endpoint returns the relation endpoint with the supplied name, if it exists.
func (*Service) EnsureMinUnits ¶
EnsureMinUnits adds new units if the service's MinUnits value is greater than the number of alive units.
func (*Service) GetOwnerTag ¶
SCHEMACHANGE TODO(mattyw) remove when schema upgrades are possible
func (*Service) IsExposed ¶
IsExposed returns whether this service is exposed. The explicitly open ports (with open-port) for exposed services may be accessed from machines outside of the local deployment network. See SetExposed and ClearExposed.
func (*Service) IsPrincipal ¶
IsPrincipal returns whether units of the service can have subordinate units.
func (*Service) Refresh ¶
Refresh refreshes the contents of the Service from the underlying state. It returns an error that satisfies IsNotFound if the service has been removed.
func (*Service) SetAnnotations ¶
SetAnnotations adds key/value pairs to annotations in MongoDB.
func (*Service) SetCharm ¶
SetCharm changes the charm for the service. New units will be started with this charm, and existing units will be upgraded to use it. If force is true, units will be upgraded even if they are in an error state.
func (*Service) SetConstraints ¶
func (s *Service) SetConstraints(cons constraints.Value) (err error)
SetConstraints replaces the current service constraints.
func (*Service) SetExposed ¶
SetExposed marks the service as exposed. See ClearExposed and IsExposed.
func (*Service) SetMinUnits ¶
SetMinUnits changes the number of minimum units required by the service.
func (*Service) Tag ¶
Tag returns a name identifying the service that is safe to use as a file name. The returned name will be different from other Tag values returned by any other entities from the same state.
func (*Service) UpdateConfigSettings ¶
UpdateConfigSettings changes a service's charm config settings. Values set to nil will be deleted; unknown and invalid values will return an error.
func (*Service) Watch ¶
func (s *Service) Watch() NotifyWatcher
Watch returns a watcher for observing changes to a service.
func (*Service) WatchRelations ¶
func (s *Service) WatchRelations() StringsWatcher
WatchRelations returns a StringsWatcher that notifies of changes to the lifecycles of relations involving s.
func (*Service) WatchUnits ¶
func (s *Service) WatchUnits() StringsWatcher
WatchUnits returns a StringsWatcher that notifies of changes to the lifecycles of units of s.
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
A Settings manages changes to settings as a delta in memory and merges them back in the database when explicitly requested.
func (*Settings) Write ¶
func (c *Settings) Write() ([]ItemChange, error)
Write writes changes made to c back onto its node. Changes are written as a delta applied on top of the latest version of the node, to prevent overwriting unrelated changes made to the node since it was last read.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the state of an environment managed by juju.
func Initialize ¶
func Initialize(info *Info, cfg *config.Config, opts DialOpts, policy Policy) (rst *State, err error)
Initialize sets up an initial empty state and returns it. This needs to be performed only once for a given environment. It returns unauthorizedError if access is unauthorized.
func Open ¶
Open connects to the server described by the given info, waits for it to be initialized, and returns a new State representing the environment connected to.
A policy may be provided, which will be used to validate and modify behaviour of certain operations in state. A nil policy may be provided.
Open returns unauthorizedError if access is unauthorized.
func (*State) APIAddresses ¶
APIAddresses returns the list of cloud-internal addresses that can be used to connect to the state API server.
func (*State) AddCharm ¶
func (st *State) AddCharm(ch charm.Charm, curl *charm.URL, bundleURL *url.URL, bundleSha256 string) (stch *Charm, err error)
AddCharm adds the ch charm with curl to the state. bundleURL must be set to a URL where the bundle for ch may be downloaded from. On success the newly added charm state is returned.
func (*State) AddMachine ¶
func (st *State) AddMachine(series string, jobs ...MachineJob) (*Machine, error)
AddMachine adds a machine with the given series and jobs. It is deprecated and around for testing purposes only.
func (*State) AddMachineInsideMachine ¶
func (st *State) AddMachineInsideMachine(template MachineTemplate, parentId string, containerType instance.ContainerType) (*Machine, error)
AddMachineInsideMachine adds a machine inside a container of the given type on the existing machine with id=parentId.
func (*State) AddMachineInsideNewMachine ¶
func (st *State) AddMachineInsideNewMachine(template, parentTemplate MachineTemplate, containerType instance.ContainerType) (*Machine, error)
AddMachineInsideNewMachine creates a new machine within a container of the given type inside another new machine. The two given templates specify the form of the child and parent respectively.
func (*State) AddMachines ¶
func (st *State) AddMachines(templates ...MachineTemplate) (_ []*Machine, err error)
AddMachines adds new machines configured according to the given templates.
func (*State) AddOneMachine ¶
func (st *State) AddOneMachine(template MachineTemplate) (*Machine, error)
AddOne machine adds a new machine configured according to the given template.
func (*State) AddRelation ¶
AddRelation creates a new relation with the given endpoints.
func (*State) AddService ¶
AddService creates a new service, running the supplied charm, with the supplied name (which must be unique). If the charm defines peer relations, they will be created automatically.
func (*State) AddStoreCharmPlaceholder ¶
AddStoreCharmPlaceholder creates a charm document in state for the given charm URL which must reference a charm from the store. The charm document is marked as a placeholder which means that if the charm is to be deployed, it will need to first be uploaded to env storage.
func (*State) Addresses ¶
Addresses returns the list of cloud-internal addresses that can be used to connect to the state.
func (*State) AllMachines ¶
AllMachines returns all machines in the environment ordered by id.
func (*State) AllServices ¶
AllServices returns all deployed services in the environment.
func (*State) AssignUnit ¶
func (st *State) AssignUnit(u *Unit, policy AssignmentPolicy) (err error)
AssignUnit places the unit on a machine. Depending on the policy, and the state of the environment, this may lead to new instances being launched within the environment.
func (*State) Charm ¶
Charm returns the charm with the given URL. Charms pending upload to storage and placeholders are never returned.
func (*State) Cleanup ¶
Cleanup removes all documents that were previously marked for removal, if any such exist. It should be called periodically by at least one element of the system.
func (*State) DeployerConnectionInfo ¶
func (st *State) DeployerConnectionInfo() (*DeployerConnectionValues, error)
DeployerConnectionInfo returns the address information necessary for the deployer. The function does the expensive operations (getting stuff from mongo) just once.
func (*State) EndpointsRelation ¶
EndpointsRelation returns the existing relation with the given endpoints.
func (*State) EnsureAvailability ¶
func (st *State) EnsureAvailability(numStateServers int, cons constraints.Value, series string) error
EnsureAvailability adds state server machines as necessary to make the number of live state servers equal to numStateServers. The given constraints and series will be attached to any new machines.
TODO(rog): If any current state servers are down, they will be removed from the current set of voting replica set peers (although the machines themselves will remain and they will still remain part of the replica set). Once a machine's voting status has been removed, the machine itself may be removed.
func (*State) EnvironConstraints ¶
func (st *State) EnvironConstraints() (constraints.Value, error)
EnvironConstraints returns the current environment constraints.
func (*State) Environment ¶
func (st *State) Environment() (*Environment, error)
Environment returns the environment entity.
func (*State) FindEntity ¶
FindEntity returns the entity with the given tag.
The returned value can be of type *Machine, *Unit, *User, *Service or *Environment, depending on the tag.
func (*State) InferEndpoints ¶
InferEndpoints returns the endpoints corresponding to the supplied names. There must be 1 or 2 supplied names, of the form <service>[:<relation>]. If the supplied names uniquely specify a possible relation, or if they uniquely specify a possible relation once all implicit relations have been filtered, the endpoints corresponding to that relation will be returned.
func (*State) KeyRelation ¶
KeyRelation returns the existing relation with the given key (which can be derived unambiguously from the relation's endpoints).
func (*State) LatestPlaceholderCharm ¶
LatestPlaceholderCharm returns the latest charm described by the given URL but which is not yet deployed.
func (*State) MongoSession ¶
MongoSession returns the underlying mongodb session used by the state. It is exposed so that external code can maintain the mongo replica set and should not otherwise be used.
func (*State) NeedsCleanup ¶
NeedsCleanup returns true if documents previously marked for removal exist.
func (*State) PrepareLocalCharmUpload ¶
PrepareLocalCharmUpload must be called before a local charm is uploaded to the provider storage in order to create a charm document in state. It returns the chosen unique charm URL reserved in state for the charm.
The url's schema must be "local" and it must include a revision.
func (*State) PrepareStoreCharmUpload ¶
PrepareStoreCharmUpload must be called before a charm store charm is uploaded to the provider storage in order to create a charm document in state. If a charm with the same URL is already in state, it will be returned as a *state.Charm (is can be still pending or already uploaded). Otherwise, a new charm document is added in state with just the given charm URL and PendingUpload=true, which is then returned as a *state.Charm.
The url's schema must be "cs" and it must include a revision.
func (*State) ResumeTransactions ¶
ResumeTransactions resumes all pending transactions.
func (*State) SetAdminMongoPassword ¶
SetAdminMongoPassword sets the administrative password to access the state. If the password is non-empty, all subsequent attempts to access the state must be authorized; otherwise no authorization is required.
func (*State) SetEnvironAgentVersion ¶
SetEnvironAgentVersion changes the agent version for the environment to the given version, only if the environment is in a stable state (all agents are running the current version).
func (*State) SetEnvironConfig ¶
SetEnvironConfig replaces the current configuration of the environment with the provided configuration.
func (*State) SetEnvironConstraints ¶
func (st *State) SetEnvironConstraints(cons constraints.Value) error
SetEnvironConstraints replaces the current environment constraints.
func (*State) StartSync ¶
func (st *State) StartSync()
StartSync forces watchers to resynchronize their state with the database immediately. This will happen periodically automatically.
func (*State) StateServerInfo ¶
func (st *State) StateServerInfo() (*StateServerInfo, error)
StateServerInfo returns returns information about the currently configured state server machines.
func (*State) UpdateUploadedCharm ¶
func (st *State) UpdateUploadedCharm(ch charm.Charm, curl *charm.URL, bundleURL *url.URL, bundleSha256 string) (*Charm, error)
UpdateUploadedCharm marks the given charm URL as uploaded and updates the rest of its data, returning it as *state.Charm.
func (*State) Watch ¶
func (st *State) Watch() *multiwatcher.Watcher
func (*State) WatchCleanups ¶
func (st *State) WatchCleanups() NotifyWatcher
WatchCleanups starts and returns a CleanupWatcher.
func (*State) WatchEnvironConfig ¶
func (s *State) WatchEnvironConfig() *EnvironConfigWatcher
WatchEnvironConfig returns a watcher for observing changes to the environment configuration.
func (*State) WatchEnvironMachines ¶
func (st *State) WatchEnvironMachines() StringsWatcher
WatchEnvironMachines returns a StringsWatcher that notifies of changes to the lifecycles of the machines (but not containers) in the environment.
func (*State) WatchForEnvironConfigChanges ¶
func (st *State) WatchForEnvironConfigChanges() NotifyWatcher
WatchForEnvironConfigChanges return a NotifyWatcher waiting for the Environ Config to change. This differs from WatchEnvironConfig in that the watcher is a NotifyWatcher that does not give content during Changes()
func (*State) WatchMinUnits ¶
func (st *State) WatchMinUnits() StringsWatcher
func (*State) WatchServices ¶
func (st *State) WatchServices() StringsWatcher
WatchServices returns a StringsWatcher that notifies of changes to the lifecycles of the services in the environment.
func (*State) WatchStateServerInfo ¶
func (st *State) WatchStateServerInfo() NotifyWatcher
type StateServerInfo ¶
type StateServerInfo struct { // MachineIds holds the ids of all machines configured // to run a state server. It includes all the machine // ids in VotingMachineIds. MachineIds []string // VotingMachineIds holds the ids of all machines // configured to run a state server and to have a vote // in peer election. VotingMachineIds []string }
StateServerInfo holds information about currently configured state server machines.
type StatusSetter ¶
type StringsWatcher ¶
StringsWatcher generates signals when something changes, returning the changes as a list of strings.
type Unit ¶
type Unit struct {
// contains filtered or unexported fields
}
Unit represents the state of a service unit.
func (*Unit) AgentAlive ¶
AgentAlive returns whether the respective remote agent is alive.
func (*Unit) AgentTools ¶
AgentTools returns the tools that the agent is currently running. It an error that satisfies IsNotFound if the tools have not yet been set.
func (*Unit) Annotation ¶
Annotation returns the annotation value corresponding to the given key. If the requested annotation is not found, an empty string is returned.
func (*Unit) Annotations ¶
Annotations returns all the annotations corresponding to an entity.
func (*Unit) AssignToCleanEmptyMachine ¶
AssignToCleanMachine assigns u to a machine which is marked as clean and is also not hosting any containers. A machine is clean if it has never had any principal units assigned to it. If there are no clean machines besides any machine(s) running JobHostEnviron, an error is returned. This method does not take constraints into consideration when choosing a machine (lp:1161919).
func (*Unit) AssignToCleanMachine ¶
AssignToCleanMachine assigns u to a machine which is marked as clean. A machine is clean if it has never had any principal units assigned to it. If there are no clean machines besides any machine(s) running JobHostEnviron, an error is returned. This method does not take constraints into consideration when choosing a machine (lp:1161919).
func (*Unit) AssignToMachine ¶
AssignToMachine assigns this unit to a given machine.
func (*Unit) AssignToNewMachine ¶
AssignToNewMachine assigns the unit to a new machine, with constraints determined according to the service and environment constraints at the time of unit creation.
func (*Unit) AssignToNewMachineOrContainer ¶
AssignToNewMachineOrContainer assigns the unit to a new machine, with constraints determined according to the service and environment constraints at the time of unit creation. If a container is required, a clean, empty machine instance is required on which to create the container. An existing clean, empty instance is first searched for, and if not found, a new one is created.
func (*Unit) AssignedMachineId ¶
AssignedMachineId returns the id of the assigned machine.
func (*Unit) ClearResolved ¶
ClearResolved removes any resolved setting on the unit.
func (*Unit) ClosePort ¶
ClosePort sets the policy of the port with protocol and number to be closed.
func (*Unit) ConfigSettings ¶
ConfigSettings returns the complete set of service charm config settings available to the unit. Unset values will be replaced with the default value for the associated option, and may thus be nil when no default is specified.
func (*Unit) DeployerTag ¶
DeployerTag returns the tag of the agent responsible for deploying the unit. If no such entity can be determined, false is returned.
func (*Unit) Destroy ¶
Destroy, when called on a Alive unit, advances its lifecycle as far as possible; it otherwise has no effect. In most situations, the unit's life is just set to Dying; but if a principal unit that is not assigned to a provisioned machine is Destroyed, it will be removed from state directly.
func (*Unit) EnsureDead ¶
EnsureDead sets the unit lifecycle to Dead if it is Alive or Dying. It does nothing otherwise. If the unit has subordinates, it will return ErrUnitHasSubordinates.
func (*Unit) IsPrincipal ¶
IsPrincipal returns whether the unit is deployed in its own container, and can therefore have subordinate services deployed alongside it.
func (*Unit) OpenedPorts ¶
OpenedPorts returns a slice containing the open ports of the unit.
func (*Unit) PasswordValid ¶
PasswordValid returns whether the given password is valid for the given unit.
func (*Unit) PrincipalName ¶
PrincipalName returns the name of the unit's principal. If the unit is not a subordinate, false is returned.
func (*Unit) PrivateAddress ¶
PrivateAddress returns the private address of the unit and whether it is valid.
func (*Unit) PublicAddress ¶
PublicAddress returns the public address of the unit and whether it is valid.
func (*Unit) Refresh ¶
Refresh refreshes the contents of the Unit from the underlying state. It an error that satisfies IsNotFound if the unit has been removed.
func (*Unit) Remove ¶
Remove removes the unit from state, and may remove its service as well, if the service is Dying and no other references to it exist. It will fail if the unit is not Dead.
func (*Unit) Resolve ¶
Resolve marks the unit as having had any previous state transition problems resolved, and informs the unit that it may attempt to reestablish normal workflow. The retryHooks parameter informs whether to attempt to reexecute previous failed hooks or to continue as if they had succeeded before.
func (*Unit) Resolved ¶
func (u *Unit) Resolved() ResolvedMode
Resolved returns the resolved mode for the unit.
func (*Unit) ServiceName ¶
ServiceName returns the service name.
func (*Unit) SetAgentAlive ¶
SetAgentAlive signals that the agent for unit u is alive. It returns the started pinger.
func (*Unit) SetAgentVersion ¶
SetAgentVersion sets the version of juju that the agent is currently running.
func (*Unit) SetAnnotations ¶
SetAnnotations adds key/value pairs to annotations in MongoDB.
func (*Unit) SetCharmURL ¶
SetCharmURL marks the unit as currently using the supplied charm URL. An error will be returned if the unit is dead, or the charm URL not known.
func (*Unit) SetMongoPassword ¶
SetMongoPassword sets the password the agent responsible for the unit should use to communicate with the state servers. Previous passwords are invalidated.
func (*Unit) SetPassword ¶
SetPassword sets the password for the machine's agent.
func (*Unit) SetPrivateAddress ¶
SetPrivateAddress sets the private address of the unit.
func (*Unit) SetPublicAddress ¶
SetPublicAddress sets the public address of the unit.
func (*Unit) SetResolved ¶
func (u *Unit) SetResolved(mode ResolvedMode) (err error)
SetResolved marks the unit as having had any previous state transition problems resolved, and informs the unit that it may attempt to reestablish normal workflow. The resolved mode parameter informs whether to attempt to reexecute previous failed hooks or to continue as if they had succeeded before.
func (*Unit) SetStatus ¶
SetStatus sets the status of the unit. The optional values allow to pass additional helpful status data.
func (*Unit) SubordinateNames ¶
SubordinateNames returns the names of any subordinate units.
func (*Unit) Tag ¶
Tag returns a name identifying the unit that is safe to use as a file name. The returned name will be different from other Tag values returned by any other entities from the same state.
func (*Unit) UnassignFromMachine ¶
UnassignFromMachine removes the assignment between this unit and the machine it's assigned to.
func (*Unit) WaitAgentAlive ¶
WaitAgentAlive blocks until the respective agent is alive.
func (*Unit) Watch ¶
func (u *Unit) Watch() NotifyWatcher
Watch returns a watcher for observing changes to a unit.
func (*Unit) WatchConfigSettings ¶
func (u *Unit) WatchConfigSettings() (NotifyWatcher, error)
WatchConfigSettings returns a watcher for observing changes to the unit's service configuration settings. The unit must have a charm URL set before this method is called, and the returned watcher will be valid only while the unit's charm URL is not changed. TODO(fwereade): this could be much smarter; if it were, uniter.Filter could be somewhat simpler.
func (*Unit) WatchSubordinateUnits ¶
func (u *Unit) WatchSubordinateUnits() StringsWatcher
WatchSubordinateUnits returns a StringsWatcher tracking the unit's subordinate units.
type UnitsWatcher ¶
type UnitsWatcher interface { Entity WatchUnits() StringsWatcher }
UnitsWatcher defines the methods needed to retrieve an entity (a machine or a service) and watch its units.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User represents a juju client user.
func (*User) PasswordValid ¶
PasswordValid returns whether the given password is valid for the user.
func (*User) SetPassword ¶
SetPassword sets the password associated with the user.
func (*User) SetPasswordHash ¶
SetPasswordHash sets the password to the inverse of pwHash = utils.UserPasswordHash(pw, pwSalt). It can be used when we know only the hash of the password, but not the clear text.
type Watcher ¶
type Watcher interface { // Kill asks the watcher to stop without waiting for it do so. Kill() // Wait waits for the watcher to die and returns any // error encountered when it was running. Wait() error // Stop kills the watcher, then waits for it to die. Stop() error // Err returns any error encountered while the watcher // has been running. Err() error }
Watcher is implemented by all watchers; the actual changes channel is returned by a watcher-specific Changes method.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
agent
The machine package implements the API interfaces used by the machine agent.
|
The machine package implements the API interfaces used by the machine agent. |
machine
The machiner package implements the API interface used by the machiner worker.
|
The machiner package implements the API interface used by the machiner worker. |
uniter
The uniter package implements the API interface used by the uniter worker.
|
The uniter package implements the API interface used by the uniter worker. |
The presence package implements an interface for observing liveness of arbitrary keys (agents, processes, etc) on top of MongoDB.
|
The presence package implements an interface for observing liveness of arbitrary keys (agents, processes, etc) on top of MongoDB. |
The watcher package provides an interface for observing changes to arbitrary MongoDB documents that are maintained via the mgo/txn transaction package.
|
The watcher package provides an interface for observing changes to arbitrary MongoDB documents that are maintained via the mgo/txn transaction package. |