uniter

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package uniter implements the API interface used by the uniter worker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LXDProfileAPI

type LXDProfileAPI struct {
	AccessMachine common.GetAuthFunc
	// contains filtered or unexported fields
}

func NewExternalLXDProfileAPI

func NewExternalLXDProfileAPI(
	st *state.State,
	resources facade.Resources,
	authorizer facade.Authorizer,
	accessMachine common.GetAuthFunc,
	accessUnit common.GetAuthFunc,
	logger loggo.Logger,
) *LXDProfileAPI

NewExternalLXDProfileAPI can be used for API registration.

func NewLXDProfileAPI

func NewLXDProfileAPI(
	backend LXDProfileBackend,
	resources facade.Resources,
	authorizer facade.Authorizer,
	accessMachine common.GetAuthFunc,
	accessUnit common.GetAuthFunc,
	logger loggo.Logger,
) *LXDProfileAPI

NewLXDProfileAPI returns a new LXDProfileAPI. Currently both GetAuthFuncs can used to determine current permissions.

func (*LXDProfileAPI) RemoveUpgradeCharmProfileData

func (u *LXDProfileAPI) RemoveUpgradeCharmProfileData(args params.Entities) (params.ErrorResults, error)

RemoveUpgradeCharmProfileData is intended to clean up the LXDProfile status to ensure that we start from a clean slate.

func (*LXDProfileAPI) WatchLXDProfileUpgradeNotifications

func (u *LXDProfileAPI) WatchLXDProfileUpgradeNotifications(args params.LXDProfileUpgrade) (params.StringsWatchResults, error)

WatchLXDProfileUpgradeNotifications returns a StringsWatcher for observing changes to the lxd profile changes.

type LXDProfileBackend

type LXDProfileBackend interface {
	Machine(string) (LXDProfileMachine, error)
	Unit(string) (LXDProfileUnit, error)
}

type LXDProfileMachine

type LXDProfileMachine interface {
	WatchLXDProfileUpgradeNotifications(string) (state.StringsWatcher, error)
	Units() ([]LXDProfileUnit, error)
	RemoveUpgradeCharmProfileData() error
}

LXDProfileMachine describes machine-receiver state methods for executing a lxd profile upgrade.

type LXDProfileState

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

LXDProfileState implements the LXDProfileBackend indirection over state.State.

func (LXDProfileState) Machine

func (s LXDProfileState) Machine(id string) (LXDProfileMachine, error)

func (LXDProfileState) Unit

type LXDProfileUnit

type LXDProfileUnit interface {
	Tag() names.Tag
	AssignedMachineId() (string, error)
}

LXDProfileUnit describes unit-receiver state methods for executing a lxd profile upgrade.

type StatusAPI

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

StatusAPI is the uniter part that deals with setting/getting status from different entities, this particular separation from base is because we have a shim to support unit/agent split.

func NewStatusAPI

func NewStatusAPI(st *state.State, getCanModify common.GetAuthFunc) *StatusAPI

NewStatusAPI creates a new server-side Status setter API facade.

func (*StatusAPI) ApplicationStatus

func (s *StatusAPI) ApplicationStatus(args params.Entities) (params.ApplicationStatusResults, error)

ApplicationStatus returns the status of the Applications and its workloads if the given unit is the leader.

func (*StatusAPI) SetAgentStatus

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

SetAgentStatus will set status for agents of Units passed in args, if one of the args is not an Unit it will fail.

func (*StatusAPI) SetApplicationStatus

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

SetApplicationStatus sets the status for all the Services in args if the given Unit is the leader.

func (*StatusAPI) SetStatus

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

SetStatus will set status for a entities passed in args. If the entity is a Unit it will instead set status to its agent, to emulate backwards compatibility.

func (*StatusAPI) SetUnitStatus

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

SetUnitStatus sets status for all elements passed in args, the difference with SetStatus is that if an entity is a Unit it will set its status instead of its agent.

