juju: github.com/jrwren/juju/api/uniter Index | Files

package uniter

import "github.com/jrwren/juju/api/uniter"

Index

Package Files

action.go charm.go endpoint.go environ.go relation.go relationunit.go service.go settings.go unit.go uniter.go

Variables

var ErrNoCharmURLSet = errors.New("unit has no charm url set")
var NewState = newStateV1

NewState creates a new client-side Uniter facade. Defined like this to allow patching during tests.

func CharmsURL Uses

func CharmsURL(apiAddr string, envTag names.EnvironTag) *url.URL

CharmsURL takes an API server address and an optional environment tag and constructs a base URL used for fetching charm archives. If the environment tag empty or invalid, it will be ignored.

type Action Uses

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

Action represents a single instance of an Action call, by name and params.

func NewAction Uses

func NewAction(name string, params map[string]interface{}) (*Action, error)

NewAction makes a new Action with specified name and params map.

func (*Action) Name Uses

func (a *Action) Name() string

Name retrieves the name of the Action.

func (*Action) Params Uses

func (a *Action) Params() map[string]interface{}

Params retrieves the params map of the Action.

type Charm Uses

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

Charm represents the state of a charm in the environment.

func (*Charm) ArchiveSha256 Uses

func (c *Charm) ArchiveSha256() (string, error)

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 Uses

func (c *Charm) ArchiveURL() *url.URL

ArchiveURL returns the url to the charm archive (bundle) in the environment storage.

func (*Charm) String Uses

func (c *Charm) String() string

String returns the charm URL as a string.

func (*Charm) URL Uses

func (c *Charm) URL() *charm.URL

URL returns the URL that identifies the charm.

type Endpoint Uses

type Endpoint struct {
    charm.Relation
}

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 Uses

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

Environment represents the state of an environment.

func (Environment) Name Uses

func (e Environment) Name() string

Name returns the human friendly name of the environment.

func (Environment) UUID Uses

func (e Environment) UUID() string

UUID returns the universally unique identifier of the environment.

type Relation Uses

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

Relation represents a relation between one or two service endpoints.

func (*Relation) Endpoint Uses

func (r *Relation) Endpoint() (*Endpoint, error)

Endpoint returns the endpoint of the relation for the service the uniter's managed unit belongs to.

func (*Relation) Id Uses

func (r *Relation) Id() int

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) Life Uses

func (r *Relation) Life() params.Life

Life returns the relation's current life state.

func (*Relation) Refresh Uses

func (r *Relation) Refresh() error

Refresh refreshes the contents of the relation from the underlying state. It returns an error that satisfies errors.IsNotFound if the relation has been removed.

func (*Relation) String Uses

func (r *Relation) String() string

String returns the relation as a string.

func (*Relation) Tag Uses

func (r *Relation) Tag() names.RelationTag

Tag returns the relation tag.

func (*Relation) Unit Uses

func (r *Relation) Unit(u *Unit) (*RelationUnit, error)

Unit returns a RelationUnit for the supplied unit.

type RelationUnit Uses

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 Uses

func (ru *RelationUnit) Endpoint() Endpoint

Endpoint returns the relation endpoint that defines the unit's participation in the relation.

func (*RelationUnit) EnterScope Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (ru *RelationUnit) Relation() *Relation

Relation returns the relation associated with the unit.

func (*RelationUnit) Settings Uses

func (ru *RelationUnit) Settings() (*Settings, error)

Settings returns a Settings which allows access to the unit's settings within the relation.

func (*RelationUnit) Watch Uses

func (ru *RelationUnit) Watch() (watcher.RelationUnitsWatcher, error)

Watch returns a watcher that notifies of changes to counterpart units in the relation.

type Service Uses

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

Service represents the state of a service.

func (*Service) CharmURL Uses

func (s *Service) CharmURL() (*charm.URL, bool, error)

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) Life Uses

func (s *Service) Life() params.Life

Life returns the service's current life state.

func (*Service) Name Uses

func (s *Service) Name() string

Name returns the service name.

func (*Service) OwnerTag Uses

func (s *Service) OwnerTag() (names.UserTag, error)

