Documentation ¶
Index ¶
- Variables
- type Charm
- type Endpoint
- type Environment
- type Relation
- type RelationUnit
- func (ru *RelationUnit) Endpoint() Endpoint
- func (ru *RelationUnit) EnterScope() error
- func (ru *RelationUnit) LeaveScope() error
- func (ru *RelationUnit) PrivateAddress() (string, error)
- func (ru *RelationUnit) ReadSettings(uname string) (params.RelationSettings, error)
- func (ru *RelationUnit) Relation() *Relation
- func (ru *RelationUnit) Settings() (*Settings, error)
- func (ru *RelationUnit) Watch() (watcher.RelationUnitsWatcher, error)
- type Service
- func (s *Service) CharmURL() (*charm.URL, bool, error)
- func (s *Service) GetOwnerTag() (string, error)
- func (s *Service) Life() params.Life
- func (s *Service) Name() string
- func (s *Service) Refresh() error
- func (s *Service) String() string
- func (s *Service) Watch() (watcher.NotifyWatcher, error)
- func (s *Service) WatchRelations() (watcher.StringsWatcher, error)
- type Settings
- type State
- func (st *State) APIAddresses() ([]string, error)
- func (st *State) Charm(curl *charm.URL) (*Charm, error)
- func (st *State) Environment() (*Environment, error)
- func (st *State) ProviderType() (string, error)
- func (st *State) Relation(tag string) (*Relation, error)
- func (st *State) RelationById(id int) (*Relation, error)
- func (st *State) Service(tag string) (*Service, error)
- func (st *State) Unit(tag string) (*Unit, error)
- type Unit
- func (u *Unit) CharmURL() (*charm.URL, error)
- func (u *Unit) ClearResolved() error
- func (u *Unit) ClosePort(protocol string, number int) error
- func (u *Unit) ConfigSettings() (charm.Settings, error)
- func (u *Unit) Destroy() error
- func (u *Unit) DestroyAllSubordinates() error
- func (u *Unit) EnsureDead() error
- func (u *Unit) HasSubordinates() (bool, error)
- func (u *Unit) IsPrincipal() (bool, error)
- func (u *Unit) Life() params.Life
- func (u *Unit) Name() string
- func (u *Unit) OpenPort(protocol string, number int) error
- func (u *Unit) PrivateAddress() (string, error)
- func (u *Unit) PublicAddress() (string, error)
- func (u *Unit) Refresh() error
- func (u *Unit) Resolved() (params.ResolvedMode, error)
- func (u *Unit) Service() (*Service, error)
- func (u *Unit) ServiceName() string
- func (u *Unit) ServiceTag() string
- func (u *Unit) SetCharmURL(curl *charm.URL) error
- func (u *Unit) SetPrivateAddress(address string) error
- func (u *Unit) SetPublicAddress(address string) error
- func (u *Unit) SetStatus(status params.Status, info string, data params.StatusData) error
- func (u *Unit) String() string
- func (u *Unit) Tag() string
- func (u *Unit) Watch() (watcher.NotifyWatcher, error)
- func (u *Unit) WatchConfigSettings() (watcher.NotifyWatcher, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoCharmURLSet = errors.New("unit has no charm url set")
Functions ¶
This section is empty.
Types ¶
type Charm ¶
type Charm struct {
// contains filtered or unexported fields
}
Charm represents the state of a charm in the environment.
func (*Charm) ArchiveSha256 ¶
ArchiveSha256 returns the SHA256 digest of the charm archive (bundle) bytes.
NOTE: This differs from state.Charm.BundleSha256() by returning an error as well, because it needs to make an API call. It's also renamed to avoid confusion with juju deployment bundles.
TODO(dimitern): 2013-09-06 bug 1221834 Cache the result after getting it once for the same charm URL, because it's immutable.
func (*Charm) ArchiveURL ¶
ArchiveURL returns the url to the charm archive (bundle) in the provider storage, and DisableSSLHostnameVerification flag.
NOTE: This differs from state.Charm.BundleURL() by returning an error as well, because it needs to make an API call. It's also renamed to avoid confusion with juju deployment bundles.
TODO(dimitern): 2013-09-06 bug 1221834 Cache the result after getting it once for the same charm URL, because it's immutable.
type Endpoint ¶
Endpoint represents one endpoint of a relation. It is just a wrapper around charm.Relation. No API calls to the server-side are needed to support the interface needed by the uniter worker.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment represents the state of an environment.
func (Environment) Name ¶
func (e Environment) Name() string
Name returns the human friendly name of the environment.
func (Environment) UUID ¶
func (e Environment) UUID() string
UUID returns the universally unique identifier of the environment.
type Relation ¶
type Relation struct {
// contains filtered or unexported fields
}
Relation represents a relation between one or two service endpoints.
func (*Relation) Endpoint ¶
Endpoint returns the endpoint of the relation for the service the uniter's managed unit belongs to.
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.
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() 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.
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.
NOTE: Unlike state.RelatioUnit.EnterScope(), this method does not take settings, because uniter only uses this to supply the unit's private address, but this is not done at the server-side by the API.
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, error)
PrivateAddress returns the private address of the unit and whether it is valid.
NOTE: This differs from state.RelationUnit.PrivateAddress() by returning an error instead of a bool, because it needs to make an API call.
func (*RelationUnit) ReadSettings ¶
func (ru *RelationUnit) ReadSettings(uname string) (params.RelationSettings, 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() (watcher.RelationUnitsWatcher, error)
Watch returns a watcher that notifies of changes to counterpart units in the relation.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents the state of a service.
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 (force flag).
NOTE: This differs from state.Service.CharmURL() by returning an error instead as well, because it needs to make an API call.
func (*Service) GetOwnerTag ¶
TODO(dimitern) bug #1270795 2014-01-20 Add a doc comment here.
func (*Service) Watch ¶
func (s *Service) Watch() (watcher.NotifyWatcher, error)
Watch returns a watcher for observing changes to a service.
func (*Service) WatchRelations ¶
func (s *Service) WatchRelations() (watcher.StringsWatcher, error)
WatchRelations returns a StringsWatcher that notifies of changes to the lifecycles of relations involving s.
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings manages changes to unit settings in a relation.
func (*Settings) Map ¶
func (s *Settings) Map() params.RelationSettings
Map returns all keys and values of the node.
TODO(dimitern): This differes from state.Settings.Map() - it does not return map[string]interface{}, but since all values are expected to be strings anyway, we need to fix the uniter code accordingly when migrating to the API.
func (*Settings) Set ¶
Set sets key to value.
TODO(dimitern): value must be a string. Change the code that uses this accordingly.
func (*Settings) Write ¶
Write writes changes made to s back onto its node. Keys set to empty values will be deleted, others will be updated to the new value.
TODO(dimitern): 2013-09-06 bug 1221798 Once the machine addressability changes lands, we may need to revise the logic here to take into account that the "private-address" setting for a unit can be changed outside of the uniter's control. So we may need to send diffs of what has changed to make sure we update the address (and other settings) correctly, without overwritting.
type State ¶
type State struct { *common.EnvironWatcher // contains filtered or unexported fields }
State provides access to the Uniter API facade.
func (*State) APIAddresses ¶
APIAddresses returns the list of addresses used to connect to the API.
func (*State) Environment ¶
func (st *State) Environment() (*Environment, error)
Environment returns the environment entity.
func (*State) ProviderType ¶
ProviderType returns a provider type used by the current juju environment.
TODO(dimitern): We might be able to drop this, once we have machine addresses implemented fully. See also LP bug 1221798.
func (*State) RelationById ¶
Relation returns the existing relation with the given tag.
type Unit ¶
type Unit struct {
// contains filtered or unexported fields
}
Unit represents a juju unit as seen by a uniter worker.
func (*Unit) CharmURL ¶
CharmURL returns the charm URL this unit is currently using.
NOTE: This differs from state.Unit.CharmURL() by returning an error instead of a bool, because it needs to make an API call.
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.
TODO: We should really be opening and closing ports on machines, rather than units.
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) 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) DestroyAllSubordinates ¶
DestroyAllSubordinates destroys all subordinates of the unit.
func (*Unit) EnsureDead ¶
EnsureDead sets the unit lifecycle to Dead if it is Alive or Dying. It does nothing otherwise.
func (*Unit) HasSubordinates ¶
HasSubordinates returns the tags of any subordinate units.
func (*Unit) IsPrincipal ¶
IsPrincipal returns whether the unit is deployed in its own container, and can therefore have subordinate services deployed alongside it.
NOTE: This differs from state.Unit.IsPrincipal() by returning an error as well, because it needs to make an API call.
func (*Unit) OpenPort ¶
OpenPort sets the policy of the port with protocol and number to be opened.
TODO: We should really be opening and closing ports on machines, rather than units.
func (*Unit) PrivateAddress ¶
PrivateAddress returns the private address of the unit and whether it is valid.
NOTE: This differs from state.Unit.PrivateAddress() by returning an error instead of a bool, because it needs to make an API call.
TODO(dimitern): We might be able to drop this, once we have machine addresses implemented fully. See also LP bug 1221798.
func (*Unit) PublicAddress ¶
PublicAddress returns the public address of the unit and whether it is valid.
NOTE: This differs from state.Unit.PublicAddres() by returning an error instead of a bool, because it needs to make an API call.
TODO(dimitern): We might be able to drop this, once we have machine addresses implemented fully. See also LP bug 1221798.
func (*Unit) Resolved ¶
func (u *Unit) Resolved() (params.ResolvedMode, error)
Resolved returns the resolved mode for the unit.
NOTE: This differs from state.Unit.Resolved() by returning an error as well, because it needs to make an API call
func (*Unit) ServiceName ¶
ServiceName returns the service name.
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) SetPrivateAddress ¶
SetPrivateAddress sets the private address of the unit.
TODO(dimitern): We might be able to drop this, once we have machine addresses implemented fully. See also LP bug 1221798.
func (*Unit) SetPublicAddress ¶
SetPublicAddress sets the public address of the unit.
TODO(dimitern): We might be able to drop this, once we have machine addresses implemented fully. See also LP bug 1221798.
func (*Unit) Watch ¶
func (u *Unit) Watch() (watcher.NotifyWatcher, error)
Watch returns a watcher for observing changes to the unit.
func (*Unit) WatchConfigSettings ¶
func (u *Unit) WatchConfigSettings() (watcher.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.