func (*StatusAPI) UnitStatus

func (s *StatusAPI) UnitStatus(args params.Entities) (params.StatusResults, error)

UnitStatus returns the workload status information for the unit.

type StorageAPI

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

StorageAPI provides access to the Storage API facade.

func (*StorageAPI) AddUnitStorage

func (s *StorageAPI) AddUnitStorage(
	args params.StoragesAddParams,
) (params.ErrorResults, error)

AddUnitStorage validates and creates additional storage instances for units. Failures on an individual storage instance do not block remaining instances from being processed.

func (*StorageAPI) DestroyUnitStorageAttachments

func (s *StorageAPI) DestroyUnitStorageAttachments(args params.Entities) (params.ErrorResults, error)

DestroyUnitStorageAttachments marks each storage attachment of the specified units as Dying.

func (*StorageAPI) RemoveStorageAttachments

func (s *StorageAPI) RemoveStorageAttachments(args params.StorageAttachmentIds) (params.ErrorResults, error)

RemoveStorageAttachments removes the specified storage attachments from state.

func (*StorageAPI) StorageAttachmentLife

func (s *StorageAPI) StorageAttachmentLife(args params.StorageAttachmentIds) (params.LifeResults, error)

StorageAttachmentLife returns the lifecycle state of the storage attachments with the specified tags.

func (*StorageAPI) StorageAttachments

StorageAttachments returns the storage attachments with the specified tags.

func (*StorageAPI) UnitStorageAttachments

func (s *StorageAPI) UnitStorageAttachments(args params.Entities) (params.StorageAttachmentIdsResults, error)

UnitStorageAttachments returns the IDs of storage attachments for a collection of units.

func (*StorageAPI) WatchStorageAttachments

func (s *StorageAPI) WatchStorageAttachments(args params.StorageAttachmentIds) (params.NotifyWatchResults, error)

WatchStorageAttachments creates watchers for a collection of storage attachments, each of which can be used to watch changes to storage attachment info.

func (*StorageAPI) WatchUnitStorageAttachments

func (s *StorageAPI) WatchUnitStorageAttachments(args params.Entities) (params.StringsWatchResults, error)

WatchUnitStorageAttachments creates watchers for a collection of units, each of which can be used to watch for lifecycle changes to the corresponding unit's storage attachments.

type Unit

type Unit interface {
	AssignedMachineId() (string, error)
	ShouldBeAssigned() bool
	StorageConstraints() (map[string]state.StorageConstraints, error)
}

type UniterAPI

UniterAPI implements the latest version (v9) of the Uniter API, which adds WatchConfigSettingsHash, WatchTrustConfigSettingsHash and WatchUnitAddressesHash.

func NewUniterAPI

func NewUniterAPI(context facade.Context) (*UniterAPI, error)

NewUniterAPI creates a new instance of the core Uniter API.

func (*UniterAPI) Actions

func (u *UniterAPI) Actions(args params.Entities) (params.ActionResults, error)

Actions returns the Actions by Tags passed and ensures that the Unit asking for them is the same Unit that has the Actions.

func (*UniterAPI) AddMetricBatches

func (u *UniterAPI) AddMetricBatches(args params.MetricBatchParams) (params.ErrorResults, error)

AddMetricBatches adds the metrics for the specified unit.

func (*UniterAPI) AllMachinePorts

func (u *UniterAPI) AllMachinePorts(args params.Entities) (params.MachinePortsResults, error)

AllMachinePorts returns all opened port ranges for each given machine (on all networks).

func (*UniterAPI) AssignedMachine

func (u *UniterAPI) AssignedMachine(args params.Entities) (params.StringResults, error)

AssignedMachine returns the machine tag for each given unit tag, or an error satisfying params.IsCodeNotAssigned when a unit has no assigned machine.

func (*UniterAPI) AvailabilityZone

func (u *UniterAPI) AvailabilityZone(args params.Entities) (params.StringResults, error)