OwnerTag returns the service's owner user tag.

func (*Service) Refresh Uses

func (s *Service) Refresh() error

Refresh refreshes the contents of the Service from the underlying state.

func (*Service) String Uses

func (s *Service) String() string

String returns the service as a string.

func (*Service) Tag Uses

func (s *Service) Tag() names.ServiceTag

Tag returns the service's tag.

func (*Service) Watch Uses

func (s *Service) Watch() (watcher.NotifyWatcher, error)

Watch returns a watcher for observing changes to a service.

func (*Service) WatchRelations Uses

func (s *Service) WatchRelations() (watcher.StringsWatcher, error)

WatchRelations returns a StringsWatcher that notifies of changes to the lifecycles of relations involving s.

type Settings Uses

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

Settings manages changes to unit settings in a relation.

func (*Settings) Delete Uses

func (s *Settings) Delete(key string)

Delete removes key.

func (*Settings) Map Uses

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 Uses

func (s *Settings) Set(key, value string)

Set sets key to value.

TODO(dimitern): value must be a string. Change the code that uses this accordingly.

func (*Settings) Write Uses

func (s *Settings) Write() error

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 Uses

type State struct {
    *common.EnvironWatcher
    *common.APIAddresser
    // contains filtered or unexported fields
}

State provides access to the Uniter API facade.

func (*State) Action Uses

func (st *State) Action(tag names.ActionTag) (*Action, error)

Action returns the Action with the given tag.

func (*State) ActionFinish Uses

func (st *State) ActionFinish(tag names.ActionTag, status string, results map[string]interface{}, message string) error

ActionFinish captures the structured output of an action.

func (*State) AllMachinePorts Uses

func (st *State) AllMachinePorts(machineTag names.MachineTag) (map[network.PortRange]params.RelationUnit, error)

AllMachinePorts returns all port ranges currently open on the given machine, mapped to the tags of the unit that opened them and the relation that applies.

func (*State) BestAPIVersion Uses

func (st *State) BestAPIVersion() int

BestAPIVersion returns the API version that we were able to determine is supported by both the client and the API Server.

func (*State) Charm Uses

func (st *State) Charm(curl *charm.URL) (*Charm, error)

Charm returns the charm with the given URL.

func (*State) Environment Uses

func (st *State) Environment() (*Environment, error)

Environment returns the environment entity.

func (*State) ProviderType Uses

func (st *State) ProviderType() (string, error)

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) Relation Uses

func (st *State) Relation(relationTag names.RelationTag) (*Relation, error)

Relation returns the existing relation with the given tag.

func (*State) RelationById Uses

func (st *State) RelationById(id int) (*Relation, error)

RelationById returns the existing relation with the given id.

func (*State) Service Uses

func (st *State) Service(tag names.ServiceTag) (*Service, error)

Service returns a service state by tag.

func (*State) Unit Uses

func (st *State) Unit(tag names.UnitTag) (*Unit, error)

Unit provides access to methods of a state.Unit through the facade.

type Unit Uses

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

Unit represents a juju unit as seen by a uniter worker.

func (*Unit) AddMetrics Uses

func (u *Unit) AddMetrics(metrics []params.Metric) error

AddMetrics adds the metrics for the unit.

func (*Unit) AssignedMachine Uses

func (u *Unit) AssignedMachine() (names.MachineTag, error)

AssignedMachine returns the unit's assigned machine tag or an error satisfying params.IsCodeNotAssigned when the unit has no assigned machine..

func (*Unit) CharmURL Uses

func (u *Unit) CharmURL() (*charm.URL, error)

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 Uses

func (u *Unit) ClearResolved() error

ClearResolved removes any resolved setting on the unit.

func (*Unit) ClosePort Uses

func (u *Unit) ClosePort(protocol string, number int) error

ClosePort sets the policy of the port with protocol and number to be closed.

TODO(dimitern): This is deprecated and is kept for backwards-compatibility. Use ClosePorts instead.

func (*Unit) ClosePorts Uses

func (u *Unit) ClosePorts(protocol string, fromPort, toPort int) error

ClosePorts sets the policy of the port range with protocol to be closed.