AvailabilityZone returns the availability zone for each given unit, if applicable.

func (*UniterAPI) BeginActions

func (u *UniterAPI) BeginActions(args params.Entities) (params.ErrorResults, error)

BeginActions marks the actions represented by the passed in Tags as running.

func (*UniterAPI) CharmArchiveSha256

func (u *UniterAPI) CharmArchiveSha256(args params.CharmURLs) (params.StringResults, error)

CharmArchiveSha256 returns the SHA256 digest of the charm archive (bundle) data for each charm url in the given parameters.

func (*UniterAPI) CharmModifiedVersion

func (u *UniterAPI) CharmModifiedVersion(args params.Entities) (params.IntResults, error)

CharmModifiedVersion returns the most CharmModifiedVersion for all given units or applications.

func (*UniterAPI) CharmURL

func (u *UniterAPI) CharmURL(args params.Entities) (params.StringBoolResults, error)

CharmURL returns the charm URL for all given units or applications.

func (*UniterAPI) ClearResolved

func (u *UniterAPI) ClearResolved(args params.Entities) (params.ErrorResults, error)

ClearResolved removes any resolved setting from each given unit.

func (*UniterAPI) ClosePorts

ClosePorts sets the policy of the port range with protocol to be closed, for all given units.

func (*UniterAPI) CloudSpec

func (u *UniterAPI) CloudSpec() (params.CloudSpecResult, error)

CloudSpec returns the cloud spec used by the model in which the authenticated unit or application resides. A check is made beforehand to ensure that the request is made by an entity that has been granted the appropriate trust.

func (*UniterAPI) ConfigSettings

func (u *UniterAPI) ConfigSettings(args params.Entities) (params.ConfigSettingsResults, error)

ConfigSettings returns the complete set of application charm config settings available to each given unit.

func (*UniterAPI) CurrentModel

func (u *UniterAPI) CurrentModel() (params.ModelResult, error)

CurrentModel returns the name and UUID for the current juju model.

func (*UniterAPI) Destroy

func (u *UniterAPI) Destroy(args params.Entities) (params.ErrorResults, error)

Destroy advances all given Alive units' lifecycles as far as possible. See state/Unit.Destroy().

func (*UniterAPI) DestroyAllSubordinates

func (u *UniterAPI) DestroyAllSubordinates(args params.Entities) (params.ErrorResults, error)

DestroyAllSubordinates destroys all subordinates of each given unit.

func (*UniterAPI) EnterScope

func (u *UniterAPI) EnterScope(args params.RelationUnits) (params.ErrorResults, error)

EnterScope ensures each unit has entered its scope in the relation, for all of the given relation/unit pairs. See also state.RelationUnit.EnterScope().

func (*UniterAPI) FinishActions

func (u *UniterAPI) FinishActions(args params.ActionExecutionResults) (params.ErrorResults, error)

FinishActions saves the result of a completed Action

func (*UniterAPI) GetPrincipal

func (u *UniterAPI) GetPrincipal(args params.Entities) (params.StringBoolResults, error)

GetPrincipal returns the result of calling PrincipalName() and converting it to a tag, on each given unit.

func (*UniterAPI) GoalStates

func (u *UniterAPI) GoalStates(args params.Entities) (params.GoalStateResults, error)

GoalStates returns information of charm units and relations.

func (*UniterAPI) HasSubordinates

func (u *UniterAPI) HasSubordinates(args params.Entities) (params.BoolResults, error)

HasSubordinates returns the whether each given unit has any subordinates.

func (*UniterAPI) LeaveScope

func (u *UniterAPI) LeaveScope(args params.RelationUnits) (params.ErrorResults, error)

LeaveScope signals each unit has left its scope in the relation, for all of the given relation/unit pairs. See also state.RelationUnit.LeaveScope().

func (*UniterAPI) NetworkInfo

NetworkInfo returns network interfaces/addresses for specified bindings.