func (*Unit) ConfigSettings Uses

func (u *Unit) ConfigSettings() (charm.Settings, error)

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 Uses

func (u *Unit) Destroy() error

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 Uses

func (u *Unit) DestroyAllSubordinates() error

DestroyAllSubordinates destroys all subordinates of the unit.

func (*Unit) EnsureDead Uses

func (u *Unit) EnsureDead() error

EnsureDead sets the unit lifecycle to Dead if it is Alive or Dying. It does nothing otherwise.

func (*Unit) HasSubordinates Uses

func (u *Unit) HasSubordinates() (bool, error)

HasSubordinates returns the tags of any subordinate units.

func (*Unit) IsPrincipal Uses

func (u *Unit) IsPrincipal() (bool, error)

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) JoinedRelations Uses

func (u *Unit) JoinedRelations() ([]names.RelationTag, error)

JoinedRelations returns the tags of the relations the unit has joined.

func (*Unit) Life Uses

func (u *Unit) Life() params.Life

Life returns the unit's lifecycle value.

func (*Unit) MeterStatus Uses

func (u *Unit) MeterStatus() (statusCode, statusInfo string, rErr error)

MeterStatus returns the meter status of the unit.

func (*Unit) Name Uses

func (u *Unit) Name() string

Name returns the name of the unit.

func (*Unit) OpenPort Uses

func (u *Unit) OpenPort(protocol string, number int) error

OpenPort sets the policy of the port with protocol and number to be opened.

TODO(dimitern): This is deprecated and is kept for backwards-compatibility. Use OpenPorts instead.

func (*Unit) OpenPorts Uses

func (u *Unit) OpenPorts(protocol string, fromPort, toPort int) error

OpenPorts sets the policy of the port range with protocol to be opened.

func (*Unit) PrivateAddress Uses

func (u *Unit) PrivateAddress() (string, error)

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 Uses

func (u *Unit) PublicAddress() (string, error)

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) Refresh Uses

func (u *Unit) Refresh() error

Refresh updates the cached local copy of the unit's data.

func (*Unit) RequestReboot Uses

func (u *Unit) RequestReboot() error

RequestReboot sets the reboot flag for its machine agent

func (*Unit) Resolved Uses

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) Service Uses

func (u *Unit) Service() (*Service, error)

Service returns the service.

func (*Unit) ServiceName Uses

func (u *Unit) ServiceName() string

ServiceName returns the service name.

func (*Unit) ServiceTag Uses

func (u *Unit) ServiceTag() names.ServiceTag

ServiceTag returns the service tag.

func (*Unit) SetCharmURL Uses

func (u *Unit) SetCharmURL(curl *charm.URL) error

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) SetStatus Uses

func (u *Unit) SetStatus(status params.Status, info string, data map[string]interface{}) error

SetStatus sets the status of the unit.

func (*Unit) String Uses

func (u *Unit) String() string

String returns the unit as a string.

func (*Unit) Tag Uses

func (u *Unit) Tag() names.UnitTag

Tag returns the unit's tag.

func (*Unit) Watch Uses

func (u *Unit) Watch() (watcher.NotifyWatcher, error)

Watch returns a watcher for observing changes to the unit.

func (*Unit) WatchActions Uses

func (u *Unit) WatchActions() (watcher.StringsWatcher, error)

WatchActions returns a StringsWatcher for observing the ids of Actions added to the Unit. The initial event will contain the ids of any Actions pending at the time the Watcher is made.

func (*Unit) WatchAddresses Uses

func (u *Unit) WatchAddresses() (watcher.NotifyWatcher, error)

WatchAddresses returns a watcher for observing changes to the unit's addresses. The unit must be assigned to a machine before this method is called, and the returned watcher will be valid only while the unit's assigned machine is not changed.

func (*Unit) WatchConfigSettings Uses

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.

func (*Unit) WatchMeterStatus Uses

func (u *Unit) WatchMeterStatus() (watcher.NotifyWatcher, error)

WatchMeterStatus returns a watcher for observing changes to the unit's meter status.

Package uniter imports 11 packages (graph). Updated 2016-07-26. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).