func (*UniterAPI) OpenPorts

OpenPorts sets the policy of the port range with protocol to be opened, for all given units.

func (*UniterAPI) PrivateAddress

func (u *UniterAPI) PrivateAddress(args params.Entities) (params.StringResults, error)

PrivateAddress returns the private address for each given unit, if set.

func (*UniterAPI) ProviderType

func (u *UniterAPI) ProviderType() (params.StringResult, error)

ProviderType returns the provider type used by the current juju model.

TODO(dimitern): Refactor the uniter to call this instead of calling ModelConfig() just to get the provider type. Once we have machine addresses, this might be completely unnecessary though.

func (*UniterAPI) PublicAddress

func (u *UniterAPI) PublicAddress(args params.Entities) (params.StringResults, error)

PublicAddress returns the public address for each given unit, if set.

func (*UniterAPI) ReadRemoteSettings

func (u *UniterAPI) ReadRemoteSettings(args params.RelationUnitPairs) (params.SettingsResults, error)

ReadRemoteSettings returns the remote settings of each given set of relation/local unit/remote unit.

func (*UniterAPI) ReadSettings

func (u *UniterAPI) ReadSettings(args params.RelationUnits) (params.SettingsResults, error)

ReadSettings returns the local settings of each given set of relation/unit.

func (*UniterAPI) Refresh

Refresh retrieves the latest values for attributes on this unit.

func (*UniterAPI) Relation

Relation returns information about all given relation/unit pairs, including their id, key and the local endpoint.

func (*UniterAPI) RelationById

func (u *UniterAPI) RelationById(args params.RelationIds) (params.RelationResults, error)

RelationById returns information about all given relations, specified by their ids, including their key and the local endpoint.

func (*UniterAPI) RelationsStatus

func (u *UniterAPI) RelationsStatus(args params.Entities) (params.RelationUnitStatusResults, error)

RelationsStatus returns for each unit the corresponding relation and status information.

func (*UniterAPI) Resolved

Resolved returns the current resolved setting for each given unit.

func (*UniterAPI) SLALevel

func (u *UniterAPI) SLALevel() (params.StringResult, error)

SLALevel returns the model's SLA level.

func (*UniterAPI) SetCharmURL

func (u *UniterAPI) SetCharmURL(args params.EntitiesCharmURL) (params.ErrorResults, error)

SetCharmURL sets the charm URL for each given unit. An error will be returned if a unit is dead, or the charm URL is not know.

func (*UniterAPI) SetPodSpec

func (u *UniterAPI) SetPodSpec(args params.SetPodSpecParams) (params.ErrorResults, error)

SetPodSpec sets the pod specs for a set of applications.

func (*UniterAPI) SetRelationStatus

func (u *UniterAPI) SetRelationStatus(args params.RelationStatusArgs) (params.ErrorResults, error)

SetRelationStatus updates the status of the specified relations.

func (*UniterAPI) SetWorkloadVersion

func (u *UniterAPI) SetWorkloadVersion(args params.EntityWorkloadVersions) (params.ErrorResults, error)

SetWorkloadVersion sets the workload version for each given unit. An error will be returned if a unit is dead.

func (*UniterAPI) UpdateSettings

func (u *UniterAPI) UpdateSettings(args params.RelationUnitsSettings) (params.ErrorResults, error)

UpdateSettings persists all changes made to the local settings of all given pairs of relation and unit. Keys with empty values are considered a signal to delete these values.

func (*UniterAPI) WatchActionNotifications

func (u *UniterAPI) WatchActionNotifications(args params.Entities) (params.StringsWatchResults, error)

WatchActionNotifications returns a StringsWatcher for observing incoming action calls to a unit. See also state/watcher.go Unit.WatchActionNotifications(). This method is called from api/uniter/uniter.go WatchActionNotifications().

func (*UniterAPI) WatchConfigSettingsHash

func (u *UniterAPI) WatchConfigSettingsHash(args params.Entities) (params.StringsWatchResults, error)

WatchConfigSettingsHash returns a StringsWatcher that yields a hash of the config values every time the config changes. The uniter can save this hash and use it to decide whether the config-changed hook needs to be run (or whether this was just an agent restart with no substantive config change).

func (*UniterAPI) WatchRelationUnits

func (u *UniterAPI) WatchRelationUnits(args params.RelationUnits) (params.RelationUnitsWatchResults, error)

WatchRelationUnits returns a RelationUnitsWatcher for observing changes to every unit in the supplied relation that is visible to the supplied unit. See also state/watcher.go:RelationUnit.Watch().

func (*UniterAPI) WatchTrustConfigSettingsHash

func (u *UniterAPI) WatchTrustConfigSettingsHash(args params.Entities) (params.StringsWatchResults, error)

WatchTrustConfigSettingsHash returns a StringsWatcher that yields a hash of the application config values whenever they change. The uniter can use the hash to determine whether the actual values have changed since it last saw the config.

func (*UniterAPI) WatchUnitAddressesHash

func (u *UniterAPI) WatchUnitAddressesHash(args params.Entities) (params.StringsWatchResults, error)

WatchUnitAddressesHash returns a StringsWatcher that yields the hashes of the addresses for the unit whenever the addresses change. The uniter can use the hash to determine whether the actual address values have changed since it last saw the config.

func (*UniterAPI) WatchUnitRelations

func (u *UniterAPI) WatchUnitRelations(args params.Entities) (params.StringsWatchResults, error)

WatchUnitRelations returns a StringsWatcher, for each given unit, that notifies of changes to the lifecycles of relations relevant to that unit. For principal units, this will be all of the relations for the application. For subordinate units, only relations with the principal unit's application will be monitored.

func (*UniterAPI) WorkloadVersion

func (u *UniterAPI) WorkloadVersion(args params.Entities) (params.StringResults, error)

WorkloadVersion returns the workload version for all given units or applications.

type UniterAPIV4

type UniterAPIV4 struct {
	UniterAPIV5
}

UniterAPIV4 has old WatchApplicationRelations and NetworkConfig methods, and doesn't have the new SLALevel, NetworkInfo or WatchUnitRelations methods.

func NewUniterAPIV4

func NewUniterAPIV4(context facade.Context) (*UniterAPIV4, error)

NewUniterAPIV4 creates an instance of the V4 uniter API.

func (*UniterAPIV4) NetworkConfig

NetworkConfig returns information about all given relation/unit pairs, including their id, key and the local endpoint. It's not included in APIv5 TODO(wpk): NetworkConfig API is obsoleted by Uniter.NetworkInfo

func (*UniterAPIV4) NetworkInfo

func (u *UniterAPIV4) NetworkInfo(_, _ struct{})

NetworkInfo isn't on the V4 API.

func (*UniterAPIV4) SLALevel

func (u *UniterAPIV4) SLALevel(_, _ struct{})

SLALevel isn't on the V4 API.

func (*UniterAPIV4) WatchApplicationRelations

func (u *UniterAPIV4) WatchApplicationRelations(args params.Entities) (params.StringsWatchResults, error)

WatchApplicationRelations returns a StringsWatcher, for each given application, that notifies of changes to the lifecycles of relations involving that application. This method is obsolete - it's been replaced by WatchUnitRelations in V5 of the uniter API.

func (*UniterAPIV4) WatchUnitRelations

func (u *UniterAPIV4) WatchUnitRelations(_, _ struct{})

WatchUnitRelations isn't on the V4 API.

type UniterAPIV5

type UniterAPIV5 struct {
	UniterAPIV6
}

UniterAPIV5 returns a RelationResultsV5 instead of RelationResults from Relation and RelationById - elements don't have an OtherApplication field.

func NewUniterAPIV5

func NewUniterAPIV5(context facade.Context) (*UniterAPIV5, error)

NewUniterAPIV5 creates an instance of the V5 uniter API.

func (*UniterAPIV5) Relation

Relation returns information about all given relation/unit pairs, including their id, key and the local endpoint (without other application name).

func (*UniterAPIV5) RelationById

func (u *UniterAPIV5) RelationById(args params.RelationIds) (params.RelationResultsV5, error)

RelationById returns information about all given relations, specified by their ids, including their key and the local endpoint (without other application name).

type UniterAPIV6

type UniterAPIV6 struct {
	UniterAPIV7
}

UniterAPIV6 adds NetworkInfo as a preferred method to calling NetworkConfig.

func NewUniterAPIV6

func NewUniterAPIV6(context facade.Context) (*UniterAPIV6, error)

NewUniterAPIV6 creates an instance of the V6 uniter API.

func (*UniterAPIV6) JoinedRelations

func (u *UniterAPIV6) JoinedRelations(args params.Entities) (params.StringsResults, error)

JoinedRelations returns the tags of all relations for which each supplied unit has entered scope. TODO(wallyworld) - this API is replaced by RelationsStatus

func (*UniterAPIV6) NetworkInfo

Network Info implements UniterAPIV6 version of NetworkInfo by constructing an API V6 compatible result.

type UniterAPIV7

type UniterAPIV7 struct {
	UniterAPIV8
}

UniterAPIV7 adds CMR support to NetworkInfo.

func NewUniterAPIV7

func NewUniterAPIV7(context facade.Context) (*UniterAPIV7, error)

NewUniterAPIV7 creates an instance of the V7 uniter API.

func (*UniterAPIV7) SetPodSpec

func (u *UniterAPIV7) SetPodSpec(_, _ struct{})

SetPodSpec isn't on the v7 API.

type UniterAPIV8

type UniterAPIV8 struct {
	UniterAPI
}

UniterAPIV8 adds SetContainerSpec, GoalStates, CloudSpec, WatchTrustConfigSettings, WatchActionNotifications, UpgradeSeriesStatus, SetUpgradeSeriesStatus.

func NewUniterAPIV8

func NewUniterAPIV8(context facade.Context) (*UniterAPIV8, error)

NewUniterAPIV8 creates an instance of the V8 uniter API.

func (*UniterAPIV8) WatchConfigSettings

func (u *UniterAPIV8) WatchConfigSettings(args params.Entities) (params.NotifyWatchResults, error)

WatchConfigSettings returns a NotifyWatcher for observing changes to each unit's application configuration settings. See also state/watcher.go:Unit.WatchConfigSettings().

func (*UniterAPIV8) WatchConfigSettingsHash

func (u *UniterAPIV8) WatchConfigSettingsHash(_, _ struct{})

WatchConfigSettingsHash isn't on the v8 API.

func (*UniterAPIV8) WatchSettings

func (u *UniterAPIV8) WatchSettings(args params.Entities, configWatcherFn func(u *state.Unit) (state.NotifyWatcher, error)) (params.NotifyWatchResults, error)

func (*UniterAPIV8) WatchTrustConfigSettings

func (u *UniterAPIV8) WatchTrustConfigSettings(args params.Entities) (params.NotifyWatchResults, error)

func (*UniterAPIV8) WatchTrustConfigSettingsHash

func (u *UniterAPIV8) WatchTrustConfigSettingsHash(_, _ struct{})

WatchTrustConfigSettingsHash isn't on the v8 API.

func (*UniterAPIV8) WatchUnitAddresses

func (u *UniterAPIV8) WatchUnitAddresses(args params.Entities) (params.NotifyWatchResults, error)

WatchUnitAddresses returns a NotifyWatcher for observing changes to each unit's addresses.

func (*UniterAPIV8) WatchUnitAddressesHash

func (u *UniterAPIV8) WatchUnitAddressesHash(_, _ struct{})

WatchUnitAddressesHash isn't on the v8 API.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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