Documentation ¶
Overview ¶
Package state enables reading, observing, and changing the state stored in MongoDB of a whole environment managed by juju.
Index ¶
- Constants
- Variables
- func AddAvailabilityZoneToInstanceData(st *State, azFunc func(*State, instance.Id) (string, error)) error
- func AddBindingToFilesystems(st *State) error
- func AddBindingToVolumes(st *State) error
- func AddCharmStoragePaths(st *State, storagePaths map[*charm.URL]string) error
- func AddDefaultBlockDevicesDocs(st *State) error
- func AddEnvUUIDToAnnotations(st *State) error
- func AddEnvUUIDToCharms(st *State) error
- func AddEnvUUIDToCleanups(st *State) error
- func AddEnvUUIDToConstraints(st *State) error
- func AddEnvUUIDToContainerRefs(st *State) error
- func AddEnvUUIDToEnvUsersDoc(st *State) error
- func AddEnvUUIDToInstanceData(st *State) error
- func AddEnvUUIDToMachines(st *State) error
- func AddEnvUUIDToMeterStatus(st *State) error
- func AddEnvUUIDToMinUnits(st *State) error
- func AddEnvUUIDToNetworkInterfaces(st *State) error
- func AddEnvUUIDToNetworks(st *State) error
- func AddEnvUUIDToOpenPorts(st *State) error
- func AddEnvUUIDToReboots(st *State) error
- func AddEnvUUIDToRelationScopes(st *State) error
- func AddEnvUUIDToRelations(st *State) error
- func AddEnvUUIDToRequestedNetworks(st *State) error
- func AddEnvUUIDToSequences(st *State) error
- func AddEnvUUIDToServices(st *State) error
- func AddEnvUUIDToSettings(st *State) error
- func AddEnvUUIDToSettingsRefs(st *State) error
- func AddEnvUUIDToStatuses(st *State) error
- func AddEnvUUIDToUnits(st *State) error
- func AddEnvironmentUUIDToStateServerDoc(st *State) error
- func AddFilesystemStatus(st *State) error
- func AddFilesystemsAttachmentCount(st *State) error
- func AddInstanceIdFieldOfIPAddresses(st *State) error
- func AddLeadershipSettingsDocs(st *State) error
- func AddLifeFieldOfIPAddresses(st *State) error
- func AddMissingEnvUUIDOnStatuses(st *State) error
- func AddMissingServiceStatuses(st *State) error
- func AddNameFieldLowerCaseIdOfUsers(st *State) error
- func AddPreferredAddressesToMachines(st *State) error
- func AddStateUsersAsEnvironUsers(st *State) error
- func AddUUIDToIPAddresses(st *State) error
- func AddUniqueOwnerEnvNameForEnvirons(st *State) error
- func AddVolumeAttachmentCount(st *State) error
- func AddVolumeStatus(st *State) error
- func ChangeStatusHistoryEntityId(st *State) error
- func ChangeStatusHistoryUpdatedType(st *State) error
- func ChangeStatusUpdatedType(st *State) error
- func ContainerTypeFromId(machineId string) instance.ContainerType
- func CreateUnitMeterStatus(st *State) error
- func DropOldIndexesv123(st *State) error
- func FixMinUnitsEnvUUID(st *State) error
- func FixSequenceFields(st *State) error
- func InitDbLogs(session *mgo.Session) error
- func IsCharmAlreadyUploadedError(err interface{}) bool
- func IsContainsFilesystem(err error) bool
- func IsHasAssignedUnitsError(err error) bool
- func IsHasAttachmentsError(err error) bool
- func IsHasContainersError(err error) bool
- func IsNeverConnectedError(err error) bool
- func IsNeverLoggedInError(err error) bool
- func IsUpgradeInProgressError(err error) bool
- func IsVersionInconsistentError(e interface{}) bool
- func LowerCaseEnvUsersID(st *State) error
- func MigrateJobManageNetworking(st *State) error
- func MigrateLastLoginAndLastConnection(st *State) error
- func MigrateMachineInstanceIdToInstanceData(st *State) error
- func MigrateSettingsSchema(st *State) error
- func MigrateUnitPortsToOpenedPorts(st *State) error
- func MigrateUserLastConnectionToLastLogin(st *State) error
- func MoveServiceUnitSeqToSequence(st *State) error
- func NestingLevel(machineId string) int
- func ParentId(machineId string) string
- func ParseFilesystemAttachmentId(id string) (names.MachineTag, names.FilesystemTag, error)
- func ParseVolumeAttachmentId(id string) (names.MachineTag, names.VolumeTag, error)
- func PruneLogs(st LoggingState, minLogTime time.Time, maxLogsMB int) error
- func PruneStatusHistory(st *State, maxLogsPerEntity int) error
- func ServiceInstances(st *State, service string) ([]instance.Id, error)
- func SetHostedEnvironCount(st *State) error
- func SetOwnerAndServerUUIDForEnvironment(st *State) error
- func SetSystemIdentity(st *State, identity string) error
- func TopParentId(machineId string) string
- func ValidWorkloadStatus(status Status) bool
- type Action
- func (a *Action) ActionTag() names.ActionTag
- func (a *Action) Begin() (*Action, error)
- func (a *Action) Completed() time.Time
- func (a *Action) Enqueued() time.Time
- func (a *Action) Finish(results ActionResults) (*Action, error)
- func (a *Action) Id() string
- func (a *Action) Name() string
- func (a *Action) Parameters() map[string]interface{}
- func (a *Action) Receiver() string
- func (a *Action) Results() (map[string]interface{}, string)
- func (a *Action) Started() time.Time
- func (a *Action) Status() ActionStatus
- func (a *Action) Tag() names.Tag
- func (a *Action) ValidateTag() bool
- type ActionReceiver
- type ActionResults
- type ActionSpecsByName
- type ActionStatus
- type ActionsWatcher
- type AddressState
- type AgentEntity
- type AgentLiving
- type AgentTooler
- type AssignmentPolicy
- type Authenticator
- type Backing
- type BatchParam
- type Block
- type BlockDevice
- type BlockDeviceInfo
- type BlockType
- type Charm
- func (c *Charm) Actions() *charm.Actions
- 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) Metrics() *charm.Metrics
- func (c *Charm) Revision() int
- func (c *Charm) StoragePath() string
- func (c *Charm) String() string
- func (c *Charm) Tag() names.Tag
- func (c *Charm) URL() *charm.URL
- type ConfigValidator
- type Database
- type DbLogger
- type DeployerConnectionValues
- type Endpoint
- type EnsureDeader
- type Entity
- type EntityFinder
- type EntityWithService
- type EnvironAccessor
- type EnvironCapability
- type EnvironConfigWatcher
- type EnvironMachinesWatcher
- type Environment
- func (e *Environment) Config() (*config.Config, error)
- func (e *Environment) Destroy() (err error)
- func (e *Environment) EnvironTag() names.EnvironTag
- func (e *Environment) LatestToolsVersion() version.Number
- func (e *Environment) Life() Life
- func (e *Environment) Name() string
- func (e *Environment) Owner() names.UserTag
- func (e *Environment) Refresh() error
- func (e *Environment) ServerTag() names.EnvironTag
- func (e *Environment) ServerUUID() string
- func (e *Environment) Tag() names.Tag
- func (e *Environment) UUID() string
- func (e *Environment) UpdateLatestToolsVersion(ver version.Number) error
- func (e *Environment) Users() ([]*EnvironmentUser, error)
- func (e *Environment) Watch() NotifyWatcher
- type EnvironmentUser
- func (e *EnvironmentUser) CreatedBy() string
- func (e *EnvironmentUser) DateCreated() time.Time
- func (e *EnvironmentUser) DisplayName() string
- func (e *EnvironmentUser) EnvironmentTag() names.EnvironTag
- func (e *EnvironmentUser) ID() string
- func (e *EnvironmentUser) LastConnection() (time.Time, error)
- func (e *EnvironmentUser) UpdateLastConnection() error
- func (e *EnvironmentUser) UserName() string
- func (e *EnvironmentUser) UserTag() names.UserTag
- type ErrCharmAlreadyUploaded
- type Filesystem
- type FilesystemAttachment
- type FilesystemAttachmentInfo
- type FilesystemAttachmentParams
- type FilesystemInfo
- type FilesystemParams
- type GlobalEntity
- type HasAssignedUnitsError
- type HasAttachmentsError
- type HasContainersError
- type IPAddress
- func (i *IPAddress) Address() network.Address
- func (i *IPAddress) AllocateTo(machineId, interfaceId, macAddress string) (err error)
- func (i *IPAddress) EnsureDead() (err error)
- func (i *IPAddress) GoString() string
- func (i *IPAddress) Id() string
- func (i *IPAddress) InstanceId() instance.Id
- func (i *IPAddress) InterfaceId() string
- func (i *IPAddress) Life() Life
- func (i *IPAddress) MACAddress() string
- func (i *IPAddress) MachineId() string
- func (i *IPAddress) Refresh() error
- func (i *IPAddress) Remove() (err error)
- func (i *IPAddress) Scope() network.Scope
- func (i *IPAddress) SetState(newState AddressState) (err error)
- func (i *IPAddress) State() AddressState
- func (i *IPAddress) String() string
- func (i *IPAddress) SubnetId() string
- func (i *IPAddress) Tag() names.Tag
- func (i *IPAddress) Type() network.AddressType
- func (i *IPAddress) UUID() (utils.UUID, error)
- func (i *IPAddress) Value() string
- type InstanceDistributor
- type InstanceIdGetter
- type ItemChange
- type Life
- type LifeBinder
- type Lifer
- type Living
- type LogRecord
- type LogTailer
- type LogTailerParams
- type LoggingState
- type Machine
- func (m *Machine) AddNetworkInterface(args NetworkInterfaceInfo) (iface *NetworkInterface, err error)
- func (m *Machine) Addresses() (addresses []network.Address)
- func (m *Machine) AgentPresence() (bool, error)
- func (m *Machine) AgentTools() (*tools.Tools, error)
- func (m *Machine) AllPorts() ([]*Ports, error)
- func (m *Machine) AvailabilityZone() (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) GetRebootFlag() (bool, 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) IsContainer() bool
- 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 []network.Address)
- func (m *Machine) MachineTag() names.MachineTag
- func (m *Machine) NetworkInterfaces() ([]*NetworkInterface, error)
- func (m *Machine) Networks() ([]*Network, error)
- func (m *Machine) OpenedPorts(networkName string) (*Ports, error)
- func (m *Machine) ParentId() (string, bool)
- func (m *Machine) PasswordValid(password string) bool
- func (m *Machine) Placement() string
- func (m *Machine) PrivateAddress() (network.Address, error)
- func (m *Machine) ProviderAddresses() (addresses []network.Address)
- func (m *Machine) PublicAddress() (network.Address, error)
- func (m *Machine) Refresh() error
- func (m *Machine) Remove() (err error)
- func (m *Machine) RequestedNetworks() ([]string, error)
- func (m *Machine) Series() string
- func (m *Machine) SetAgentPresence() (*presence.Pinger, error)
- func (m *Machine) SetAgentVersion(v version.Binary) (err error)
- func (m *Machine) SetConstraints(cons constraints.Value) (err error)
- func (m *Machine) SetHasVote(hasVote bool) error
- func (m *Machine) SetInstanceInfo(id instance.Id, nonce string, ...) error
- func (m *Machine) SetInstanceStatus(status string) (err error)
- func (m *Machine) SetMachineAddresses(addresses ...network.Address) (err error)
- func (m *Machine) SetMachineBlockDevices(info ...BlockDeviceInfo) error
- func (m *Machine) SetMongoPassword(password string) error
- func (m *Machine) SetPassword(password string) error
- func (m *Machine) SetProviderAddresses(addresses ...network.Address) (err error)
- func (m *Machine) SetProvisioned(id instance.Id, nonce string, ...) (err error)
- func (m *Machine) SetRebootFlag(flag bool) error
- func (m *Machine) SetStatus(status Status, info string, data map[string]interface{}) error
- func (m *Machine) SetSupportedContainers(containers []instance.ContainerType) (err error)
- func (m *Machine) ShouldRebootOrShutdown() (RebootAction, error)
- func (m *Machine) Status() (StatusInfo, error)
- func (m *Machine) String() string
- func (m *Machine) SupportedContainers() ([]instance.ContainerType, bool)
- func (m *Machine) SupportsNoContainers() (err error)
- func (m *Machine) Tag() names.Tag
- func (m *Machine) Units() (units []*Unit, err error)
- func (m *Machine) VolumeAttachments() ([]VolumeAttachment, error)
- func (m *Machine) WaitAgentPresence(timeout time.Duration) (err error)
- func (m *Machine) WantsVote() bool
- func (m *Machine) Watch() NotifyWatcher
- func (m *Machine) WatchAddresses() NotifyWatcher
- func (m *Machine) WatchAllContainers() StringsWatcher
- func (m *Machine) WatchContainers(ctype instance.ContainerType) StringsWatcher
- func (m *Machine) WatchForRebootEvent() (NotifyWatcher, error)
- func (m *Machine) WatchHardwareCharacteristics() NotifyWatcher
- func (m *Machine) WatchInterfaces() NotifyWatcher
- func (m *Machine) WatchPrincipalUnits() StringsWatcher
- func (m *Machine) WatchUnits() StringsWatcher
- type MachineFilesystemParams
- type MachineJob
- type MachineTemplate
- type MachineVolumeParams
- type MeterStatus
- type MeterStatusCode
- type Metric
- type MetricBatch
- func (m *MetricBatch) CharmURL() string
- func (m *MetricBatch) Created() time.Time
- func (m *MetricBatch) Credentials() []byte
- func (m *MetricBatch) EnvUUID() string
- func (m *MetricBatch) MarshalJSON() ([]byte, error)
- func (m *MetricBatch) Metrics() []Metric
- func (m *MetricBatch) Sent() bool
- func (m *MetricBatch) SetSent() error
- func (m *MetricBatch) UUID() string
- func (m *MetricBatch) Unit() string
- type MetricsManager
- func (m *MetricsManager) ConsecutiveErrors() int
- func (m *MetricsManager) DocID() string
- func (m *MetricsManager) EnvUUID() string
- func (m *MetricsManager) GracePeriod() time.Duration
- func (m *MetricsManager) IncrementConsecutiveErrors() error
- func (m *MetricsManager) LastSuccessfulSend() time.Time
- func (m *MetricsManager) MeterStatus() MeterStatus
- func (m *MetricsManager) SetGracePeriod(t time.Duration) error
- func (m *MetricsManager) SetLastSuccessfulSend(t time.Time) error
- type Multiwatcher
- type Network
- type NetworkInfo
- type NetworkInterface
- func (ni *NetworkInterface) Disable() (err error)
- func (ni *NetworkInterface) Enable() (err error)
- func (ni *NetworkInterface) GoString() string
- func (ni *NetworkInterface) Id() string
- func (ni *NetworkInterface) InterfaceName() string
- func (ni *NetworkInterface) IsDisabled() bool
- func (ni *NetworkInterface) IsPhysical() bool
- func (ni *NetworkInterface) IsVirtual() bool
- func (ni *NetworkInterface) MACAddress() string
- func (ni *NetworkInterface) MachineId() string
- func (ni *NetworkInterface) MachineTag() names.MachineTag
- func (ni *NetworkInterface) NetworkName() string
- func (ni *NetworkInterface) NetworkTag() names.NetworkTag
- func (ni *NetworkInterface) RawInterfaceName() string
- func (ni *NetworkInterface) Refresh() error
- func (ni *NetworkInterface) Remove() (err error)
- type NetworkInterfaceInfo
- type NeverConnectedError
- type NeverLoggedInError
- type NotifyWatcher
- type NotifyWatcherFactory
- type Policy
- type PortRange
- type Ports
- func (p *Ports) AllPortRanges() map[network.PortRange]string
- func (p *Ports) ClosePorts(portRange PortRange) (err error)
- func (p *Ports) GlobalKey() string
- func (p *Ports) NetworkName() string
- func (p *Ports) OpenPorts(portRange PortRange) (err error)
- func (p *Ports) PortsForUnit(unit string) []PortRange
- func (p *Ports) Refresh() error
- func (p *Ports) Remove() error
- func (p *Ports) String() string
- type Prechecker
- type RebootAction
- type RebootActionGetter
- type RebootFlagSetter
- type Relation
- func (r *Relation) Destroy() (err error)
- func (r *Relation) Endpoint(serviceName string) (Endpoint, error)
- func (r *Relation) Endpoints() []Endpoint
- 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() names.Tag
- 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) Joined() (bool, error)
- func (ru *RelationUnit) LeaveScope() error
- func (ru *RelationUnit) PrepareLeaveScope() error
- func (ru *RelationUnit) PrivateAddress() (network.Address, error)
- 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 RestoreInfo
- type RestoreStatus
- type Service
- func (s *Service) AddUnit() (unit *Unit, err error)
- func (s *Service) AllUnits() (units []*Unit, err 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) LeaderSettings() (map[string]string, error)
- func (s *Service) Life() Life
- func (s *Service) MetricCredentials() []byte
- func (s *Service) MinUnits() int
- func (s *Service) Name() string
- func (s *Service) Networks() ([]string, error)
- func (s *Service) Refresh() error
- func (s *Service) Relations() (relations []*Relation, err error)
- func (s *Service) ServiceAndUnitsStatus() (StatusInfo, map[string]StatusInfo, error)
- func (s *Service) SetCharm(ch *Charm, force bool) error
- func (s *Service) SetConstraints(cons constraints.Value) (err error)
- func (s *Service) SetExposed() error
- func (s *Service) SetMetricCredentials(b []byte) error
- func (s *Service) SetMinUnits(minUnits int) (err error)
- func (s *Service) SetStatus(status Status, info string, data map[string]interface{}) error
- func (s *Service) Status() (StatusInfo, error)
- func (s *Service) StorageConstraints() (map[string]StorageConstraints, error)
- func (s *Service) String() string
- func (s *Service) Tag() names.Tag
- func (s *Service) UpdateConfigSettings(changes charm.Settings) error
- func (s *Service) UpdateLeaderSettings(token leadership.Token, updates map[string]string) error
- func (s *Service) Watch() NotifyWatcher
- func (s *Service) WatchLeaderSettings() NotifyWatcher
- func (s *Service) WatchRelations() StringsWatcher
- func (s *Service) WatchUnits() StringsWatcher
- type SessionCloser
- 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 Space
- type State
- func (st *State) APIAddressesFromMachines() ([]string, error)
- func (st *State) APIHostPorts() ([][]network.HostPort, error)
- func (st *State) AbortCurrentUpgrade() error
- func (st *State) Action(id string) (*Action, error)
- func (st *State) ActionByTag(tag names.ActionTag) (*Action, error)
- func (st *State) AddCharm(ch charm.Charm, curl *charm.URL, storagePath, bundleSha256 string) (stch *Charm, err error)
- func (st *State) AddEnvironmentUser(user, createdBy names.UserTag, displayName string) (*EnvironmentUser, error)
- func (st *State) AddIPAddress(addr network.Address, subnetID string) (*IPAddress, 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) AddMetrics(batch BatchParam) (*MetricBatch, error)
- func (st *State) AddNetwork(args NetworkInfo) (n *Network, 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, owner string, ch *Charm, networks []string, ...) (service *Service, err error)
- func (st *State) AddSpace(name string, subnets []string, isPublic bool) (newSpace *Space, err error)
- func (st *State) AddStorageForUnit(tag names.UnitTag, name string, cons StorageConstraints) error
- func (st *State) AddStoreCharmPlaceholder(curl *charm.URL) (err error)
- func (st *State) AddSubnet(args SubnetInfo) (subnet *Subnet, err error)
- func (st *State) AddUser(name, displayName, password, creator string) (*User, error)
- func (st *State) Addresses() ([]string, error)
- func (st *State) AllBlocks() ([]Block, error)
- func (st *State) AllBlocksForSystem() ([]Block, error)
- func (st *State) AllCharms() ([]*Charm, error)
- func (st *State) AllEnvironments() ([]*Environment, error)
- func (st *State) AllFilesystems() ([]Filesystem, error)
- func (st *State) AllMachines() (machines []*Machine, err error)
- func (st *State) AllNetworks() (networks []*Network, err error)
- func (st *State) AllRelations() (relations []*Relation, err error)
- func (st *State) AllServices() (services []*Service, err error)
- func (st *State) AllSpaces() ([]*Space, error)
- func (st *State) AllStorageInstances() (storageInstances []StorageInstance, err error)
- func (st *State) AllSubnets() (subnets []*Subnet, err error)
- func (st *State) AllUsers(includeDeactivated bool) ([]*User, error)
- func (st *State) AllVolumes() ([]Volume, error)
- func (st *State) AllocatedIPAddresses(machineId string) ([]*IPAddress, error)
- func (st *State) Annotation(entity GlobalEntity, key string) (string, error)
- func (st *State) Annotations(entity GlobalEntity) (map[string]string, error)
- func (st *State) AssignUnit(u *Unit, policy AssignmentPolicy) (err error)
- func (st *State) BlockDevices(machine names.MachineTag) ([]BlockDeviceInfo, error)
- func (st *State) CACert() string
- func (st *State) Charm(curl *charm.URL) (*Charm, error)
- func (st *State) Cleanup() (err error)
- func (st *State) CleanupOldMetrics() error
- func (st *State) ClearUpgradeInfo() error
- func (st *State) Close() (err error)
- func (st *State) CountOfSentMetrics() (int, error)
- func (st *State) CountOfUnsentMetrics() (int, error)
- func (st *State) DeadIPAddresses() ([]*IPAddress, error)
- func (st *State) DeployerConnectionInfo() (*DeployerConnectionValues, error)
- func (st *State) DestroyFilesystem(tag names.FilesystemTag) (err error)
- func (st *State) DestroyStorageAttachment(storage names.StorageTag, unit names.UnitTag) (err error)
- func (st *State) DestroyStorageInstance(tag names.StorageTag) (err error)
- func (st *State) DestroyUnitStorageAttachments(unit names.UnitTag) (err error)
- func (st *State) DestroyVolume(tag names.VolumeTag) (err error)
- func (st *State) DetachFilesystem(machine names.MachineTag, filesystem names.FilesystemTag) (err error)
- func (st *State) DetachVolume(machine names.MachineTag, volume names.VolumeTag) (err error)
- func (st *State) EndpointsRelation(endpoints ...Endpoint) (*Relation, error)
- func (st *State) EnqueueAction(receiver names.Tag, actionName string, payload map[string]interface{}) (*Action, error)
- func (st *State) EnsureAvailability(numStateServers int, cons constraints.Value, series string, placement []string) (StateServersChanges, error)
- func (st *State) EnsureEnvironmentRemoved() error
- func (st *State) EnsureUpgradeInfo(machineId string, previousVersion, targetVersion version.Number) (*UpgradeInfo, error)
- func (st *State) EnvironConfig() (*config.Config, error)
- func (st *State) EnvironConstraints() (constraints.Value, error)
- func (st *State) EnvironTag() names.EnvironTag
- func (st *State) EnvironUUID() string
- func (st *State) Environment() (*Environment, error)
- func (st *State) EnvironmentUser(user names.UserTag) (*EnvironmentUser, error)
- func (st *State) EnvironmentsForUser(user names.UserTag) ([]*UserEnvironment, error)
- func (st *State) Filesystem(tag names.FilesystemTag) (Filesystem, error)
- func (st *State) FilesystemAttachment(machine names.MachineTag, filesystem names.FilesystemTag) (FilesystemAttachment, error)
- func (st *State) FilesystemAttachments(filesystem names.FilesystemTag) ([]FilesystemAttachment, error)
- func (st *State) FilesystemStatus(tag names.FilesystemTag) (StatusInfo, error)
- func (st *State) FindActionTagsByPrefix(prefix string) []names.ActionTag
- func (st *State) FindEntity(tag names.Tag) (Entity, error)
- func (st *State) ForEnviron(env names.EnvironTag) (*State, error)
- func (st *State) GetBlockForType(t BlockType) (Block, bool, error)
- func (st *State) GetEnvironment(tag names.EnvironTag) (*Environment, error)
- func (st *State) HackLeadership()
- func (st *State) IPAddress(value string) (*IPAddress, error)
- func (st *State) IPAddressByTag(tag names.IPAddressTag) (*IPAddress, error)
- func (st *State) ImageStorage() imagestorage.Storage
- func (st *State) InferEndpoints(names ...string) ([]Endpoint, error)
- func (st *State) IsStateServer() bool
- func (st *State) IsSystemAdministrator(user names.UserTag) (bool, error)
- func (st *State) IsUpgrading() (bool, error)
- func (st *State) KeyRelation(key string) (*Relation, error)
- func (st *State) LatestPlaceholderCharm(curl *charm.URL) (*Charm, error)
- func (st *State) LeadershipChecker() leadership.Checker
- func (st *State) LeadershipClaimer() leadership.Claimer
- func (st *State) Machine(id string) (*Machine, error)
- func (st *State) MachineFilesystemAttachments(machine names.MachineTag) ([]FilesystemAttachment, error)
- func (st *State) MachineVolumeAttachments(machine names.MachineTag) ([]VolumeAttachment, error)
- func (st *State) MaybePruneTransactions() error
- func (st *State) MetricBatch(id string) (*MetricBatch, error)
- func (st *State) MetricBatches() ([]MetricBatch, error)
- func (st *State) MetricsManager() (*MetricsManager, error)
- func (st *State) MetricsToSend(batchSize int) ([]*MetricBatch, error)
- func (st *State) MongoConnectionInfo() *mongo.MongoInfo
- func (st *State) MongoSession() *mgo.Session
- func (st *State) NeedsCleanup() (bool, error)
- func (st *State) Network(name string) (*Network, error)
- func (st *State) NewEnvironment(cfg *config.Config, owner names.UserTag) (_ *Environment, _ *State, err 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) ReadSettings(key string) (*Settings, error)
- func (st *State) Relation(id int) (*Relation, error)
- func (st *State) RemoveAllBlocksForSystem() error
- func (st *State) RemoveAllEnvironDocs() error
- func (st *State) RemoveEnvironmentUser(user names.UserTag) error
- func (st *State) RemoveFilesystem(tag names.FilesystemTag) (err error)
- func (st *State) RemoveFilesystemAttachment(machine names.MachineTag, filesystem names.FilesystemTag) (err error)
- func (st *State) RemoveStorageAttachment(storage names.StorageTag, unit names.UnitTag) (err error)
- func (st *State) RemoveVolume(tag names.VolumeTag) (err error)
- func (st *State) RemoveVolumeAttachment(machine names.MachineTag, volume names.VolumeTag) (err error)
- func (st *State) RestoreInfoSetter() (*RestoreInfo, error)
- func (st *State) ResumeTransactions() error
- func (st *State) Service(name string) (service *Service, err error)
- func (st *State) SetAPIHostPorts(netHostsPorts [][]network.HostPort) error
- func (st *State) SetAdminMongoPassword(password string) error
- func (st *State) SetAnnotations(entity GlobalEntity, annotations map[string]string) (err error)
- func (st *State) SetEnvironAgentVersion(newVersion version.Number) (err error)
- func (st *State) SetEnvironConstraints(cons constraints.Value) error
- func (st *State) SetFilesystemAttachmentInfo(machineTag names.MachineTag, filesystemTag names.FilesystemTag, ...) (err error)
- func (st *State) SetFilesystemInfo(tag names.FilesystemTag, info FilesystemInfo) (err error)
- func (st *State) SetFilesystemStatus(tag names.FilesystemTag, status Status, info string, ...) error
- func (st *State) SetMetricBatchesSent(batchUUIDs []string) error
- func (st *State) SetStateServingInfo(info StateServingInfo) error
- func (st *State) SetVolumeAttachmentInfo(machineTag names.MachineTag, volumeTag names.VolumeTag, ...) (err error)
- func (st *State) SetVolumeInfo(tag names.VolumeTag, info VolumeInfo) (err error)
- func (st *State) SetVolumeStatus(tag names.VolumeTag, status Status, info string, data map[string]interface{}) error
- func (st *State) Space(name string) (*Space, error)
- func (st *State) StartSync()
- func (st *State) StateServerEnvironment() (*Environment, error)
- func (st *State) StateServerInfo() (*StateServerInfo, error)
- func (st *State) StateServingInfo() (StateServingInfo, error)
- func (st *State) StorageAttachment(storage names.StorageTag, unit names.UnitTag) (StorageAttachment, error)
- func (st *State) StorageAttachments(storage names.StorageTag) ([]StorageAttachment, error)
- func (st *State) StorageInstance(tag names.StorageTag) (StorageInstance, error)
- func (st *State) StorageInstanceFilesystem(tag names.StorageTag) (Filesystem, error)
- func (st *State) StorageInstanceVolume(tag names.StorageTag) (Volume, error)
- func (st *State) Subnet(cidr string) (*Subnet, error)
- func (st *State) SwitchBlockOff(t BlockType) error
- func (st *State) SwitchBlockOn(t BlockType, msg string) error
- func (st *State) ToolsStorage() (toolstorage.StorageCloser, error)
- func (st *State) Unit(name string) (*Unit, error)
- func (st *State) UnitStorageAttachments(unit names.UnitTag) ([]StorageAttachment, error)
- func (st *State) UnitsFor(machineId string) ([]*Unit, error)
- func (st *State) UpdateEnvironConfig(updateAttrs map[string]interface{}, removeAttrs []string, ...) error
- func (st *State) UpdateUploadedCharm(ch charm.Charm, curl *charm.URL, storagePath, bundleSha256 string) (*Charm, error)
- func (st *State) User(tag names.UserTag) (*User, error)
- func (st *State) Volume(tag names.VolumeTag) (Volume, error)
- func (st *State) VolumeAttachment(machine names.MachineTag, volume names.VolumeTag) (VolumeAttachment, error)
- func (st *State) VolumeAttachments(volume names.VolumeTag) ([]VolumeAttachment, error)
- func (st *State) VolumeFilesystem(tag names.VolumeTag) (Filesystem, error)
- func (st *State) VolumeStatus(tag names.VolumeTag) (StatusInfo, error)
- func (st *State) Watch() *Multiwatcher
- func (st *State) WatchAPIHostPorts() NotifyWatcher
- func (st *State) WatchActionResults() StringsWatcher
- func (st *State) WatchActionResultsFilteredBy(receivers ...ActionReceiver) StringsWatcher
- func (st *State) WatchAllEnvs() *Multiwatcher
- func (st *State) WatchBlockDevices(machine names.MachineTag) NotifyWatcher
- func (st *State) WatchCleanups() NotifyWatcher
- func (st *State) WatchEnvironConfig() *EnvironConfigWatcher
- func (st *State) WatchEnvironFilesystemAttachments() StringsWatcher
- func (st *State) WatchEnvironFilesystems() StringsWatcher
- func (st *State) WatchEnvironMachines() StringsWatcher
- func (st *State) WatchEnvironVolumeAttachments() StringsWatcher
- func (st *State) WatchEnvironVolumes() StringsWatcher
- func (st *State) WatchEnvironments() StringsWatcher
- func (st *State) WatchFilesystemAttachment(m names.MachineTag, f names.FilesystemTag) NotifyWatcher
- func (st *State) WatchForEnvironConfigChanges() NotifyWatcher
- func (st *State) WatchIPAddresses() StringsWatcher
- func (st *State) WatchMachineFilesystemAttachments(m names.MachineTag) StringsWatcher
- func (st *State) WatchMachineFilesystems(m names.MachineTag) StringsWatcher
- func (st *State) WatchMachineVolumeAttachments(m names.MachineTag) StringsWatcher
- func (st *State) WatchMachineVolumes(m names.MachineTag) StringsWatcher
- func (st *State) WatchMinUnits() StringsWatcher
- func (st *State) WatchOpenedPorts() StringsWatcher
- func (st *State) WatchRestoreInfoChanges() NotifyWatcher
- func (st *State) WatchServices() StringsWatcher
- func (st *State) WatchStateServerInfo() NotifyWatcher
- func (st *State) WatchStorageAttachment(s names.StorageTag, u names.UnitTag) NotifyWatcher
- func (st *State) WatchStorageAttachments(unit names.UnitTag) StringsWatcher
- func (st *State) WatchUpgradeInfo() NotifyWatcher
- func (st *State) WatchVolumeAttachment(m names.MachineTag, v names.VolumeTag) NotifyWatcher
- type StatePool
- type StateServerInfo
- type StateServersChanges
- type StateServingInfo
- type StateSettings
- func (s *StateSettings) CreateSettings(key string, settings map[string]interface{}) error
- func (s *StateSettings) ListSettings(keyPrefix string) (map[string]map[string]interface{}, error)
- func (s *StateSettings) ReadSettings(key string) (map[string]interface{}, error)
- func (s *StateSettings) RemoveSettings(key string) error
- type Status
- type StatusGetter
- type StatusHistoryGetter
- type StatusInfo
- type StatusSetter
- type StorageAttachment
- type StorageConstraints
- type StorageInstance
- type StorageKind
- type StringsWatcher
- type Subnet
- func (s *Subnet) AllocatableIPHigh() string
- func (s *Subnet) AllocatableIPLow() string
- func (s *Subnet) AvailabilityZone() string
- func (s *Subnet) CIDR() string
- func (s *Subnet) EnsureDead() (err error)
- func (s *Subnet) GoString() string
- func (s *Subnet) ID() string
- func (s *Subnet) Life() Life
- func (s *Subnet) PickNewAddress() (*IPAddress, error)
- func (s *Subnet) ProviderId() string
- func (s *Subnet) Refresh() error
- func (s *Subnet) Remove() (err error)
- func (s *Subnet) SpaceName() string
- func (s *Subnet) String() string
- func (s *Subnet) VLANTag() int
- func (s *Subnet) Validate() error
- type SubnetInfo
- type Unit
- func (u *Unit) ActionSpecs() (ActionSpecsByName, error)
- func (u *Unit) Actions() ([]*Action, error)
- func (u *Unit) AddAction(name string, payload map[string]interface{}) (*Action, error)
- func (u *Unit) Agent() *UnitAgent
- func (u *Unit) AgentHistory() StatusHistoryGetter
- func (u *Unit) AgentPresence() (bool, error)
- func (u *Unit) AgentStatus() (StatusInfo, error)
- func (u *Unit) AgentTools() (*tools.Tools, 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) AvailabilityZone() (string, error)
- func (u *Unit) CancelAction(action *Action) (*Action, error)
- func (u *Unit) CharmURL() (*charm.URL, bool)
- func (u *Unit) ClearResolved() error
- func (u *Unit) ClosePort(protocol string, number int) error
- func (u *Unit) ClosePorts(protocol string, fromPort, toPort int) (err error)
- func (u *Unit) CompletedActions() ([]*Action, error)
- func (u *Unit) ConfigSettings() (charm.Settings, error)
- func (u *Unit) Constraints() (*constraints.Value, error)
- func (u *Unit) DeployerTag() (names.Tag, bool)
- func (u *Unit) Destroy() (err error)
- func (u *Unit) EnsureDead() (err error)
- func (u *Unit) GetMeterStatus() (MeterStatus, error)
- func (u *Unit) IsPrincipal() bool
- func (u *Unit) Life() Life
- func (u *Unit) Name() string
- func (u *Unit) OpenPort(protocol string, number int) error
- func (u *Unit) OpenPorts(protocol string, fromPort, toPort int) (err error)
- func (u *Unit) OpenedPorts() ([]network.PortRange, error)
- func (u *Unit) PasswordValid(password string) bool
- func (u *Unit) PendingActions() ([]*Action, error)
- func (u *Unit) PrincipalName() (string, bool)
- func (u *Unit) PrivateAddress() (network.Address, error)
- func (u *Unit) PublicAddress() (network.Address, error)
- func (u *Unit) Refresh() error
- func (u *Unit) RelationsInScope() ([]*Relation, error)
- func (u *Unit) RelationsJoined() ([]*Relation, error)
- func (u *Unit) Remove() (err error)
- func (u *Unit) Resolve(retryHooks bool) error
- func (u *Unit) Resolved() ResolvedMode
- func (u *Unit) RunningActions() ([]*Action, error)
- func (u *Unit) Series() string
- func (u *Unit) Service() (*Service, error)
- func (u *Unit) ServiceName() string
- func (u *Unit) SetAgentPresence() (*presence.Pinger, error)
- func (u *Unit) SetAgentStatus(status Status, info string, data map[string]interface{}) error
- func (u *Unit) SetAgentVersion(v version.Binary) (err error)
- func (u *Unit) SetCharmURL(curl *charm.URL) error
- func (u *Unit) SetMeterStatus(codeStr, info string) error
- func (u *Unit) SetPassword(password string) error
- func (u *Unit) SetResolved(mode ResolvedMode) (err error)
- func (u *Unit) SetStatus(status Status, info string, data map[string]interface{}) error
- func (u *Unit) Status() (StatusInfo, error)
- func (u *Unit) StatusHistory(size int) ([]StatusInfo, error)
- func (u *Unit) StorageConstraints() (map[string]StorageConstraints, error)
- func (u *Unit) String() string
- func (u *Unit) SubordinateNames() []string
- func (u *Unit) Tag() names.Tag
- func (u *Unit) UnassignFromMachine() (err error)
- func (u *Unit) UnitTag() names.UnitTag
- func (u *Unit) WaitAgentPresence(timeout time.Duration) (err error)
- func (u *Unit) Watch() NotifyWatcher
- func (u *Unit) WatchActionNotifications() StringsWatcher
- func (u *Unit) WatchConfigSettings() (NotifyWatcher, error)
- func (u *Unit) WatchMeterStatus() NotifyWatcher
- func (u *Unit) WatchSubordinateUnits() StringsWatcher
- type UnitAgent
- type UnitsWatcher
- type UpgradeInfo
- func (info *UpgradeInfo) Abort() error
- func (info *UpgradeInfo) AllProvisionedStateServersReady() (bool, error)
- func (info *UpgradeInfo) PreviousVersion() version.Number
- func (info *UpgradeInfo) Refresh() error
- func (info *UpgradeInfo) SetStateServerDone(machineId string) error
- func (info *UpgradeInfo) SetStatus(status UpgradeStatus) error
- func (info *UpgradeInfo) Started() time.Time
- func (info *UpgradeInfo) StateServersDone() []string
- func (info *UpgradeInfo) StateServersReady() []string
- func (info *UpgradeInfo) Status() UpgradeStatus
- func (info *UpgradeInfo) TargetVersion() version.Number
- func (info *UpgradeInfo) Watch() NotifyWatcher
- type UpgradeStatus
- type User
- func (u *User) CreatedBy() string
- func (u *User) DateCreated() time.Time
- func (u *User) Disable() error
- func (u *User) DisplayName() string
- func (u *User) Enable() error
- func (u *User) IsDisabled() bool
- func (u *User) LastLogin() (time.Time, error)
- func (u *User) Name() string
- func (u *User) PasswordValid(password string) bool
- func (u *User) Refresh() error
- func (u *User) SetPassword(password string) error
- func (u *User) SetPasswordHash(pwHash string, pwSalt string) error
- func (u *User) String() string
- func (u *User) Tag() names.Tag
- func (u *User) UpdateLastLogin() (err error)
- func (u *User) UserTag() names.UserTag
- type UserEnvironment
- type ValidateConfigFunc
- type Volume
- type VolumeAttachment
- type VolumeAttachmentInfo
- type VolumeAttachmentParams
- type VolumeInfo
- type VolumeParams
- type Watcher
Constants ¶
const ( ItemAdded = iota ItemModified ItemDeleted )
const ( MessageInstalling = "installing charm software" // StorageReadyMessage is the message set to the agent status when all storage // attachments are properly done. StorageReadyMessage = "storage ready" // PreparingStorageMessage is the message set to the agent status before trying // to attach storages. PreparingStorageMessage = "preparing storage" )
const (
CleanupAge = time.Hour * 24
)
const MessageWaitForAgentInit = "Waiting for agent initialization to finish"
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 ErrDead = fmt.Errorf("not found or dead")
var ErrNoBackingVolume = errors.New("filesystem has no backing volume")
ErrNoBackingVolume is returned by Filesystem.Volume() for filesystems without a backing volume.
var ErrNoDefaultStoragePool = fmt.Errorf("no storage pool specifed and no default available")
ErrNoDefaultStoragePool is returned when a storage pool is required but none is specified nor available as a default.
var ErrStateClosed = fmt.Errorf("state has been closed")
ErrStateClosed is returned from watchers if their underlying state connection has been closed.
var ErrStopped = stderrors.New("watcher was stopped")
var ErrSubordinateConstraints = stderrors.New("constraints do not apply to subordinate services")
var ErrUnitHasStorageAttachments = stderrors.New("unit has storage attachments")
ErrUnitHasStorageAttachments is a standard error to indicate that a Unit cannot complete an operation to end its life because it still has storage attachments.
var ErrUnitHasSubordinates = stderrors.New("unit has subordinates")
ErrUnitHasSubordinates is a standard error to indicate that a Unit cannot complete an operation to end its life because it still has subordinate services
var GetClock = func() clock.Clock { return clock.WallClock }
GetClock exists to allow us to patch out time-handling; specifically for the worker/uniter tests that want to know what happens when leases expire unexpectedly.
TODO(fwereade): lp:1479653 This is *clearly* a bad idea, and we should be injecting the dependency explicitly -- and using an injected clock across the codebase -- but, time pressure.
NewUUID wraps the utils.NewUUID() call, and exposes it as a var to facilitate patching.
var UpgradeInProgressError = errors.New("an upgrade is already in progress or the last upgrade did not complete")
Functions ¶
func AddAvailabilityZoneToInstanceData ¶
func AddAvailabilityZoneToInstanceData(st *State, azFunc func(*State, instance.Id) (string, error)) error
AddAvailabilityZoneToInstanceData sets the AvailZone field on instanceData docs that don't have it already.
func AddBindingToFilesystems ¶
AddBindingToFilesystems adds the binding field to filesystemDoc and populates it.
func AddBindingToVolumes ¶
AddBindingToVolumes adds the binding field to volumesDoc and populates it.
func AddCharmStoragePaths ¶
AddCharmStoragePaths adds storagepath fields to the specified charms.
func AddDefaultBlockDevicesDocs ¶
AddDefaultBlockDevicesDocs creates block devices documents for all existing machines in all environments.
func AddEnvUUIDToAnnotations ¶
AddEnvUUIDToAnnotations prepends the environment UUID to the ID of all annotation docs and adds new "env-uuid" field.
func AddEnvUUIDToCharms ¶
AddEnvUUIDToCharms prepends the environment UUID to the ID of all charm docs and adds new "env-uuid" field.
func AddEnvUUIDToCleanups ¶
AddEnvUUIDToCleanups prepends the environment UUID to the ID of all cleanup docs and adds new "env-uuid" field.
func AddEnvUUIDToConstraints ¶
AddEnvUUIDToConstraints prepends the environment UUID to the ID of all constraints docs and adds new "env-uuid" field.
func AddEnvUUIDToContainerRefs ¶
AddEnvUUIDToContainerRefs prepends the environment UUID to the ID of all containerRef docs and adds new "env-uuid" field.
func AddEnvUUIDToEnvUsersDoc ¶
AddEnvUUIDToEnvUsersDoc adds environment uuid to state server doc.
func AddEnvUUIDToInstanceData ¶
AddEnvUUIDToInstanceData prepends the environment UUID to the ID of all instanceData docs and adds new "env-uuid" field.
func AddEnvUUIDToMachines ¶
AddEnvUUIDToMachines prepends the environment UUID to the ID of all machine docs and adds new "env-uuid" field.
func AddEnvUUIDToMeterStatus ¶
AddEnvUUIDToMeterStatus prepends the environment UUID to the ID of all meterStatus docs and adds new "env-uuid" field and "id" fields.
func AddEnvUUIDToMinUnits ¶
AddEnvUUIDToMinUnits prepends the environment UUID to the ID of all minUnits docs and adds new "env-uuid" field.
func AddEnvUUIDToNetworkInterfaces ¶
AddEnvUUIDToNetworkInterfaces prepends adds a new "env-uuid" field to all networkInterfaces docs.
func AddEnvUUIDToNetworks ¶
AddEnvUUIDToNetworks prepends the environment UUID to the ID of all network docs and adds new "env-uuid" field.
func AddEnvUUIDToOpenPorts ¶
AddEnvUUIDToOpenPorts prepends the environment UUID to the ID of all openPorts docs and adds new "env-uuid" field.
func AddEnvUUIDToReboots ¶
AddEnvUUIDToReboots prepends the environment UUID to the ID of all reboot docs and adds new "env-uuid" field.
func AddEnvUUIDToRelationScopes ¶
AddEnvUUIDToRelationScopes prepends the environment UUID to the ID of all relationscopes docs and adds new "env-uuid" field and "key" fields.
func AddEnvUUIDToRelations ¶
AddEnvUUIDToRelations prepends the environment UUID to the ID of all relations docs and adds new "env-uuid" and "key" fields.
func AddEnvUUIDToRequestedNetworks ¶
AddEnvUUIDToRequestedNetworks prepends the environment UUID to the ID of all requestedNetworks docs and adds new "env-uuid" field.
func AddEnvUUIDToSequences ¶
AddEnvUUIDToSequences prepends the environment UUID to the ID of all sequence docs and adds new "env-uuid" field.
func AddEnvUUIDToServices ¶
AddEnvUUIDToServices prepends the environment UUID to the ID of all service docs and adds new "env-uuid" field.
func AddEnvUUIDToSettings ¶
AddEnvUUIDToSettings prepends the environment UUID to the ID of all settings docs and adds new "env-uuid" field.
func AddEnvUUIDToSettingsRefs ¶
AddEnvUUIDToSettingsRefs prepends the environment UUID to the ID of all settingRef docs and adds new "env-uuid" field.
func AddEnvUUIDToStatuses ¶
AddEnvUUIDToStatuses prepends the environment UUID to the ID of all Statuses docs and adds new "env-uuid" field.
func AddEnvUUIDToUnits ¶
AddEnvUUIDToUnits prepends the environment UUID to the ID of all unit docs and adds new "env-uuid" field.
func AddEnvironmentUUIDToStateServerDoc ¶
AddEnvironmentUUIDToStateServerDoc adds environment uuid to state server doc.
func AddFilesystemStatus ¶
AddFilesystemStatus ensures each filesystem has a status doc.
func AddFilesystemsAttachmentCount ¶
AddFilesystemAttachmentCount adds filesystemDoc.AttachmentCount and sets the right number to it.
func AddInstanceIdFieldOfIPAddresses ¶
AddInstanceIdFieldOfIPAddresses creates and populates the instance Id field for all IP addresses referencing a live machine with a provisioned instance.
func AddLeadershipSettingsDocs ¶
AddLeadsershipSettingsDocs creates service leadership documents in the settings collection for all services in all environments.
func AddLifeFieldOfIPAddresses ¶
AddLifeFieldOfIPAddresses creates the Life field for all IP addresses that don't have this field. For addresses referencing live machines Life will be set to Alive, otherwise Life will be set to Dead.
func AddMissingEnvUUIDOnStatuses ¶
AddMissingEnvUUIDOnStatuses populates the env-uuid field where it is missing due to LP #1474606.
func AddMissingServiceStatuses ¶
AddMissingServiceStatuses creates all service status documents that do not already exist.
func AddStateUsersAsEnvironUsers ¶
AddStateUsersAsEnvironUsers loops through all users stored in state and adds them as environment users with a local provider.
func AddUUIDToIPAddresses ¶
AddUUIDToIPAddresses creates and populates the UUID field for all IP addresses.
func AddVolumeAttachmentCount ¶
AddVolumeAttachmentCount adds volumeDoc.AttachmentCount and sets the right number to it.
func AddVolumeStatus ¶
AddVolumeStatus ensures each volume has a status doc.
func ChangeStatusHistoryEntityId ¶
ChangeStatusHistoryEntityId renames entityId field to globalkey.
func ChangeStatusHistoryUpdatedType ¶
ChangeStatusHistoryUpdatedType seeks for historicalStatusDoc records whose updated attribute is a time and converts them to int64.
func ChangeStatusUpdatedType ¶
ChangeStatusUpdatedType seeks for statusDoc records whose updated attribute is a time and converts them to int64.
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 CreateUnitMeterStatus ¶
CreateUnitMeterStatus creates documents in the meter status collection for all existing units.
func DropOldIndexesv123 ¶
DropOldIndexesv123 drops old mongo indexes.
func FixMinUnitsEnvUUID ¶
FixMinUnitsEnvUUID sets the env-uuid field on documents in the minUnits collection where the field is blank. This is needed because a code change was missed with the env UUID migration was done for this collection (in 1.21).
func FixSequenceFields ¶
FixSequenceFields sets the env-uuid and name fields on documents in the sequence collection where these fields are blank. This is needed because code changes were missed with the env UUID migration was done for this collection (in 1.21).
func InitDbLogs ¶
func InitDbLogs(session *mgo.Session) error
InitDbLogs sets up the indexes for the logs collection. It should be called as state is opened. It is idempotent.
func IsCharmAlreadyUploadedError ¶
func IsCharmAlreadyUploadedError(err interface{}) bool
IsCharmAlreadyUploadedError returns if the given error is ErrCharmAlreadyUploaded.
func IsContainsFilesystem ¶
func IsHasAssignedUnitsError ¶
func IsHasAttachmentsError ¶
IsHasAttachmentsError reports whether or not the error is a HasAttachmentsError, indicating that an attempt to destroy a machine failed due to it having storage attachments.
func IsHasContainersError ¶
IsHasContainersError reports whether or not the error is a HasContainersError, indicating that an attempt to destroy a machine failed due to it having containers.
func IsNeverConnectedError ¶
IsNeverConnectedError returns true if err is of type NeverConnectedError.
func IsNeverLoggedInError ¶
IsNeverLoggedInError returns true if err is of type NeverLoggedInError.
func IsUpgradeInProgressError ¶
IsUpgradeInProgressError returns true if the error given is UpgradeInProgressError.
func IsVersionInconsistentError ¶
func IsVersionInconsistentError(e interface{}) bool
IsVersionInconsistentError returns if the given error is versionInconsistentError.
func LowerCaseEnvUsersID ¶
func MigrateJobManageNetworking ¶
migrateJobManageNetworking adds the job JobManageNetworking to all machines except for:
- machines in a MAAS environment, - machines in a Joyent environment, - machines in a manual environment, - bootstrap node (host machine) in a local environment, and - manually provisioned machines.
func MigrateLastLoginAndLastConnection ¶
MigrateLastLoginAndLastConnection is an upgrade step that separates out LastLogin from the userDoc into its own collection and removes the lastlogin field from the userDoc. It does the same for LastConnection in the envUserDoc.
func MigrateMachineInstanceIdToInstanceData ¶
MigrateMachineInstanceIdToInstanceData migrates the deprecated "instanceid" machine field into "instanceid" in the instanceData doc.
func MigrateSettingsSchema ¶
MigrateSettingsSchema migrates the schema of the settings collection, moving non-reserved keys at the top-level into a subdoc, and introducing a top-level "version" field with the initial value matching txn-revno.
This migration takes place both before and after env-uuid migration, to get the correct txn-revno value.
func MigrateUnitPortsToOpenedPorts ¶
MigrateUnitPortsToOpenedPorts loops through all units stored in state and migrates any ports into the openedPorts collection.
func MoveServiceUnitSeqToSequence ¶
MoveServiceUnitSeqToSequence moves information from unitSeq value in the services documents and puts it into a new document in the sequence collection. The move happens in 3 stages: Insert: We insert the new sequence documents based on the values in the service collection. Any existing documents with the id we ignore Update: We update all the sequence documents with the correct UnitSeq. this phase overwrites any existing sequence documents that existed and were ignored during the install phase Unset: The last phase is to remove the unitseq from the service collection.
func NestingLevel ¶
NestingLevel returns how many levels of nesting exist for a machine id.
func ParentId ¶
ParentId returns the id of the host machine if machineId a container id, or "" if machineId is not for a container.
func ParseFilesystemAttachmentId ¶
func ParseFilesystemAttachmentId(id string) (names.MachineTag, names.FilesystemTag, error)
ParseFilesystemAttachmentId parses a string as a filesystem attachment ID, returning the machine and filesystem components.
func ParseVolumeAttachmentId ¶
ParseVolumeAttachmentId parses a string as a volume attachment ID, returning the machine and volume components.
func PruneLogs ¶
func PruneLogs(st LoggingState, minLogTime time.Time, maxLogsMB int) error
PruneLogs removes old log documents in order to control the size of logs collection. All logs older than minLogTime are removed. Further removal is also performed if the logs collection size is greater than maxLogsMB.
func PruneStatusHistory ¶
PruneStatusHistory removes status history entries until only the maxLogsPerEntity newest records per unit remain.
func ServiceInstances ¶
ServiceInstances returns the instance IDs of provisioned machines that are assigned units of the specified service.
func SetHostedEnvironCount ¶
SetHostedEnvironCount is an upgrade step that sets hostedEnvCountDoc.Count to the number of hosted environments.
func SetOwnerAndServerUUIDForEnvironment ¶
SetOwnerAndServerUUIDForEnvironment adds the environment uuid as the server uuid as well (it is the initial environment, so all good), and the owner to "admin@local", again all good as all existing environments have a user called "admin".
func SetSystemIdentity ¶
SetSystemIdentity sets the system identity value in the database if and only iff it is empty.
func TopParentId ¶
TopParentId returns the id of the top level host machine for a container id.
func ValidWorkloadStatus ¶
ValidWorkloadStatus returns true if status has a valid value (that is to say, a value that it's OK to set) for units or services.
Types ¶
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
Action represents an instruction to do some "action" and is expected to match an action definition in a charm.
func (*Action) ActionTag ¶
ActionTag returns an ActionTag constructed from this action's Prefix and Sequence.
func (*Action) Begin ¶
Begin marks an action as running, and logs the time it was started. It asserts that the action is currently pending.
func (*Action) Enqueued ¶
Enqueued returns the time the action was added to state as a pending Action.
func (*Action) Finish ¶
func (a *Action) Finish(results ActionResults) (*Action, error)
Finish removes action from the pending queue and captures the output and end state of the action.
func (*Action) Parameters ¶
Parameters will contain a structure representing arguments or parameters to an action, and is expected to be validated by the Unit using the Charm definition of the Action.
func (*Action) Receiver ¶
Receiver returns the Name of the ActionReceiver for which this action is enqueued. Usually this is a Unit Name().
func (*Action) Status ¶
func (a *Action) Status() ActionStatus
Status returns the final state of the action.
func (*Action) Tag ¶
Tag implements the Entity interface and returns a names.Tag that is a names.ActionTag.
func (*Action) ValidateTag ¶
ValidateTag should be called before calls to Tag() or ActionTag(). It verifies that the Action can produce a valid Tag.
type ActionReceiver ¶
type ActionReceiver interface { Entity // AddAction queues an action with the given name and payload for this // ActionReceiver. AddAction(name string, payload map[string]interface{}) (*Action, error) // CancelAction removes a pending Action from the queue for this // ActionReceiver and marks it as cancelled. CancelAction(action *Action) (*Action, error) // WatchActionNotifications returns a StringsWatcher that will notify // on changes to the queued actions for this ActionReceiver. WatchActionNotifications() StringsWatcher // Actions returns the list of Actions queued and completed for this // ActionReceiver. Actions() ([]*Action, error) // CompletedActions returns the list of Actions completed for this // ActionReceiver. CompletedActions() ([]*Action, error) // PendingActions returns the list of Actions queued for this // ActionReceiver. PendingActions() ([]*Action, error) // RunningActions returns the list of Actions currently running for // this ActionReceiver. RunningActions() ([]*Action, error) }
ActionReceiver describes Entities that can have Actions queued for them, and that can get ActionRelated information about those actions. TODO(jcw4) consider implementing separate Actor classes for this interface; for example UnitActor that implements this interface, and takes a Unit and performs all these actions.
type ActionResults ¶
type ActionResults struct { Status ActionStatus `json:"status"` Results map[string]interface{} `json:"results"` Message string `json:"message"` }
ActionResults is a data transfer object that holds the key Action output and results information.
type ActionSpecsByName ¶
type ActionSpecsByName map[string]charm.ActionSpec
ActionSpecsByName is a map of action names to their respective ActionSpec.
type ActionStatus ¶
type ActionStatus string
ActionStatus represents the possible end states for an action.
const ( // ActionFailed signifies that the action did not complete successfully. ActionFailed ActionStatus = "failed" // ActionCompleted indicates that the action ran to completion as intended. ActionCompleted ActionStatus = "completed" // ActionCancelled means that the Action was cancelled before being run. ActionCancelled ActionStatus = "cancelled" // ActionPending is the default status when an Action is first queued. ActionPending ActionStatus = "pending" // ActionRunning indicates that the Action is currently running. ActionRunning ActionStatus = "running" )
type ActionsWatcher ¶
type ActionsWatcher interface { Entity WatchActionNotifications() StringsWatcher }
ActionsWatcher defines the methods an entity exposes to watch Actions queued up for itself
type AddressState ¶
type AddressState string
AddressState represents the states an IP address can be in. They are created in an unknown state and then either become allocated or unavailable if allocation fails.
const ( // AddressStateUnknown is the initial state an IP address is // created with. AddressStateUnknown AddressState = "" // AddressStateAllocated means that the IP address has // successfully been allocated by the provider and is now in use // by an interface on a machine. AddressStateAllocated AddressState = "allocated" // the provider failed. We shouldn't use this address, nor should // we attempt to allocate it again in the future. AddressStateUnavailable AddressState = "unavailable" )
type AgentEntity ¶
type AgentEntity interface { Entity Lifer Authenticator 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 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 Backing ¶
type Backing interface { // GetAll retrieves information about all information // known to the Backing and stashes it in the Store. GetAll(all *multiwatcherStore) error // Changed informs the backing about a change received // from a watcher channel. The backing is responsible for // updating the Store to reflect the change. Changed(all *multiwatcherStore, change watcher.Change) error // Watch watches for any changes and sends them // on the given channel. Watch(in chan<- watcher.Change) // Unwatch stops watching for changes on the // given channel. Unwatch(in chan<- watcher.Change) // Release cleans up resources opened by the Backing. Release() error }
Backing is the interface required by the storeManager to access the underlying state.
type BatchParam ¶
type BatchParam struct { UUID string CharmURL string Created time.Time Metrics []Metric Unit names.UnitTag }
BatchParam contains the properties of the metrics batch used when creating a metrics batch.
type Block ¶
type Block interface { // Id returns this block's id. Id() string // EnvUUID returns the environment UUID associated with this block. EnvUUID() string // Tag returns tag for the entity that is being blocked Tag() (names.Tag, error) // Type returns block type Type() BlockType // Message returns explanation that accompanies this block. Message() string }
Customers and stakeholders want to be able to prevent accidental damage to their Juju deployments. To prevent running some operations, we want to have blocks that can be switched on/off.
type BlockDevice ¶
type BlockDevice interface { // Machine returns the ID of the machine the block device is attached to. Machine() string // Info returns the block device's BlockDeviceInfo. Info() BlockDeviceInfo }
BlockDevice represents the state of a block device in the environment.
type BlockDeviceInfo ¶
type BlockDeviceInfo struct { DeviceName string `bson:"devicename"` DeviceLinks []string `bson:"devicelinks,omitempty"` Label string `bson:"label,omitempty"` UUID string `bson:"uuid,omitempty"` HardwareId string `bson:"hardwareid,omitempty"` BusAddress string `bson:"busaddress,omitempty"` Size uint64 `bson:"size"` FilesystemType string `bson:"fstype,omitempty"` InUse bool `bson:"inuse"` MountPoint string `bson:"mountpoint,omitempty"` }
BlockDeviceInfo describes information about a block device.
type BlockType ¶
type BlockType int8
BlockType specifies block type for enum benefit.
const ( // DestroyBlock type identifies block that prevents environment destruction. DestroyBlock BlockType = iota // RemoveBlock type identifies block that prevents // removal of machines, services, units or relations. RemoveBlock // ChangeBlock type identifies block that prevents environment changes such // as additions, modifications, removals of environment entities. ChangeBlock )
func ParseBlockType ¶
ParseBlockType returns BlockType from humanly readable type representation.
func (BlockType) ToParams ¶
func (t BlockType) ToParams() multiwatcher.BlockType
ToParams returns the type as multiwatcher.BlockType.
type Charm ¶
type Charm struct {
// contains filtered or unexported fields
}
Charm represents the state of a charm in the environment.
func (*Charm) Actions ¶
func (c *Charm) Actions() *charm.Actions
Actions returns the actions definition of the charm.
func (*Charm) BundleSha256 ¶
BundleSha256 returns the SHA256 digest of the charm bundle bytes.
func (*Charm) BundleURL ¶
BundleURL returns the url to the charm bundle in the provider storage.
DEPRECATED: this is only to be used for migrating charm archives to environment storage.
func (*Charm) Config ¶
func (c *Charm) Config() *charm.Config
Config returns the configuration of the charm.
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 environment storage.
func (*Charm) Metrics ¶
func (c *Charm) Metrics() *charm.Metrics
Metrics returns the metrics declared for the charm.
func (*Charm) StoragePath ¶
StoragePath returns the storage path of the charm bundle.
type ConfigValidator ¶
type ConfigValidator interface {
Validate(cfg, old *config.Config) (valid *config.Config, err error)
}
ConfigValidator is a policy interface that is provided to State to check validity of new configuration attributes before applying them to state.
type Database ¶
type Database interface { // CopySession returns a matching Database with its own session, and a // func that must be called when the Database is no longer needed. // // GetCollection and TransactionRunner results from the resulting Database // will all share a session; this does not absolve you of responsibility // for calling those collections' closers. CopySession() (Database, SessionCloser) // GetCollection returns the named Collection, and a func that must be // called when the Collection is no longer needed. The returned Collection // might or might not have its own session, depending on the Database; the // closer must always be called regardless. // // If the schema specifies environment-filtering for the named collection, // the returned collection will automatically filter queries; for details, // see envStateCollection. GetCollection(name string) (mongo.Collection, SessionCloser) // TransactionRunner() returns a runner responsible for making changes to // the database, and a func that must be called when the runner is no longer // needed. The returned Runner might or might not have its own session, // depending on the Database; the closer must always be called regardless. // // It will reject transactions that reference raw-access (or unknown) // collections; it will automatically rewrite operations that reference // non-global collections; and it will ensure that non-global documents can // only be inserted while the corresponding environment is still Alive. TransactionRunner() (jujutxn.Runner, SessionCloser) // Schema returns the schema used to load the database. The returned schema // is not a copy and must not be modified. Schema() collectionSchema }
Database exposes the mongodb capabilities that most of state should see.
type DbLogger ¶
type DbLogger struct {
// contains filtered or unexported fields
}
func NewDbLogger ¶
func NewDbLogger(st LoggingState, entity names.Tag) *DbLogger
NewDbLogger returns a DbLogger instance which is used to write logs to the database.
type Endpoint ¶
type Endpoint struct { ServiceName string charm.Relation }
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 ¶
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 EntityWithService ¶
EntityWithService is implemented by Units it is intended for anything that can return its Service.
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 EnvironCapability ¶
type EnvironCapability interface { // SupportedArchitectures returns the image architectures which can // be hosted by this environment. SupportedArchitectures() ([]string, error) // SupportsUnitAssignment returns an error which, if non-nil, indicates // that the environment does not support unit placement. If the environment // does not support unit placement, then machines may not be created // without units, and units cannot be placed explcitly. SupportsUnitPlacement() error }
EnvironCapability implements access to metadata about the capabilities of an environment.
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) Config ¶
func (e *Environment) Config() (*config.Config, error)
Config returns the config for the environment.
func (*Environment) Destroy ¶
func (e *Environment) Destroy() (err error)
Destroy sets the environment's lifecycle to Dying, preventing addition of services or machines to state.
func (*Environment) EnvironTag ¶
func (e *Environment) EnvironTag() names.EnvironTag
EnvironTag is the concrete environ tag for this environment.
func (*Environment) LatestToolsVersion ¶
func (e *Environment) LatestToolsVersion() version.Number
LatestToolsVersion returns the newest version found in the last check in the streams. Bear in mind that the check was performed filtering only new patches for the current major.minor. (major.minor.patch)
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) Owner ¶
func (e *Environment) Owner() names.UserTag
Owner returns tag representing the owner of the environment. The owner is the user that created the environment.
func (*Environment) Refresh ¶
func (e *Environment) Refresh() error
func (*Environment) ServerTag ¶
func (e *Environment) ServerTag() names.EnvironTag
ServerTag is the environ tag for the server that the environment is running within.
func (*Environment) ServerUUID ¶
func (e *Environment) ServerUUID() string
ServerUUID returns the universally unique identifier of the server in which the environment is running.
func (*Environment) Tag ¶
func (e *Environment) Tag() names.Tag
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) UpdateLatestToolsVersion ¶
func (e *Environment) UpdateLatestToolsVersion(ver version.Number) error
UpdateLatestToolsVersion looks up for the latest available version of juju tools and updates environementDoc with it.
func (*Environment) Users ¶
func (e *Environment) Users() ([]*EnvironmentUser, error)
Users returns a slice of all users for this environment.
func (*Environment) Watch ¶
func (e *Environment) Watch() NotifyWatcher
Watch returns a watcher for observing changes to an environment.
type EnvironmentUser ¶
type EnvironmentUser struct {
// contains filtered or unexported fields
}
EnvironmentUser represents a user access to an environment whereas the user could represent a remote user or a user across multiple environments the environment user always represents a single user for a single environment. There should be no more than one EnvironmentUser per environment.
func (*EnvironmentUser) CreatedBy ¶
func (e *EnvironmentUser) CreatedBy() string
CreatedBy returns the user who created the environment user.
func (*EnvironmentUser) DateCreated ¶
func (e *EnvironmentUser) DateCreated() time.Time
DateCreated returns the date the environment user was created in UTC.
func (*EnvironmentUser) DisplayName ¶
func (e *EnvironmentUser) DisplayName() string
DisplayName returns the display name of the environment user.
func (*EnvironmentUser) EnvironmentTag ¶
func (e *EnvironmentUser) EnvironmentTag() names.EnvironTag
EnvironmentTag returns the environment tag of the environment user.
func (*EnvironmentUser) ID ¶
func (e *EnvironmentUser) ID() string
ID returns the ID of the environment user.
func (*EnvironmentUser) LastConnection ¶
func (e *EnvironmentUser) LastConnection() (time.Time, error)
LastConnection returns when this EnvironmentUser last connected through the API in UTC. The resulting time will be nil if the user has never logged in.
func (*EnvironmentUser) UpdateLastConnection ¶
func (e *EnvironmentUser) UpdateLastConnection() error
UpdateLastConnection updates the last connection time of the environment user.
func (*EnvironmentUser) UserName ¶
func (e *EnvironmentUser) UserName() string
UserName returns the user name of the environment user.
func (*EnvironmentUser) UserTag ¶
func (e *EnvironmentUser) UserTag() names.UserTag
UserTag returns the tag for the environment user.
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 Filesystem ¶
type Filesystem interface { GlobalEntity LifeBinder StatusGetter StatusSetter // FilesystemTag returns the tag for the filesystem. FilesystemTag() names.FilesystemTag // Storage returns the tag of the storage instance that this // filesystem is assigned to, if any. If the filesystem is not // assigned to a storage instance, an error satisfying // errors.IsNotAssigned will be returned. // // A filesystem can be assigned to at most one storage instance, and // a storage instance can have at most one associated filesystem. Storage() (names.StorageTag, error) // Volume returns the tag of the volume backing this filesystem, // or ErrNoBackingVolume if the filesystem is not backed by a volume // managed by Juju. Volume() (names.VolumeTag, error) // Info returns the filesystem's FilesystemInfo, or a NotProvisioned // error if the filesystem has not yet been provisioned. Info() (FilesystemInfo, error) // Params returns the parameters for provisioning the filesystem, // if it needs to be provisioned. Params returns true if the returned // parameters are usable for provisioning, otherwise false. Params() (FilesystemParams, bool) }
Filesystem describes a filesystem in the environment. Filesystems may be backed by a volume, and managed by Juju; otherwise they are first-class entities managed by a filesystem provider.
type FilesystemAttachment ¶
type FilesystemAttachment interface { Lifer // Filesystem returns the tag of the related Filesystem. Filesystem() names.FilesystemTag // Machine returns the tag of the related Machine. Machine() names.MachineTag // Info returns the filesystem attachment's FilesystemAttachmentInfo, or a // NotProvisioned error if the attachment has not yet been made. // // Note that the presence of FilesystemAttachmentInfo does not necessarily // imply that the filesystem is mounted; environment storage providers may // need to prepare a filesystem for attachment to a machine before it can // be mounted. Info() (FilesystemAttachmentInfo, error) // Params returns the parameters for creating the filesystem attachment, // if it has not already been made. Params returns true if the returned // parameters are usable for creating an attachment, otherwise false. Params() (FilesystemAttachmentParams, bool) }
FilesystemAttachment describes an attachment of a filesystem to a machine.
type FilesystemAttachmentInfo ¶
type FilesystemAttachmentInfo struct { // MountPoint is the path at which the filesystem is mounted on the // machine. MountPoint may be empty, meaning that the filesystem is // not mounted yet. MountPoint string `bson:"mountpoint"` ReadOnly bool `bson:"read-only"` }
FilesystemAttachmentInfo describes information about a filesystem attachment.
type FilesystemAttachmentParams ¶
type FilesystemAttachmentParams struct { Location string `bson:"location"` ReadOnly bool `bson:"read-only"` // contains filtered or unexported fields }
FilesystemAttachmentParams records parameters for attaching a filesystem to a machine.
type FilesystemInfo ¶
type FilesystemInfo struct { Size uint64 `bson:"size"` Pool string `bson:"pool"` // FilesystemId is the provider-allocated unique ID of the // filesystem. This will be unspecified for filesystems // backed by volumes. FilesystemId string `bson:"filesystemid"` }
FilesystemInfo describes information about a filesystem.
type FilesystemParams ¶
type FilesystemParams struct { Pool string `bson:"pool"` Size uint64 `bson:"size"` // contains filtered or unexported fields }
FilesystemParams records parameters for provisioning a new filesystem.
type GlobalEntity ¶
GlobalEntity specifies entity.
type HasAssignedUnitsError ¶
func (*HasAssignedUnitsError) Error ¶
func (e *HasAssignedUnitsError) Error() string
type HasAttachmentsError ¶
HasAttachmentsError is the error returned by EnsureDead if the machine has attachments to resources that must be cleaned up first.
func (*HasAttachmentsError) Error ¶
func (e *HasAttachmentsError) Error() string
type HasContainersError ¶
func (*HasContainersError) Error ¶
func (e *HasContainersError) Error() string
type IPAddress ¶
type IPAddress struct {
// contains filtered or unexported fields
}
IPAddress represents the state of an IP address.
func (*IPAddress) AllocateTo ¶
AllocateTo sets the machine ID, MAC address and interface ID of the IP address. It will fail if the state is not AddressStateUnknown. On success, the address state will also change to AddressStateAllocated.
func (*IPAddress) EnsureDead ¶
EnsureDead sets the Life of the IP address to Dead, if it's Alive. It does nothing otherwise.
func (*IPAddress) InstanceId ¶
InstanceId returns the provider ID of the instance the IP address is associated with. For a container this will be the ID of the host. If the address is not associated with an instance this returns "" (the same as instance.UnknownId).
func (*IPAddress) InterfaceId ¶
InterfaceId returns the ID of the network interface the IP address is associated with. If the address is not associated with a network interface this returns "".
func (*IPAddress) MACAddress ¶
MACAddress returns the MAC address of the container NIC the IP address is associated with.
func (*IPAddress) MachineId ¶
MachineId returns the ID of the machine the IP address is associated with. If the address is not associated with a machine this returns "".
func (*IPAddress) Refresh ¶
Refresh refreshes the contents of the IPAddress from the underlying state. It an error that satisfies errors.IsNotFound if the Subnet has been removed.
func (*IPAddress) Remove ¶
Remove removes an existing IP address. Trying to remove a missing address is not an error.
func (*IPAddress) Scope ¶
Scope returns the scope of the IP address. If the scope is not set this returns "".
func (*IPAddress) SetState ¶
func (i *IPAddress) SetState(newState AddressState) (err error)
SetState sets the State of an IPAddress. Valid state transitions are Unknown to Allocated or Unavailable, as well as setting the same state more than once. Any other transition will result in returning an error satisfying errors.IsNotValid().
func (*IPAddress) State ¶
func (i *IPAddress) State() AddressState
State returns the state of an IP address.
func (*IPAddress) SubnetId ¶
SubnetId returns the ID of the subnet the IP address is associated with. If the address is not associated with a subnet this returns "".
func (*IPAddress) Type ¶
func (i *IPAddress) Type() network.AddressType
Type returns the type of the IP address. The IP address will have a type of IPv4, IPv6 or hostname.
type InstanceDistributor ¶
type InstanceDistributor interface { // DistributeInstance takes a set of clean, empty // instances, and a distribution group, and returns // the subset of candidates which the policy will // allow entry into the distribution group. // // The AssignClean and AssignCleanEmpty unit // assignment policies will attempt to assign a // unit to each of the resulting instances until // one is successful. If no instances can be assigned // to (e.g. because of concurrent deployments), then // a new machine will be allocated. DistributeInstances(candidates, distributionGroup []instance.Id) ([]instance.Id, error) }
InstanceDistributor is a policy interface that is provided to State to perform distribution of units across instances for high availability.
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 LifeBinder ¶
type LifeBinder interface { Lifer // LifeBinding either returns the tag of an entity to which this // entity's lifespan is bound; the result may be nil, indicating // that the entity's lifespan is not bound to anything. // // The types of tags that may be returned are depdendent on the // entity type. For example, a Volume may be bound to a Filesystem, // but a Filesystem may not be bound to a Filesystem. LifeBinding() names.Tag }
LifeBinder represents an entity whose lifespan is bindable to that of another entity.
type LogRecord ¶
type LogRecord struct { Time time.Time Entity string Module string Location string Level loggo.Level Message string }
LogRecord defines a single Juju log message as returned by LogTailer.
type LogTailer ¶
type LogTailer interface { // Logs returns the channel through which the LogTailer returns // Juju logs. It will be closed when the tailer stops. Logs() <-chan *LogRecord // Dying returns a channel which will be closed as the LogTailer // stops. Dying() <-chan struct{} // Stop is used to request that the LogTailer stops. It blocks // unil the LogTailer has stopped. Stop() error // Err returns the error that caused the LogTailer to stopped. If // it hasn't stopped or stopped without error nil will be // returned. Err() error }
LogTailer allows for retrieval of Juju's logs from MongoDB. It first returns any matching already recorded logs and then waits for additional matching logs as they appear.
func NewLogTailer ¶
func NewLogTailer(st LoggingState, params *LogTailerParams) LogTailer
NewLogTailer returns a LogTailer which filters according to the parameters given.
type LogTailerParams ¶
type LogTailerParams struct { StartTime time.Time MinLevel loggo.Level InitialLines int IncludeEntity []string ExcludeEntity []string IncludeModule []string ExcludeModule []string Oplog *mgo.Collection // For testing only }
LogTailerParams specifies the filtering a LogTailer should apply to logs in order to decide which to return.
type LoggingState ¶
type LoggingState interface { EnvironUUID() string MongoSession() *mgo.Session }
LoggingState describes the methods on State required for logging to the database.
type Machine ¶
Machine represents the state of a machine.
func (*Machine) AddNetworkInterface ¶
func (m *Machine) AddNetworkInterface(args NetworkInterfaceInfo) (iface *NetworkInterface, err error)
AddNetworkInterface creates a new network interface with the given args for this machine. The machine must be alive and not yet provisioned, and there must be no other interface with the same MAC address on the same network, or the same name on that machine for this to succeed. If a network interface already exists, the returned error satisfies errors.IsAlreadyExists.
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. Provider-reported addresses always come before machine-reported addresses. Duplicates are removed.
func (*Machine) AgentPresence ¶
AgentPresence 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 errors.IsNotFound if the tools have not yet been set.
func (*Machine) AvailabilityZone ¶
AvailabilityZone returns the provier-specific instance availability zone in which the machine was provisioned.
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) GetRebootFlag ¶
GetRebootFlag returns the reboot flag for this 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) IsContainer ¶
IsContainer returns true if the machine is a container.
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) MachineTag ¶
func (m *Machine) MachineTag() names.MachineTag
MachineTag returns the more specific MachineTag type as opposed to the more generic Tag type.
func (*Machine) NetworkInterfaces ¶
func (m *Machine) NetworkInterfaces() ([]*NetworkInterface, error)
NetworkInterfaces returns the list of configured network interfaces of the machine.
func (*Machine) Networks ¶
Networks returns the list of configured networks on the machine. The configured and requested networks on a machine must match.
func (*Machine) OpenedPorts ¶
OpenedPorts returns this machine ports document for the given network.
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) Placement ¶
Placement returns the machine's Placement structure that should be used when provisioning an instance for the machine.
func (*Machine) PrivateAddress ¶
PrivateAddress returns a private address for the machine. If no address is available it returns an error that satisfies network.IsNoAddress.
func (*Machine) ProviderAddresses ¶
ProviderAddresses returns any hostnames and ips associated with a machine, as determined by asking the provider.
func (*Machine) PublicAddress ¶
PublicAddress returns a public address for the machine. If no address is available it returns an error that satisfies network.IsNoAddress.
func (*Machine) Refresh ¶
Refresh refreshes the contents of the machine from the underlying state. It returns an error that satisfies errors.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) RequestedNetworks ¶
RequestedNetworks returns the list of network names the machine should be on. Unlike networks specified with constraints, these networks are required to be present on the machine.
TODO(dimitern): Drop this when we can use space bindings derived from constraints.
func (*Machine) SetAgentPresence ¶
SetAgentPresence 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) 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) SetInstanceInfo ¶
func (m *Machine) SetInstanceInfo( id instance.Id, nonce string, characteristics *instance.HardwareCharacteristics, networks []NetworkInfo, interfaces []NetworkInterfaceInfo, volumes map[names.VolumeTag]VolumeInfo, volumeAttachments map[names.VolumeTag]VolumeAttachmentInfo, ) error
SetInstanceInfo is used to provision a machine and in one steps set it's instance id, nonce, hardware characteristics, add networks and network interfaces as needed.
TODO(dimitern) Do all the operations described in a single transaction, rather than using separate calls. Alternatively, we can add all the things to create/set in a document in some collection and have a worker that takes care of the actual work. Merge SetProvisioned() in here or drop it at that point.
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) SetMachineBlockDevices ¶
func (m *Machine) SetMachineBlockDevices(info ...BlockDeviceInfo) error
SetMachineBlockDevices sets the block devices visible on 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) SetProviderAddresses ¶
SetProviderAddresses records any addresses related to the machine, sourced by asking the provider.
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) SetRebootFlag ¶
SetRebootFlag sets the reboot flag of a machine to a boolean value. It will also do a lazy create of a reboot document if needed; i.e. If a document does not exist yet for this machine, it will create it.
func (*Machine) SetSupportedContainers ¶
func (m *Machine) SetSupportedContainers(containers []instance.ContainerType) (err error)
SetSupportedContainers sets the list of containers supported by this machine.
func (*Machine) ShouldRebootOrShutdown ¶
func (m *Machine) ShouldRebootOrShutdown() (RebootAction, error)
ShouldRebootOrShutdown check if the current node should reboot or shutdown If we are a container, and our parent needs to reboot, this should return: ShouldShutdown
func (*Machine) Status ¶
func (m *Machine) Status() (StatusInfo, error)
Status returns the status of the 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 tag identifying the machine. The String method provides a string representation 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) VolumeAttachments ¶
func (m *Machine) VolumeAttachments() ([]VolumeAttachment, error)
VolumeAttachments returns the machine's volume attachments.
func (*Machine) WaitAgentPresence ¶
WaitAgentPresence 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) WatchAddresses ¶
func (m *Machine) WatchAddresses() NotifyWatcher
WatchAddresses returns a new NotifyWatcher watching m's addresses.
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) WatchForRebootEvent ¶
func (m *Machine) WatchForRebootEvent() (NotifyWatcher, error)
WatchForRebootEvent returns a notify watcher that will trigger an event when the reboot flag is set on our machine agent, our parent machine agent or grandparent machine agent
func (*Machine) WatchHardwareCharacteristics ¶
func (m *Machine) WatchHardwareCharacteristics() NotifyWatcher
WatchHardwareCharacteristics returns a watcher for observing changes to a machine's hardware characteristics.
func (*Machine) WatchInterfaces ¶
func (m *Machine) WatchInterfaces() NotifyWatcher
WatchInterfaces returns a new NotifyWatcher watching m's network interfaces.
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 MachineFilesystemParams ¶
type MachineFilesystemParams struct { Filesystem FilesystemParams Attachment FilesystemAttachmentParams }
MachineFilesystemParams holds the parameters for creating a filesystem and attaching it to a new machine.
type MachineJob ¶
type MachineJob int
MachineJob values define responsibilities that machines may be expected to fulfil.
const ( JobHostUnits MachineJob JobManageEnviron JobManageNetworking // Deprecated in 1.18. JobManageStateDeprecated )
func (MachineJob) String ¶
func (job MachineJob) String() string
func (MachineJob) ToParams ¶
func (job MachineJob) ToParams() multiwatcher.MachineJob
ToParams returns the job as multiwatcher.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 []network.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 // RequestedNetworks holds a list of network names the machine // should be part of. // // TODO(dimitern): Drop this in favor of constraints in a follow-up. RequestedNetworks []string // Volumes holds the parameters for volumes that are to be created // and attached to the machine. Volumes []MachineVolumeParams // VolumeAttachments holds the parameters for attaching existing // volumes to the machine. VolumeAttachments map[names.VolumeTag]VolumeAttachmentParams // Filesystems holds the parameters for filesystems that are to be // created and attached to the machine. Filesystems []MachineFilesystemParams // FilesystemAttachments holds the parameters for attaching existing // filesystems to the machine. FilesystemAttachments map[names.FilesystemTag]FilesystemAttachmentParams // 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 // Placement holds the placement directive that will be associated // with the machine. Placement string // contains filtered or unexported fields }
MachineTemplate holds attributes that are to be associated with a newly created machine.
type MachineVolumeParams ¶
type MachineVolumeParams struct { Volume VolumeParams Attachment VolumeAttachmentParams }
MachineVolumeParams holds the parameters for creating a volume and attaching it to a new machine.
type MeterStatus ¶
type MeterStatus struct { Code MeterStatusCode Info string }
MeterStatus represents the metering status of a unit.
func (*MeterStatus) Severity ¶
func (m *MeterStatus) Severity() int
Severity returns relative severity of the meter status.
type MeterStatusCode ¶
type MeterStatusCode int
MeterStatusCode represents the meter status code of a unit. The int value represents its relative severity when compared to other MeterStatusCodes.
const ( MeterNotAvailable MeterStatusCode = iota MeterRed MeterAmber MeterNotSet MeterGreen )
This const block defines the relative severities of the valid MeterStatusCodes in ascending order.
func MeterStatusFromString ¶
func MeterStatusFromString(str string) MeterStatusCode
MeterStatusFromString returns a valid MeterStatusCode given a string representation.
func (MeterStatusCode) Severity ¶
func (m MeterStatusCode) Severity() int
Severity returns the relative severity.
func (MeterStatusCode) String ¶
func (m MeterStatusCode) String() string
String returns a human readable string representation of the meter status.
type Metric ¶
type Metric struct { Key string `bson:"key"` Value string `bson:"value"` Time time.Time `bson:"time"` }
Metric represents a single Metric.
type MetricBatch ¶
type MetricBatch struct {
// contains filtered or unexported fields
}
MetricBatch represents a batch of metrics reported from a unit. These will be received from the unit in batches. The main contents of the metric (key, value) is defined by the charm author and sent from the unit via a call to add-metric
func (*MetricBatch) CharmURL ¶
func (m *MetricBatch) CharmURL() string
CharmURL returns the charm url for the charm this metric was generated in.
func (*MetricBatch) Created ¶
func (m *MetricBatch) Created() time.Time
Created returns the time this metric batch was created.
func (*MetricBatch) Credentials ¶
func (m *MetricBatch) Credentials() []byte
Credentials returns any credentials associated with the metric batch.
func (*MetricBatch) EnvUUID ¶
func (m *MetricBatch) EnvUUID() string
EnvUUID returns the environment UUID this metric applies to.
func (*MetricBatch) MarshalJSON ¶
func (m *MetricBatch) MarshalJSON() ([]byte, error)
MarshalJSON defines how the MetricBatch type should be converted to json.
func (*MetricBatch) Metrics ¶
func (m *MetricBatch) Metrics() []Metric
Metrics returns the metrics in this batch.
func (*MetricBatch) Sent ¶
func (m *MetricBatch) Sent() bool
Sent returns a flag to tell us if this metric has been sent to the metric collection service
func (*MetricBatch) SetSent ¶
func (m *MetricBatch) SetSent() error
SetSent sets the sent flag to true
func (*MetricBatch) Unit ¶
func (m *MetricBatch) Unit() string
Unit returns the name of the unit this metric was generated in.
type MetricsManager ¶
type MetricsManager struct {
// contains filtered or unexported fields
}
MetricsManager stores data about the state of the metrics manager
func (*MetricsManager) ConsecutiveErrors ¶
func (m *MetricsManager) ConsecutiveErrors() int
ConsecutiveErrors returns the number of consecutive failures.
func (*MetricsManager) DocID ¶
func (m *MetricsManager) DocID() string
DocID returns the Document id of the MetricsManager.
func (*MetricsManager) EnvUUID ¶
func (m *MetricsManager) EnvUUID() string
EnvUUID returns the environment UUID of the Metrics Manager.
func (*MetricsManager) GracePeriod ¶
func (m *MetricsManager) GracePeriod() time.Duration
GracePeriod returns the current grace period.
func (*MetricsManager) IncrementConsecutiveErrors ¶
func (m *MetricsManager) IncrementConsecutiveErrors() error
IncrementConsecutiveErrors adds 1 to the consecutive errors count.
func (*MetricsManager) LastSuccessfulSend ¶
func (m *MetricsManager) LastSuccessfulSend() time.Time
LastSuccessfulSend returns the time of the last successful send.
func (*MetricsManager) MeterStatus ¶
func (m *MetricsManager) MeterStatus() MeterStatus
MeterStatus returns the overall state of the MetricsManager as a meter status summary.
func (*MetricsManager) SetGracePeriod ¶
func (m *MetricsManager) SetGracePeriod(t time.Duration) error
func (*MetricsManager) SetLastSuccessfulSend ¶
func (m *MetricsManager) SetLastSuccessfulSend(t time.Time) error
SetLastSuccessfulSend sets the last successful send time to the input time.
type Multiwatcher ¶
type Multiwatcher struct {
// contains filtered or unexported fields
}
Multiwatcher watches any changes to the state.
func NewMultiwatcher ¶
func NewMultiwatcher(all *storeManager) *Multiwatcher
NewMultiwatcher creates a new watcher that can observe changes to an underlying store manager.
func (*Multiwatcher) Next ¶
func (w *Multiwatcher) Next() ([]multiwatcher.Delta, error)
Next retrieves all changes that have happened since the last time it was called, blocking until there are some changes available.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network represents the state of a network.
func (*Network) Interfaces ¶
func (n *Network) Interfaces() ([]*NetworkInterface, error)
Interfaces returns all network interfaces on the network.
func (*Network) IsVLAN ¶
IsVLAN returns whether the network is a VLAN (has tag > 0) or a normal network.
func (*Network) ProviderId ¶
ProviderId returns the provider-specific id of the network.
type NetworkInfo ¶
type NetworkInfo struct { // Name is juju-internal name of the network. Name string // ProviderId is a provider-specific network id. ProviderId network.Id // CIDR of the network, in 123.45.67.89/24 format. CIDR string // VLANTag needs to be between 1 and 4094 for VLANs and 0 for // normal networks. It's defined by IEEE 802.1Q standard. VLANTag int }
NetworkInfo describes a single network.
type NetworkInterface ¶
type NetworkInterface struct {
// contains filtered or unexported fields
}
NetworkInterface represents the state of a machine network interface.
func (*NetworkInterface) Disable ¶
func (ni *NetworkInterface) Disable() (err error)
Disable changes the state of the network interface to disabled. In case of a physical interface that has dependent virtual interfaces (e.g. VLANs), those will be disabled along with their parent interface. If the interface is already disabled, nothing happens and no error is returned.
func (*NetworkInterface) Enable ¶
func (ni *NetworkInterface) Enable() (err error)
Enable changes the state of the network interface to enabled. If the interface is already enabled, nothing happens and no error is returned.
func (*NetworkInterface) GoString ¶
func (ni *NetworkInterface) GoString() string
GoString implements fmt.GoStringer.
func (*NetworkInterface) Id ¶
func (ni *NetworkInterface) Id() string
Id returns the internal juju-specific id of the interface.
func (*NetworkInterface) InterfaceName ¶
func (ni *NetworkInterface) InterfaceName() string
InterfaceName returns the name of the interface.
func (*NetworkInterface) IsDisabled ¶
func (ni *NetworkInterface) IsDisabled() bool
IsDisabled returns whether the interface is disabled.
func (*NetworkInterface) IsPhysical ¶
func (ni *NetworkInterface) IsPhysical() bool
IsPhysical returns whether the interface represents a physical device.
func (*NetworkInterface) IsVirtual ¶
func (ni *NetworkInterface) IsVirtual() bool
IsVirtual returns whether the interface represents a virtual device.
func (*NetworkInterface) MACAddress ¶
func (ni *NetworkInterface) MACAddress() string
MACAddress returns the MAC address of the interface.
func (*NetworkInterface) MachineId ¶
func (ni *NetworkInterface) MachineId() string
MachineId returns the machine id of the interface.
func (*NetworkInterface) MachineTag ¶
func (ni *NetworkInterface) MachineTag() names.MachineTag
MachineTag returns the machine tag of the interface.
func (*NetworkInterface) NetworkName ¶
func (ni *NetworkInterface) NetworkName() string
NetworkName returns the network name of the interface.
func (*NetworkInterface) NetworkTag ¶
func (ni *NetworkInterface) NetworkTag() names.NetworkTag
NetworkTag returns the network tag of the interface.
func (*NetworkInterface) RawInterfaceName ¶
func (ni *NetworkInterface) RawInterfaceName() string
RawInterfaceName return the name of the raw interface.
func (*NetworkInterface) Refresh ¶
func (ni *NetworkInterface) Refresh() error
Refresh refreshes the contents of the network interface from the underlying state. It returns an error that satisfies errors.IsNotFound if the machine has been removed.
func (*NetworkInterface) Remove ¶
func (ni *NetworkInterface) Remove() (err error)
Remove removes the network interface from state.
type NetworkInterfaceInfo ¶
type NetworkInterfaceInfo struct { // MACAddress is the network interface's hardware MAC address // (e.g. "aa:bb:cc:dd:ee:ff"). MACAddress string // InterfaceName is the OS-specific network device name (e.g. // "eth0", or "eth1.42" for a VLAN virtual interface, or // "eth1:suffix" for a network alias). InterfaceName string // NetworkName is this interface's network name. NetworkName string // IsVirtual is true when the interface is a virtual device, as // opposed to a physical device (e.g. a VLAN or a network alias). IsVirtual bool // Disabled returns whether the interface is disabled. Disabled bool }
NetworkInterfaceInfo describes a single network interface available on an instance.
type NeverConnectedError ¶
type NeverConnectedError string
NeverConnectedError is used to indicate that a user has never connected to an environment.
func (NeverConnectedError) Error ¶
func (e NeverConnectedError) Error() string
Error returns the error string for a user who has never connected to an environment.
type NeverLoggedInError ¶
type NeverLoggedInError string
NeverLoggedInError is used to indicate that a user has never logged in.
func (NeverLoggedInError) Error ¶
func (e NeverLoggedInError) Error() string
Error returns the error string for a user who has never logged in.
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 Prechecker or an error. Prechecker(*config.Config) (Prechecker, error) // ConfigValidator takes a provider type name and returns a ConfigValidator // or an error. ConfigValidator(providerType string) (ConfigValidator, error) // EnvironCapability takes a *config.Config and returns an EnvironCapability // or an error. EnvironCapability(*config.Config) (EnvironCapability, error) // ConstraintsValidator takes a *config.Config and returns a // constraints.Validator or an error. ConstraintsValidator(*config.Config) (constraints.Validator, error) // InstanceDistributor takes a *config.Config and returns an // InstanceDistributor or an error. InstanceDistributor(*config.Config) (InstanceDistributor, 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 PortRange ¶
PortRange represents a single range of ports opened by one unit.
func NewPortRange ¶
NewPortRange create a new port range and validate it.
func PortRangeFromNetworkPortRange ¶
PortRangeFromNetworkPortRange constructs a state.PortRange from the given unitName and network.PortRange.
func (PortRange) CheckConflicts ¶
CheckConflicts determines if the two port ranges conflict.
func (PortRange) Length ¶
Length returns the number of ports in the range. If the range is not valid, it returns 0.
func (PortRange) SanitizeBounds ¶
Sanitize returns a copy of the port range, which is guaranteed to have FromPort >= ToPort and both FromPort and ToPort fit into the valid range from 1 to 65535, inclusive.
type Ports ¶
type Ports struct {
// contains filtered or unexported fields
}
Ports represents the state of ports on a machine.
func (*Ports) AllPortRanges ¶
AllPortRanges returns a map with network.PortRange as keys and unit names as values.
func (*Ports) ClosePorts ¶
ClosePorts removes the specified port range from the list of ports maintained by this document.
func (*Ports) NetworkName ¶
NetworkName returns the network name associated with this ports document.
func (*Ports) OpenPorts ¶
OpenPorts adds the specified port range to the list of ports maintained by this document.
func (*Ports) PortsForUnit ¶
PortsForUnit returns the ports associated with specified unit that are maintained on this document (i.e. are open on this unit's assigned machine).
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, placement string) error }
Prechecker is a policy interface that is provided to State to perform pre-flight checking of instance creation.
type RebootAction ¶
type RebootAction string
RebootAction defines the action a machine should take when a hook needs to reboot
const ( // ShouldDoNothing instructs a machine agent that no action // is required on its part ShouldDoNothing RebootAction = "noop" // ShouldReboot instructs a machine to reboot // this happens when a hook running on a machine, requests // a reboot ShouldReboot RebootAction = "reboot" // ShouldShutdown instructs a machine to shut down. This usually // happens when running inside a container, and a hook on the parent // machine requests a reboot ShouldShutdown RebootAction = "shutdown" )
type RebootActionGetter ¶
type RebootActionGetter interface {
ShouldRebootOrShutdown() (RebootAction, error)
}
type RebootFlagSetter ¶
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 errors.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 and not left it.
func (*RelationUnit) Joined ¶
func (ru *RelationUnit) Joined() (bool, error)
Joined returns whether the relation unit has entered scope and neither left it nor prepared to leave it.
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) PrepareLeaveScope ¶
func (ru *RelationUnit) PrepareLeaveScope() error
PrepareLeaveScope causes the unit to be reported as departed by watchers, but does not *actually* leave the scope, to avoid triggering relation cleanup.
func (*RelationUnit) PrivateAddress ¶
func (ru *RelationUnit) PrivateAddress() (network.Address, error)
PrivateAddress returns the private address of the unit.
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 multiwatcher.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" )
These are available ResolvedMode values.
type RestoreInfo ¶
type RestoreInfo struct {
// contains filtered or unexported fields
}
RestoreInfo its used to syncronize Restore and machine agent
func (*RestoreInfo) SetStatus ¶
func (info *RestoreInfo) SetStatus(status RestoreStatus) error
SetStatus sets the status of the current restore. Checks are made to ensure that status changes are performed in the correct order.
func (*RestoreInfo) Status ¶
func (info *RestoreInfo) Status() RestoreStatus
Status returns the current Restore doc status
type RestoreStatus ¶
type RestoreStatus string
RestoreStatus is the type of the statuses
const ( // UnknownRestoreStatus is the initial status for restoreInfoDoc. UnknownRestoreStatus RestoreStatus = "UNKNOWN" // RestorePending is a status to signal that a restore is about to start // any change done in this status will be lost. RestorePending RestoreStatus = "PENDING" // RestoreInProgress indicates that a Restore is in progress. RestoreInProgress RestoreStatus = "RESTORING" // RestoreFinished it is set by restore upon a succesful run. RestoreFinished RestoreStatus = "RESTORED" // RestoreChecked is set when the server comes up after a succesful restore. RestoreChecked RestoreStatus = "CHECKED" // RestoreFailed indicates that the process failed in a recoverable step. RestoreFailed RestoreStatus = "FAILED" )
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents the state of a service.
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) LeaderSettings ¶
LeaderSettings returns a service's leader settings. If nothing has been set yet, it will return an empty map; this is not an error.
func (*Service) MetricCredentials ¶
MetricCredentials returns any metric credentials associated with this service.
func (*Service) Networks ¶
Networks returns the networks a service is associated with. Unlike networks specified with constraints, these networks are required to be present on machines hosting this service's units.
TODO(dimitern): Convert this to use spaces from constraints or drop it entirely.
func (*Service) Refresh ¶
Refresh refreshes the contents of the Service from the underlying state. It returns an error that satisfies errors.IsNotFound if the service has been removed.
func (*Service) ServiceAndUnitsStatus ¶
func (s *Service) ServiceAndUnitsStatus() (StatusInfo, map[string]StatusInfo, error)
ServiceAndUnitsStatus returns the status for this service and all its units.
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) SetMetricCredentials ¶
SetMetricCredentials updates the metric credentials associated with this service.
func (*Service) SetMinUnits ¶
SetMinUnits changes the number of minimum units required by the service.
func (*Service) Status ¶
func (s *Service) Status() (StatusInfo, error)
Status returns the status of the service. Only unit leaders are allowed to set the status of the service. If no status is recorded, then there are no unit leaders and the status is derived from the unit status values.
func (*Service) StorageConstraints ¶
func (s *Service) StorageConstraints() (map[string]StorageConstraints, error)
func (*Service) Tag ¶
Tag returns a name identifying the service. 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) UpdateLeaderSettings ¶
UpdateLeaderSettings updates the service's leader settings with the supplied values, but will fail (with a suitable error) if the supplied Token loses validity. Empty values in the supplied map will be cleared in the database.
func (*Service) Watch ¶
func (s *Service) Watch() NotifyWatcher
Watch returns a watcher for observing changes to a service.
func (*Service) WatchLeaderSettings ¶
func (s *Service) WatchLeaderSettings() NotifyWatcher
WatchLeaderSettings returns a watcher for observing changed to a service's leader settings.
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 SessionCloser ¶
type SessionCloser func()
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 Space ¶
type Space struct {
// contains filtered or unexported fields
}
Space represents the state of a space. A space is a security subdivision of a network. In practice, a space is a collection of related subnets that have no firewalls between each other, and that have the same ingress and egress policies.
func (*Space) EnsureDead ¶
EnsureDead sets the Life of the space to Dead, if it's Alive. It does nothing otherwise.
func (*Space) Refresh ¶
Refresh: refreshes the contents of the Space from the underlying state. It returns an error that satisfies errors.IsNotFound if the Space has been removed.
type State ¶
type State struct { // TODO(anastasiamac 2015-07-16) As state gets broken up, remove this. CloudImageMetadataStorage cloudimagemetadata.Storage // contains filtered or unexported fields }
State represents the state of an environment managed by juju.
func Initialize ¶
func Initialize(owner names.UserTag, info *mongo.MongoInfo, cfg *config.Config, opts mongo.DialOpts, policy Policy) (_ *State, err error)
Initialize sets up an initial empty state and returns it. This needs to be performed only once for the initial state server environment. It returns unauthorizedError if access is unauthorized.
func Open ¶
func Open(tag names.EnvironTag, info *mongo.MongoInfo, opts mongo.DialOpts, policy Policy) (*State, error)
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) APIAddressesFromMachines ¶
APIAddressesFromMachines returns the list of cloud-internal addresses that can be used to connect to the state API server. This method will be deprecated when API addresses are stored independently in their own document.
func (*State) APIHostPorts ¶
APIHostPorts returns the API addresses as set by SetAPIHostPorts.
func (*State) AbortCurrentUpgrade ¶
AbortCurrentUpgrade archives any current UpgradeInfo and sets its status to UpgradeAborted. Nothing happens if there's no current UpgradeInfo.
func (*State) ActionByTag ¶
ActionByTag returns an Action given an ActionTag.
func (*State) AddCharm ¶
func (st *State) AddCharm(ch charm.Charm, curl *charm.URL, storagePath, bundleSha256 string) (stch *Charm, err error)
AddCharm adds the ch charm with curl to the state. On success the newly added charm state is returned.
func (*State) AddEnvironmentUser ¶
func (st *State) AddEnvironmentUser(user, createdBy names.UserTag, displayName string) (*EnvironmentUser, error)
AddEnvironmentUser adds a new user to the database.
func (*State) AddIPAddress ¶
AddIPAddress creates and returns a new IP address. It can return an error satisfying IsNotValid() or IsAlreadyExists() when the addr does not contain a valid IP, or when addr is already added.
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) AddMetrics ¶
func (st *State) AddMetrics(batch BatchParam) (*MetricBatch, error)
AddMetrics adds a new batch of metrics to the database.
func (*State) AddNetwork ¶
func (st *State) AddNetwork(args NetworkInfo) (n *Network, err error)
AddNetwork creates a new network with the given params. If a network with the same name or provider id already exists in state, an error satisfying errors.IsAlreadyExists is returned.
func (*State) AddOneMachine ¶
func (st *State) AddOneMachine(template MachineTemplate) (*Machine, error)
AddOneMachine 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 ¶
func (st *State) AddService( name, owner string, ch *Charm, networks []string, storage map[string]StorageConstraints, ) (service *Service, err error)
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) AddSpace ¶
func (st *State) AddSpace(name string, subnets []string, isPublic bool) (newSpace *Space, err error)
AddSpace creates and returns a new space.
func (*State) AddStorageForUnit ¶
func (st *State) AddStorageForUnit( tag names.UnitTag, name string, cons StorageConstraints, ) error
AddStorage adds storage instances to given unit as specified. Missing storage constraints are populated based on environment defaults. Storage store name is used to retrieve existing storage instances for this store. Combination of existing storage instances and anticipated additional storage instances is validated against storage store as specified in the charm.
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) AddSubnet ¶
func (st *State) AddSubnet(args SubnetInfo) (subnet *Subnet, err error)
AddSubnet creates and returns a new subnet
func (*State) Addresses ¶
Addresses returns the list of cloud-internal addresses that can be used to connect to the state.
func (*State) AllBlocksForSystem ¶
AllBlocksForSystem returns all blocks in any environments on the system.
func (*State) AllEnvironments ¶
func (st *State) AllEnvironments() ([]*Environment, error)
AllEnvironments returns all the environments in the system.
func (*State) AllFilesystems ¶
func (st *State) AllFilesystems() ([]Filesystem, error)
AllFilesystems returns all Filesystems for this state.
func (*State) AllMachines ¶
AllMachines returns all machines in the environment ordered by id.
func (*State) AllNetworks ¶
AllNetworks returns all known networks in the environment.
func (*State) AllRelations ¶
AllRelations returns all relations in the environment ordered by id.
func (*State) AllServices ¶
AllServices returns all deployed services in the environment.
func (*State) AllStorageInstances ¶
func (st *State) AllStorageInstances() (storageInstances []StorageInstance, err error)
AllStorageInstances lists all storage instances currently in state for this Juju environment.
func (*State) AllSubnets ¶
AllSubnets returns all known subnets in the environment.
func (*State) AllVolumes ¶
AllVolumes returns all Volumes scoped to the environment.
func (*State) AllocatedIPAddresses ¶
AllocatedIPAddresses returns all the allocated addresses for a machine
func (*State) Annotation ¶
func (st *State) Annotation(entity GlobalEntity, key string) (string, error)
Annotation returns the annotation value corresponding to the given key. If the requested annotation is not found, an empty string is returned.
func (*State) Annotations ¶
func (st *State) Annotations(entity GlobalEntity) (map[string]string, error)
Annotations returns all the annotations corresponding to an entity.
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) BlockDevices ¶
func (st *State) BlockDevices(machine names.MachineTag) ([]BlockDeviceInfo, error)
BlockDevices returns the BlockDeviceInfo for the specified machine.
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) CleanupOldMetrics ¶
CleanupOldMetrics looks for metrics that are 24 hours old (or older) and have been sent. Any metrics it finds are deleted.
func (*State) ClearUpgradeInfo ¶
ClearUpgradeInfo clears information about an upgrade in progress. It returns an error if no upgrade is current.
func (*State) CountOfSentMetrics ¶
CountOfSentMetrics returns the number of metrics that have been sent to the collection service and have not been removed by the cleanup worker.
func (*State) CountOfUnsentMetrics ¶
CountOfUnsentMetrics returns the number of metrics that haven't been sent to the collection service.
func (*State) DeadIPAddresses ¶
DeadIPAddresses returns all IP addresses with a Life of Dead
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) DestroyFilesystem ¶
func (st *State) DestroyFilesystem(tag names.FilesystemTag) (err error)
DestroyFilesystem ensures that the filesystem and any attachments to it will be destroyed and removed from state at some point in the future.
func (*State) DestroyStorageAttachment ¶
DestroyStorageAttachment ensures that the storage attachment will be removed at some point.
func (*State) DestroyStorageInstance ¶
func (st *State) DestroyStorageInstance(tag names.StorageTag) (err error)
DestroyStorageInstance ensures that the storage instance and all its attachments will be removed at some point; if the storage instance has no attachments, it will be removed immediately.
func (*State) DestroyUnitStorageAttachments ¶
DestroyStorageAttachment ensures that the existing storage attachments of the specified unit are removed at some point.
func (*State) DestroyVolume ¶
DestroyVolume ensures that the volume and any attachments to it will be destroyed and removed from state at some point in the future. DestroyVolume will fail with an IsContainsFilesystem error if the volume contains a filesystem; the filesystem must be fully removed first.
func (*State) DetachFilesystem ¶
func (st *State) DetachFilesystem(machine names.MachineTag, filesystem names.FilesystemTag) (err error)
DetachFilesystem marks the filesystem attachment identified by the specified machine and filesystem tags as Dying, if it is Alive.
func (*State) DetachVolume ¶
DetachVolume marks the volume attachment identified by the specified machine and volume tags as Dying, if it is Alive. DetachVolume will fail with a IsContainsFilesystem error if the volume contains an attached filesystem; the filesystem attachment must be removed first.
func (*State) EndpointsRelation ¶
EndpointsRelation returns the existing relation with the given endpoints.
func (*State) EnqueueAction ¶
func (st *State) EnqueueAction(receiver names.Tag, actionName string, payload map[string]interface{}) (*Action, error)
EnqueueAction
func (*State) EnsureAvailability ¶
func (st *State) EnsureAvailability( numStateServers int, cons constraints.Value, series string, placement []string, ) (StateServersChanges, 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. If placement is not empty, any new machines which may be required are started according to the specified placement directives until the placement list is exhausted; thereafter any new machines are started according to the constraints and series.
func (*State) EnsureEnvironmentRemoved ¶
EnsureEnvironmentRemoved returns an error if any multi-environment documents for this environment are found. It is intended only to be used in tests and exported so it can be used in the tests of other packages.
func (*State) EnsureUpgradeInfo ¶
func (st *State) EnsureUpgradeInfo(machineId string, previousVersion, targetVersion version.Number) (*UpgradeInfo, error)
EnsureUpgradeInfo returns an UpgradeInfo describing a current upgrade between the supplied versions. If a matching upgrade is in progress, that upgrade is returned; if there's a mismatch, an error is returned. The supplied machine id must correspond to a current state server.
func (*State) EnvironConstraints ¶
func (st *State) EnvironConstraints() (constraints.Value, error)
EnvironConstraints returns the current environment constraints.
func (*State) EnvironTag ¶
func (st *State) EnvironTag() names.EnvironTag
EnvironTag() returns the environment tag for the environment controlled by this state instance.
func (*State) EnvironUUID ¶
EnvironUUID returns the environment UUID for the environment controlled by this state instance.
func (*State) Environment ¶
func (st *State) Environment() (*Environment, error)
Environment returns the environment entity.
func (*State) EnvironmentUser ¶
func (st *State) EnvironmentUser(user names.UserTag) (*EnvironmentUser, error)
EnvironmentUser returns the environment user.
func (*State) EnvironmentsForUser ¶
func (st *State) EnvironmentsForUser(user names.UserTag) ([]*UserEnvironment, error)
EnvironmentsForUser returns a list of enviroments that the user is able to access.
func (*State) Filesystem ¶
func (st *State) Filesystem(tag names.FilesystemTag) (Filesystem, error)
Filesystem returns the Filesystem with the specified name.
func (*State) FilesystemAttachment ¶
func (st *State) FilesystemAttachment(machine names.MachineTag, filesystem names.FilesystemTag) (FilesystemAttachment, error)
FilesystemAttachment returns the FilesystemAttachment corresponding to the specified filesystem and machine.
func (*State) FilesystemAttachments ¶
func (st *State) FilesystemAttachments(filesystem names.FilesystemTag) ([]FilesystemAttachment, error)
FilesystemAttachments returns all of the FilesystemAttachments for the specified filesystem.
func (*State) FilesystemStatus ¶
func (st *State) FilesystemStatus(tag names.FilesystemTag) (StatusInfo, error)
FilesystemStatus returns the status of the specified filesystem.
func (*State) FindActionTagsByPrefix ¶
FindActionTagsByPrefix finds Actions with ids that share the supplied prefix, and returns a list of corresponding ActionTags.
func (*State) FindEntity ¶
FindEntity returns the entity with the given tag.
The returned value can be of type *Machine, *Unit, *User, *Service, *Environment, or *Action, depending on the tag.
func (*State) ForEnviron ¶
func (st *State) ForEnviron(env names.EnvironTag) (*State, error)
ForEnviron returns a connection to mongo for the specified environment. The connection uses the same credentials and policy as the existing connection.
func (*State) GetBlockForType ¶
GetBlockForType returns the Block of the specified type for the current environment where
not found -> nil, false, nil found -> block, true, nil error -> nil, false, err
func (*State) GetEnvironment ¶
func (st *State) GetEnvironment(tag names.EnvironTag) (*Environment, error)
GetEnvironment looks for the environment identified by the uuid passed in.
func (*State) HackLeadership ¶
func (st *State) HackLeadership()
HackLeadership stops the state's internal leadership manager to prevent it from interfering with apiserver shutdown.
func (*State) IPAddressByTag ¶
func (st *State) IPAddressByTag(tag names.IPAddressTag) (*IPAddress, error)
IPAddressByTag returns an existing IP address from the state identified by its tag.
func (*State) ImageStorage ¶
func (st *State) ImageStorage() imagestorage.Storage
ImageStorage returns a new imagestorage.Storage that stores image metadata.
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) IsStateServer ¶
IsStateServer returns true if this state instance has the bootstrap environment UUID.
func (*State) IsSystemAdministrator ¶
IsSystemAdministrator returns true if the user specified has access to the state server environment (the system environment).
func (*State) IsUpgrading ¶
IsUpgrading returns true if an upgrade is currently in progress.
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) LeadershipChecker ¶
func (st *State) LeadershipChecker() leadership.Checker
LeadershipChecker returns a leadership.Checker for units and services in the state's environment.
func (*State) LeadershipClaimer ¶
func (st *State) LeadershipClaimer() leadership.Claimer
LeadershipClaimer returns a leadership.Claimer for units and services in the state's environment.
func (*State) MachineFilesystemAttachments ¶
func (st *State) MachineFilesystemAttachments(machine names.MachineTag) ([]FilesystemAttachment, error)
MachineFilesystemAttachments returns all of the FilesystemAttachments for the specified machine.
func (*State) MachineVolumeAttachments ¶
func (st *State) MachineVolumeAttachments(machine names.MachineTag) ([]VolumeAttachment, error)
MachineVolumeAttachments returns all of the VolumeAttachments for the specified machine.
func (*State) MaybePruneTransactions ¶
MaybePruneTransactions removes data for completed transactions.
func (*State) MetricBatch ¶
func (st *State) MetricBatch(id string) (*MetricBatch, error)
MetricBatch returns the metric batch with the given id.
func (*State) MetricBatches ¶
func (st *State) MetricBatches() ([]MetricBatch, error)
MetricBatches returns all metric batches currently stored in state. TODO (tasdomas): this method is currently only used in the uniter worker test -
it needs to be modified to restrict the scope of the values it returns if it is to be used outside of tests.
func (*State) MetricsManager ¶
func (st *State) MetricsManager() (*MetricsManager, error)
MetricsManager returns an existing metricsmanager, or a new one if non exists.
func (*State) MetricsToSend ¶
func (st *State) MetricsToSend(batchSize int) ([]*MetricBatch, error)
MetricsToSend returns batchSize metrics that need to be sent to the collector
func (*State) MongoConnectionInfo ¶
MongoConnectionInfo returns information for connecting to mongo
func (*State) MongoSession ¶
func (st *State) MongoSession() *mgo.Session
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) NewEnvironment ¶
func (st *State) NewEnvironment(cfg *config.Config, owner names.UserTag) (_ *Environment, _ *State, err error)
NewEnvironment creates a new environment with its own UUID and prepares it for use. Environment and State instances for the new environment are returned.
The state server environment's UUID is attached to the new environment's document. Having the server UUIDs stored with each environment document means that we have a way to represent external environments, perhaps for future use around cross environment relations.
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 (it 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) ReadSettings ¶
ReadSettings returns the settings for the given key.
func (*State) RemoveAllBlocksForSystem ¶
RemoveAllBlocksForSystem removes all the blocks for the system. It does not prevent new blocks from being added during / after removal.
func (*State) RemoveAllEnvironDocs ¶
RemoveAllEnvironDocs removes all documents from multi-environment collections. The environment should be put into a dying state before call this method. Otherwise, there is a race condition in which collections could be added to during or after the running of this method.
func (*State) RemoveEnvironmentUser ¶
RemoveEnvironmentUser removes a user from the database.
func (*State) RemoveFilesystem ¶
func (st *State) RemoveFilesystem(tag names.FilesystemTag) (err error)
RemoveFilesystem removes the filesystem from state. RemoveFilesystem will fail if there are any attachments remaining, or if the filesystem is not Dying. Removing a volume-backed filesystem will cause the volume to be destroyed.
func (*State) RemoveFilesystemAttachment ¶
func (st *State) RemoveFilesystemAttachment(machine names.MachineTag, filesystem names.FilesystemTag) (err error)
RemoveFilesystemAttachment removes the filesystem attachment from state. Removing a volume-backed filesystem attachment will cause the volume to be detached.
func (*State) RemoveStorageAttachment ¶
Remove removes the storage attachment from state, and may remove its storage instance as well, if the storage instance is Dying and no other references to it exist. It will fail if the storage attachment is not Dead.
func (*State) RemoveVolume ¶
RemoveVolume removes the volume from state. RemoveVolume will fail if the volume is not Dead, which implies that it still has attachments.
func (*State) RemoveVolumeAttachment ¶
func (st *State) RemoveVolumeAttachment(machine names.MachineTag, volume names.VolumeTag) (err error)
RemoveVolumeAttachment removes the volume attachment from state. RemoveVolumeAttachment will fail if the attachment is not Dying.
func (*State) RestoreInfoSetter ¶
func (st *State) RestoreInfoSetter() (*RestoreInfo, error)
RestoreInfoSetter returns the current info doc, if it does not exists it creates it with UnknownRestoreStatus status
func (*State) ResumeTransactions ¶
ResumeTransactions resumes all pending transactions.
func (*State) SetAPIHostPorts ¶
SetAPIHostPorts sets the addresses of the API server instances. Each server is represented by one element in the top level slice.
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) SetAnnotations ¶
func (st *State) SetAnnotations(entity GlobalEntity, annotations map[string]string) (err error)
SetAnnotations adds key/value pairs to annotations in MongoDB.
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). If this is a hosted environment, newVersion cannot be higher than the state server version.
func (*State) SetEnvironConstraints ¶
func (st *State) SetEnvironConstraints(cons constraints.Value) error
SetEnvironConstraints replaces the current environment constraints.
func (*State) SetFilesystemAttachmentInfo ¶
func (st *State) SetFilesystemAttachmentInfo( machineTag names.MachineTag, filesystemTag names.FilesystemTag, info FilesystemAttachmentInfo, ) (err error)
SetFilesystemAttachmentInfo sets the FilesystemAttachmentInfo for the specified filesystem attachment.
func (*State) SetFilesystemInfo ¶
func (st *State) SetFilesystemInfo(tag names.FilesystemTag, info FilesystemInfo) (err error)
SetFilesystemInfo sets the FilesystemInfo for the specified filesystem.
func (*State) SetFilesystemStatus ¶
func (st *State) SetFilesystemStatus(tag names.FilesystemTag, status Status, info string, data map[string]interface{}) error
SetFilesystemStatus sets the status of the specified filesystem.
func (*State) SetMetricBatchesSent ¶
SetMetricBatchesSent sets sent on each MetricBatch corresponding to the uuids provided.
func (*State) SetStateServingInfo ¶
func (st *State) SetStateServingInfo(info StateServingInfo) error
SetStateServingInfo stores information needed for running a state server
func (*State) SetVolumeAttachmentInfo ¶
func (st *State) SetVolumeAttachmentInfo(machineTag names.MachineTag, volumeTag names.VolumeTag, info VolumeAttachmentInfo) (err error)
SetVolumeAttachmentInfo sets the VolumeAttachmentInfo for the specified volume attachment.
func (*State) SetVolumeInfo ¶
func (st *State) SetVolumeInfo(tag names.VolumeTag, info VolumeInfo) (err error)
SetVolumeInfo sets the VolumeInfo for the specified volume.
func (*State) SetVolumeStatus ¶
func (st *State) SetVolumeStatus(tag names.VolumeTag, status Status, info string, data map[string]interface{}) error
SetVolumeStatus sets the status of the specified volume.
func (*State) Space ¶
Space returns a space from state that matches the provided name. An error is returned if the space doesn't exist or if there was a problem accessing its information.
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) StateServerEnvironment ¶
func (st *State) StateServerEnvironment() (*Environment, error)
StateServerEnvironment returns the environment that was bootstrapped. This is the only environment that can have state server machines. The owner of this environment is also considered "special", in that they are the only user that is able to create other users (until we have more fine grained permissions), and they cannot be disabled.
func (*State) StateServerInfo ¶
func (st *State) StateServerInfo() (*StateServerInfo, error)
StateServerInfo returns information about the currently configured state server machines.
func (*State) StateServingInfo ¶
func (st *State) StateServingInfo() (StateServingInfo, error)
StateServingInfo returns information for running a state server machine
func (*State) StorageAttachment ¶
func (st *State) StorageAttachment(storage names.StorageTag, unit names.UnitTag) (StorageAttachment, error)
StorageAttachment returns the StorageAttachment wit hthe specified tags.
func (*State) StorageAttachments ¶
func (st *State) StorageAttachments(storage names.StorageTag) ([]StorageAttachment, error)
StorageAttachments returns the StorageAttachments for the specified storage instance.
func (*State) StorageInstance ¶
func (st *State) StorageInstance(tag names.StorageTag) (StorageInstance, error)
StorageInstance returns the StorageInstance with the specified tag.
func (*State) StorageInstanceFilesystem ¶
func (st *State) StorageInstanceFilesystem(tag names.StorageTag) (Filesystem, error)
StorageInstanceFilesystem returns the Filesystem assigned to the specified storage instance.
func (*State) StorageInstanceVolume ¶
func (st *State) StorageInstanceVolume(tag names.StorageTag) (Volume, error)
StorageInstanceVolume returns the Volume assigned to the specified storage instance.
func (*State) SwitchBlockOff ¶
SwitchBlockOff disables block of specified type for the current environment.
func (*State) SwitchBlockOn ¶
SwitchBlockOn enables block of specified type for the current environment.
func (*State) ToolsStorage ¶
func (st *State) ToolsStorage() (toolstorage.StorageCloser, error)
ToolsStorage returns a new toolstorage.StorageCloser that stores tools metadata in the "juju" database” "toolsmetadata" collection.
TODO(axw) remove this, add a constructor function in toolstorage.
func (*State) UnitStorageAttachments ¶
func (st *State) UnitStorageAttachments(unit names.UnitTag) ([]StorageAttachment, error)
UnitStorageAttachments returns the StorageAttachments for the specified unit.
func (*State) UpdateEnvironConfig ¶
func (st *State) UpdateEnvironConfig(updateAttrs map[string]interface{}, removeAttrs []string, additionalValidation ValidateConfigFunc) error
UpdateEnvironConfig adds, updates or removes attributes in the current configuration of the environment with the provided updateAttrs and removeAttrs.
func (*State) UpdateUploadedCharm ¶
func (st *State) UpdateUploadedCharm(ch charm.Charm, curl *charm.URL, storagePath, 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) VolumeAttachment ¶
func (st *State) VolumeAttachment(machine names.MachineTag, volume names.VolumeTag) (VolumeAttachment, error)
VolumeAttachment returns the VolumeAttachment corresponding to the specified volume and machine.
func (*State) VolumeAttachments ¶
func (st *State) VolumeAttachments(volume names.VolumeTag) ([]VolumeAttachment, error)
VolumeAttachments returns all of the VolumeAttachments for the specified volume.
func (*State) VolumeFilesystem ¶
func (st *State) VolumeFilesystem(tag names.VolumeTag) (Filesystem, error)
VolumeFilesystem returns the Filesystem backed by the specified volume.
func (*State) VolumeStatus ¶
func (st *State) VolumeStatus(tag names.VolumeTag) (StatusInfo, error)
VolumeStatus returns the status of the specified volume.
func (*State) Watch ¶
func (st *State) Watch() *Multiwatcher
func (*State) WatchAPIHostPorts ¶
func (st *State) WatchAPIHostPorts() NotifyWatcher
WatchAPIHostPorts returns a NotifyWatcher that notifies when the set of API addresses changes.
func (*State) WatchActionResults ¶
func (st *State) WatchActionResults() StringsWatcher
WatchActionResults starts and returns a StringsWatcher that notifies on new ActionResults being added.
func (*State) WatchActionResultsFilteredBy ¶
func (st *State) WatchActionResultsFilteredBy(receivers ...ActionReceiver) StringsWatcher
WatchActionResultsFilteredBy starts and returns a StringsWatcher that notifies on new ActionResults being added for the ActionRecevers being watched.
func (*State) WatchAllEnvs ¶
func (st *State) WatchAllEnvs() *Multiwatcher
func (*State) WatchBlockDevices ¶
func (st *State) WatchBlockDevices(machine names.MachineTag) NotifyWatcher
WatchBlockDevices returns a new NotifyWatcher watching for changes to block devices associated with the specified machine.
func (*State) WatchCleanups ¶
func (st *State) WatchCleanups() NotifyWatcher
WatchCleanups starts and returns a CleanupWatcher.
func (*State) WatchEnvironConfig ¶
func (st *State) WatchEnvironConfig() *EnvironConfigWatcher
WatchEnvironConfig returns a watcher for observing changes to the environment configuration.
func (*State) WatchEnvironFilesystemAttachments ¶
func (st *State) WatchEnvironFilesystemAttachments() StringsWatcher
WatchEnvironFilesystemAttachments returns a StringsWatcher that notifies of changes to the lifecycles of all filesystem attachments related to environ-scoped filesystems.
func (*State) WatchEnvironFilesystems ¶
func (st *State) WatchEnvironFilesystems() StringsWatcher
WatchEnvironFilesystems returns a StringsWatcher that notifies of changes to the lifecycles of all environment-scoped filesystems.
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) WatchEnvironVolumeAttachments ¶
func (st *State) WatchEnvironVolumeAttachments() StringsWatcher
WatchEnvironVolumeAttachments returns a StringsWatcher that notifies of changes to the lifecycles of all volume attachments related to environ- scoped volumes.
func (*State) WatchEnvironVolumes ¶
func (st *State) WatchEnvironVolumes() StringsWatcher
WatchEnvironVolumes returns a StringsWatcher that notifies of changes to the lifecycles of all environment-scoped volumes.
func (*State) WatchEnvironments ¶
func (st *State) WatchEnvironments() StringsWatcher
WatchEnvironments returns a StringsWatcher that notifies of changes to the lifecycles of all environments.
func (*State) WatchFilesystemAttachment ¶
func (st *State) WatchFilesystemAttachment(m names.MachineTag, f names.FilesystemTag) NotifyWatcher
WatchFilesystemAttachment returns a watcher for observing changes to a filesystem attachment.
func (*State) WatchForEnvironConfigChanges ¶
func (st *State) WatchForEnvironConfigChanges() NotifyWatcher
WatchForEnvironConfigChanges returns 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) WatchIPAddresses ¶
func (st *State) WatchIPAddresses() StringsWatcher
WatchIPAddresses returns a StringsWatcher that notifies of changes to the lifecycles of IP addresses.
func (*State) WatchMachineFilesystemAttachments ¶
func (st *State) WatchMachineFilesystemAttachments(m names.MachineTag) StringsWatcher
WatchMachineFilesystemAttachments returns a StringsWatcher that notifies of changes to the lifecycles of all filesystem attachments related to the specified machine, for filesystems scoped to the machine.
func (*State) WatchMachineFilesystems ¶
func (st *State) WatchMachineFilesystems(m names.MachineTag) StringsWatcher
WatchMachineFilesystems returns a StringsWatcher that notifies of changes to the lifecycles of all filesystems scoped to the specified machine.
func (*State) WatchMachineVolumeAttachments ¶
func (st *State) WatchMachineVolumeAttachments(m names.MachineTag) StringsWatcher
WatchMachineVolumeAttachments returns a StringsWatcher that notifies of changes to the lifecycles of all volume attachments related to the specified machine, for volumes scoped to the machine.
func (*State) WatchMachineVolumes ¶
func (st *State) WatchMachineVolumes(m names.MachineTag) StringsWatcher
WatchMachineVolumes returns a StringsWatcher that notifies of changes to the lifecycles of all volumes scoped to the specified machine.
func (*State) WatchMinUnits ¶
func (st *State) WatchMinUnits() StringsWatcher
WatchMinUnits returns a StringsWatcher for the minUnits collection
func (*State) WatchOpenedPorts ¶
func (st *State) WatchOpenedPorts() StringsWatcher
WatchOpenedPorts starts and returns a StringsWatcher notifying of changes to the openedPorts collection. Reported changes have the following format: "<machine-id>:<network-name>", i.e. "0:juju-public".
func (*State) WatchRestoreInfoChanges ¶
func (st *State) WatchRestoreInfoChanges() NotifyWatcher
WatchRestoreInfoChanges returns a NotifyWatcher that will inform when the restore status changes.
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
WatchStateServerInfo returns a NotifyWatcher for the stateServers collection
func (*State) WatchStorageAttachment ¶
func (st *State) WatchStorageAttachment(s names.StorageTag, u names.UnitTag) NotifyWatcher
WatchStorageAttachment returns a watcher for observing changes to a storage attachment.
func (*State) WatchStorageAttachments ¶
func (st *State) WatchStorageAttachments(unit names.UnitTag) StringsWatcher
WatchStorageAttachments returns a StringsWatcher that notifies of changes to the lifecycles of all storage instances attached to the specified unit.
func (*State) WatchUpgradeInfo ¶
func (st *State) WatchUpgradeInfo() NotifyWatcher
WatchUpgradeInfo returns a watcher for observing changes to upgrade synchronisation state.
func (*State) WatchVolumeAttachment ¶
func (st *State) WatchVolumeAttachment(m names.MachineTag, v names.VolumeTag) NotifyWatcher
WatchVolumeAttachment returns a watcher for observing changes to a volume attachment.
type StatePool ¶
type StatePool struct {
// contains filtered or unexported fields
}
StatePool is a simple cache of State instances for multiple environments.
func NewStatePool ¶
NewStatePool returns a new StatePool instance. It takes a State connected to the system (state server environment).
func (*StatePool) Get ¶
Get returns a State for a given environment from the pool, creating one if required.
func (*StatePool) SystemState ¶
SystemState returns the State passed in to NewStatePool.
type StateServerInfo ¶
type StateServerInfo struct { // EnvironmentTag identifies the initial environment. Only the initial // environment is able to have machines that manage state. The initial // environment is the environment that is created when bootstrapping. EnvironmentTag names.EnvironTag // 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 StateServersChanges ¶
type StateServersChanges struct { Added []string Removed []string Maintained []string Promoted []string Demoted []string Converted []string }
Change in state servers after the ensure availability txn has committed.
type StateServingInfo ¶
type StateServingInfo struct { APIPort int StatePort int Cert string PrivateKey string CAPrivateKey string // this will be passed as the KeyFile argument to MongoDB SystemIdentity string }
StateServingInfo holds information needed by a state server. This type is a copy of the type of the same name from the api/params package. It is replicated here to avoid the state pacakge depending on api/params.
type StateSettings ¶
type StateSettings struct {
// contains filtered or unexported fields
}
StateSettings is used to expose various settings APIs outside of the state package.
func NewStateSettings ¶
func NewStateSettings(st *State) *StateSettings
NewStateSettings creates a StateSettings from state.
func (*StateSettings) CreateSettings ¶
func (s *StateSettings) CreateSettings(key string, settings map[string]interface{}) error
CreateSettings exposes createSettings on state for use outside the state package.
func (*StateSettings) ListSettings ¶
func (s *StateSettings) ListSettings(keyPrefix string) (map[string]map[string]interface{}, error)
ListSettings exposes listSettings on state for use outside the state package.
func (*StateSettings) ReadSettings ¶
func (s *StateSettings) ReadSettings(key string) (map[string]interface{}, error)
ReadSettings exposes readSettings on state for use outside the state package.
func (*StateSettings) RemoveSettings ¶
func (s *StateSettings) RemoveSettings(key string) error
RemoveSettings exposes removeSettings on state for use outside the state package.
type Status ¶
type Status string
Status used to represent the status of an entity, but has recently become and applies to "workloads" as well, which we don't currently model, for no very clear reason.
Status values currently apply to machine (agents), unit (agents), unit (workloads), service (workloads), and volumes.
const ( // The entity requires human intervention in order to operate // correctly. StatusError Status = "error" // The entity is actively participating in the environment. // For unit agents, this is a state we preserve for backwards // compatibility with scripts during the life of Juju 1.x. // In Juju 2.x, the agent-state will remain “active” and scripts // will watch the unit-state instead for signals of service readiness. StatusStarted Status = "started" )
Status values common to machine and unit agents.
const ( // The machine is not yet participating in the environment. StatusPending Status = "pending" // The machine's agent will perform no further action, other than // to set the unit to Dead at a suitable moment. StatusStopped Status = "stopped" // The machine ought to be signalling activity, but it cannot be // detected. StatusDown Status = "down" )
Status values specific to machine agents.
const ( // The machine on which a unit is to be hosted is still being // spun up in the cloud. StatusAllocating Status = "allocating" // The machine on which this agent is running is being rebooted. // The juju-agent should move from rebooting to idle when the reboot is complete. StatusRebooting Status = "rebooting" // The agent is running a hook or action. The human-readable message should reflect // which hook or action is being run. StatusExecuting Status = "executing" // Once the agent is installed and running it will notify the Juju server and its state // becomes "idle". It will stay "idle" until some action (e.g. it needs to run a hook) or // error (e.g it loses contact with the Juju server) moves it to a different state. StatusIdle Status = "idle" // The unit agent has failed in some way,eg the agent ought to be signalling // activity, but it cannot be detected. It might also be that the unit agent // detected an unrecoverable condition and managed to tell the Juju server about it. StatusFailed Status = "failed" // The juju agent has has not communicated with the juju server for an unexpectedly long time; // the unit agent ought to be signalling activity, but none has been detected. StatusLost Status = "lost" // ---- Outdated ---- // The unit agent is downloading the charm and running the install hook. StatusInstalling Status = "installing" // The unit is being destroyed; the agent will soon mark the unit as “dead”. // In Juju 2.x this will describe the state of the agent rather than a unit. StatusStopping Status = "stopping" )
Status values specific to unit agents.
const ( // The unit is not yet providing services, but is actively doing stuff // in preparation for providing those services. // This is a "spinning" state, not an error state. // It reflects activity on the unit itself, not on peers or related units. StatusMaintenance Status = "maintenance" // This unit used to exist, we have a record of it (perhaps because of storage // allocated for it that was flagged to survive it). Nonetheless, it is now gone. StatusTerminated Status = "terminated" // A unit-agent has finished calling install, config-changed, and start, // but the charm has not called status-set yet. StatusUnknown Status = "unknown" // The unit is unable to progress to an active state because a service to // which it is related is not running. StatusWaiting Status = "waiting" // The unit needs manual intervention to get back to the Active state. StatusBlocked Status = "blocked" // The unit believes it is correctly offering all the services it has // been asked to offer. StatusActive Status = "active" )
Status values specific to services and units, reflecting the state of the software itself.
const ( // StatusAttaching indicates that the storage is being attached to a // machine. StatusAttaching Status = "attaching" // StatusDetaching indicates that the storage is attached to a machine. StatusAttached Status = "attached" // StatusDetaching indicates that the storage is being detached // from a machine. StatusDetaching Status = "detaching" // StatusDetached indicates that the storage is not attached to any // machine. StatusDetached Status = "detached" // StatusDestroying indicates that the storage is being destroyed. StatusDestroying Status = "destroying" )
Status values specific to storage.
func TranslateToLegacyAgentState ¶
func TranslateToLegacyAgentState(agentStatus, workloadStatus Status, workloadMessage string) (Status, bool)
TranslateLegacyAgentStatus returns the status value clients expect to see for agent-state in versions prior to 1.24
func (Status) KnownAgentStatus ¶
KnownAgentStatus returns true if status has a known value for an agent. It includes every status that has ever been valid for a unit or machine agent. This is used by the apiserver client facade to filter out unknown values.
func (Status) KnownWorkloadStatus ¶
KnownWorkloadStatus returns true if status has a known value for a workload. It includes every status that has ever been valid for a unit agent. This is used by the apiserver client facade to filter out unknown values.
func (Status) Matches ¶
Matches returns true if the candidate matches status, taking into account that the candidate may be a legacy status value which has been deprecated.
func (Status) WorkloadMatches ¶
WorkloadMatches returns true if the candidate matches status, taking into account that the candidate may be a legacy status value which has been deprecated.
type StatusGetter ¶
type StatusGetter interface {
Status() (StatusInfo, error)
}
StatusGetter represents a type whose status can be read.
type StatusHistoryGetter ¶
type StatusHistoryGetter interface {
StatusHistory(size int) ([]StatusInfo, error)
}
StatusHistoryGetter instances can fetch their status history.
type StatusInfo ¶
type StatusInfo struct { Status Status Message string Data map[string]interface{} Since *time.Time }
StatusInfo holds a Status and associated information.
type StatusSetter ¶
type StatusSetter interface {
SetStatus(status Status, info string, data map[string]interface{}) error
}
StatusSetter represents a type whose status can be set.
type StorageAttachment ¶
type StorageAttachment interface { // StorageInstance returns the tag of the corresponding storage // instance. StorageInstance() names.StorageTag // Unit returns the tag of the corresponding unit. Unit() names.UnitTag // Life reports whether the storage attachment is Alive, Dying or Dead. Life() Life }
StorageAttachment represents the state of a unit's attachment to a storage instance. A non-shared storage instance will have a single attachment for the storage instance's owning unit, whereas a shared storage instance will have an attachment for each unit of the service owning the storage instance.
type StorageConstraints ¶
type StorageConstraints struct { // Pool is the name of the storage pool from which to provision the // storage instances. Pool string `bson:"pool"` // Size is the required size of the storage instances, in MiB. Size uint64 `bson:"size"` // Count is the required number of storage instances. Count uint64 `bson:"count"` }
StorageConstraints contains the user-specified constraints for provisioning storage instances for a service unit.
type StorageInstance ¶
type StorageInstance interface { Entity // StorageTag returns the tag for the storage instance. StorageTag() names.StorageTag // Kind returns the storage instance kind. Kind() StorageKind // Owner returns the tag of the service or unit that owns this storage // instance. Owner() names.Tag // StorageName returns the name of the storage, as defined in the charm // storage metadata. This does not uniquely identify storage instances, // but identifies the group that the instances belong to. StorageName() string // Life reports whether the storage instance is Alive, Dying or Dead. Life() Life // CharmURL returns the charm URL that this storage instance was created with. CharmURL() *charm.URL }
StorageInstance represents the state of a unit or service-wide storage instance in the environment.
type StorageKind ¶
type StorageKind int
StorageKind defines the type of a store: whether it is a block device or a filesystem.
const ( StorageKindUnknown StorageKind = iota StorageKindBlock StorageKindFilesystem )
type StringsWatcher ¶
StringsWatcher generates signals when something changes, returning the changes as a list of strings.
type Subnet ¶
type Subnet struct {
// contains filtered or unexported fields
}
func (*Subnet) AllocatableIPHigh ¶
AllocatableIPHigh returns the hightest allocatable IP address in the subnet.
func (*Subnet) AllocatableIPLow ¶
AllocatableIPLow returns the lowest allocatable IP address in the subnet
func (*Subnet) AvailabilityZone ¶
AvailabilityZone returns the availability zone of the subnet. If the subnet is not associated with an availability zone it will be the empty string.
func (*Subnet) EnsureDead ¶
EnsureDead sets the Life of the subnet to Dead, if it's Alive. It does nothing otherwise.
func (*Subnet) PickNewAddress ¶
PickNewAddress returns a new IPAddress that isn't in use for the subnet. The address starts with AddressStateUnknown, for later allocation. This will fail if the subnet is not alive.
func (*Subnet) ProviderId ¶
ProviderId returns the provider-specific id of the subnet.
func (*Subnet) Refresh ¶
Refresh refreshes the contents of the Subnet from the underlying state. It an error that satisfies errors.IsNotFound if the Subnet has been removed.
func (*Subnet) Remove ¶
Remove removes a dead subnet. If the subnet is not dead it returns an error. It also removes any IP addresses associated with the subnet.
func (*Subnet) SpaceName ¶
SpaceName returns the space the subnet is associated with. If the subnet is in the default space it will be the empty string.
type SubnetInfo ¶
type SubnetInfo struct { // ProviderId is a provider-specific network id. This may be empty. ProviderId string // CIDR of the network, in 123.45.67.89/24 format. CIDR string // VLANTag needs to be between 1 and 4094 for VLANs and 0 for normal // networks. It's defined by IEEE 802.1Q standard. VLANTag int // AllocatableIPHigh and Low describe the allocatable portion of the // subnet. The remainder, if any, is reserved by the provider. // Either both of these must be set or neither, if they're empty it // means that none of the subnet is allocatable. If present they must // be valid IP addresses within the subnet CIDR. AllocatableIPHigh string AllocatableIPLow string // AvailabilityZone describes which availability zone this subnet is in. It can // be empty if the provider does not support availability zones. AvailabilityZone string // SpaceName is the name of the space the subnet is associated with. It // can be empty if the subnet is in the default space. SpaceName string }
SubnetInfo describes a single subnet.
type Unit ¶
type Unit struct { presence.Presencer StatusHistoryGetter // contains filtered or unexported fields }
Unit represents the state of a service unit.
func (*Unit) ActionSpecs ¶
func (u *Unit) ActionSpecs() (ActionSpecsByName, error)
ActionSpecs gets the ActionSpec map for the Unit's charm.
func (*Unit) AddAction ¶
AddAction adds a new Action of type name and using arguments payload to this Unit, and returns its ID. Note that the use of spec.InsertDefaults mutates payload.
func (*Unit) AgentHistory ¶
func (u *Unit) AgentHistory() StatusHistoryGetter
AgentHistory returns an StatusHistoryGetter which can be used to query the status history of the unit's agent.
func (*Unit) AgentPresence ¶
AgentPresence returns whether the respective remote agent is alive.
func (*Unit) AgentStatus ¶
func (u *Unit) AgentStatus() (StatusInfo, error)
AgentStatus calls Status for this unit's agent, this call is equivalent to the former call to Status when Agent and Unit where not separate entities.
func (*Unit) AgentTools ¶
AgentTools returns the tools that the agent is currently running. It an error that satisfies errors.IsNotFound if the tools have not yet been set.
func (*Unit) AssignToCleanEmptyMachine ¶
AssignToCleanEmptyMachine 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) AvailabilityZone ¶
AvailabilityZone returns the name of the availability zone into which the unit's machine instance was provisioned.
func (*Unit) CancelAction ¶
CancelAction removes a pending Action from the queue for this ActionReceiver and marks it as cancelled.
func (*Unit) ClearResolved ¶
ClearResolved removes any resolved setting on the unit.
func (*Unit) ClosePorts ¶
ClosePorts closes the given port range and protocol for the unit.
func (*Unit) CompletedActions ¶
CompletedActions returns a list of actions that have finished for this unit.
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) Constraints ¶
func (u *Unit) Constraints() (*constraints.Value, error)
Constraints returns the unit's deployment constraints.
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; otherwise, if it has storage instances, it will return ErrUnitHasStorageInstances.
func (*Unit) GetMeterStatus ¶
func (u *Unit) GetMeterStatus() (MeterStatus, error)
GetMeterStatus returns the meter status for the unit.
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) OpenPorts ¶
OpenPorts opens the given port range and protocol for the unit, if it does not conflict with another already opened range on the unit's assigned machine.
func (*Unit) OpenedPorts ¶
OpenedPorts returns a slice containing the open port ranges of the unit.
func (*Unit) PasswordValid ¶
PasswordValid returns whether the given password is valid for the given unit.
func (*Unit) PendingActions ¶
PendingActions returns a list of actions pending for this 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.
func (*Unit) PublicAddress ¶
PublicAddress returns the public address of the unit.
func (*Unit) Refresh ¶
Refresh refreshes the contents of the Unit from the underlying state. It an error that satisfies errors.IsNotFound if the unit has been removed.
func (*Unit) RelationsInScope ¶
RelationsInScope returns the relations for which the unit has entered scope and not left it.
func (*Unit) RelationsJoined ¶
RelationsJoined returns the relations for which the unit has entered scope and neither left it nor prepared to leave it
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) RunningActions ¶
RunningActions returns a list of actions running on this unit.
func (*Unit) ServiceName ¶
ServiceName returns the service name.
func (*Unit) SetAgentPresence ¶
SetAgentPresence signals that the agent for unit u is alive. It returns the started pinger.
func (*Unit) SetAgentStatus ¶
SetAgentStatus calls SetStatus for this unit's agent, this call is equivalent to the former call to SetStatus when Agent and Unit where not separate entities.
func (*Unit) SetAgentVersion ¶
SetAgentVersion sets the version of juju that the agent is currently running.
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) SetMeterStatus ¶
SetMeterStatus sets the meter status for the unit.
func (*Unit) SetPassword ¶
SetPassword sets the password for the machine's agent.
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 agent. The optional values allow to pass additional helpful status data. This method relies on globalKey instead of globalAgentKey since it is part of the effort to separate Unit from UnitAgent. Now the SetStatus for UnitAgent is in the UnitAgent struct.
func (*Unit) Status ¶
func (u *Unit) Status() (StatusInfo, error)
Status returns the status of the unit. This method relies on globalKey instead of globalAgentKey since it is part of the effort to separate Unit from UnitAgent. Now the Status for UnitAgent is in the UnitAgent struct.
func (*Unit) StatusHistory ¶
func (u *Unit) StatusHistory(size int) ([]StatusInfo, error)
StatusHistory returns a slice of at most <size> StatusInfo items representing past statuses for this unit.
func (*Unit) StorageConstraints ¶
func (u *Unit) StorageConstraints() (map[string]StorageConstraints, error)
StorageConstraints returns the unit's storage constraints.
func (*Unit) SubordinateNames ¶
SubordinateNames returns the names of any subordinate units.
func (*Unit) Tag ¶
Tag returns a name identifying the unit. 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) UnitTag ¶
UnitTag returns a names.UnitTag representing this Unit, unless the unit Name is invalid, in which case it will panic
func (*Unit) WaitAgentPresence ¶
WaitAgentPresence 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) WatchActionNotifications ¶
func (u *Unit) WatchActionNotifications() StringsWatcher
WatchActionNotifications starts and returns a StringsWatcher that notifies when actions with Id prefixes matching this Unit are added
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) WatchMeterStatus ¶
func (u *Unit) WatchMeterStatus() NotifyWatcher
WatchMeterStatus returns a watcher observing changes that affect the meter status of a unit.
func (*Unit) WatchSubordinateUnits ¶
func (u *Unit) WatchSubordinateUnits() StringsWatcher
WatchSubordinateUnits returns a StringsWatcher tracking the unit's subordinate units.
type UnitAgent ¶
type UnitAgent struct { StatusHistoryGetter // contains filtered or unexported fields }
UnitAgent represents the state of a service's unit agent.
func (*UnitAgent) SetStatus ¶
SetStatus sets the status of the unit agent. The optional values allow to pass additional helpful status data.
func (*UnitAgent) Status ¶
func (u *UnitAgent) Status() (StatusInfo, error)
Status returns the status of the unit agent.
func (*UnitAgent) StatusHistory ¶
func (u *UnitAgent) StatusHistory(size int) ([]StatusInfo, error)
StatusHistory returns a slice of at most <size> StatusInfo items representing past statuses for this agent.
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 UpgradeInfo ¶
type UpgradeInfo struct {
// contains filtered or unexported fields
}
UpgradeInfo is used to synchronise state server upgrades.
func (*UpgradeInfo) Abort ¶
func (info *UpgradeInfo) Abort() error
Abort marks the current upgrade as aborted. It should be called if the upgrade can't be completed for some reason.
func (*UpgradeInfo) AllProvisionedStateServersReady ¶
func (info *UpgradeInfo) AllProvisionedStateServersReady() (bool, error)
AllProvisionedStateServersReady returns true if and only if all state servers that have been started by the provisioner have called EnsureUpgradeInfo with matching versions.
When this returns true the master state state server can begin it's own upgrade.
func (*UpgradeInfo) PreviousVersion ¶
func (info *UpgradeInfo) PreviousVersion() version.Number
PreviousVersion returns the version being upgraded from.
func (*UpgradeInfo) Refresh ¶
func (info *UpgradeInfo) Refresh() error
Refresh updates the contents of the UpgradeInfo from underlying state.
func (*UpgradeInfo) SetStateServerDone ¶
func (info *UpgradeInfo) SetStateServerDone(machineId string) error
SetStateServerDone marks the supplied state machineId as having completed its upgrades. When SetStateServerDone is called by the last provisioned state server, the current upgrade info document will be archived with a status of UpgradeComplete.
func (*UpgradeInfo) SetStatus ¶
func (info *UpgradeInfo) SetStatus(status UpgradeStatus) error
SetStatus sets the status of the current upgrade. Checks are made to ensure that status changes are performed in the correct order.
func (*UpgradeInfo) Started ¶
func (info *UpgradeInfo) Started() time.Time
Started returns the time at which the upgrade was started.
func (*UpgradeInfo) StateServersDone ¶
func (info *UpgradeInfo) StateServersDone() []string
StateServersDone returns the machine ids for state servers that have completed their upgrades.
func (*UpgradeInfo) StateServersReady ¶
func (info *UpgradeInfo) StateServersReady() []string
StateServersReady returns the machine ids for state servers that have signalled that they are ready for upgrade.
func (*UpgradeInfo) Status ¶
func (info *UpgradeInfo) Status() UpgradeStatus
Status returns the status of the upgrade.
func (*UpgradeInfo) TargetVersion ¶
func (info *UpgradeInfo) TargetVersion() version.Number
TargetVersion returns the version being upgraded to.
func (*UpgradeInfo) Watch ¶
func (info *UpgradeInfo) Watch() NotifyWatcher
Watcher returns a watcher for the state underlying the current UpgradeInfo instance. This is provided purely for convenience.
type UpgradeStatus ¶
type UpgradeStatus string
UpgradeStatus describes the states an upgrade operation may be in.
const ( // UpgradePending indicates that an upgrade is queued but not yet started. UpgradePending UpgradeStatus = "pending" // UpgradeRunning indicates that the master state server has started // running upgrade logic, and other state servers are waiting for it. UpgradeRunning UpgradeStatus = "running" // UpgradeFinishing indicates that the master state server has finished // running upgrade logic, and other state servers are catching up. UpgradeFinishing UpgradeStatus = "finishing" // UpgradeComplete indicates that all state servers have finished running // upgrade logic. UpgradeComplete UpgradeStatus = "complete" // UpgradeAborted indicates that the upgrade wasn't completed due // to some problem. UpgradeAborted UpgradeStatus = "aborted" )
type User ¶
type User struct {
// contains filtered or unexported fields
}
User represents a local user in the database.
func (*User) DateCreated ¶
DateCreated returns when this User was created in UTC.
func (*User) DisplayName ¶
DisplayName returns the display name of the User.
func (*User) IsDisabled ¶
IsDisabled returns whether the user is currently enabled.
func (*User) LastLogin ¶
LastLogin returns when this User last connected through the API in UTC. The resulting time will be nil if the user has never logged in. In the normal case, the LastLogin is the last time that the user connected through the API server.
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 stores the hash and the salt of the password.
func (*User) UpdateLastLogin ¶
UpdateLastLogin sets the LastLogin time of the user to be now (to the nearest second).
type UserEnvironment ¶
type UserEnvironment struct { *Environment User names.UserTag }
UserEnvironment contains information about an environment that a user has access to.
func (*UserEnvironment) LastConnection ¶
func (e *UserEnvironment) LastConnection() (time.Time, error)
LastConnection returns the last time the user has connected to the environment.
type ValidateConfigFunc ¶
type Volume ¶
type Volume interface { GlobalEntity LifeBinder StatusGetter StatusSetter // VolumeTag returns the tag for the volume. VolumeTag() names.VolumeTag // StorageInstance returns the tag of the storage instance that this // volume is assigned to, if any. If the volume is not assigned to // a storage instance, an error satisfying errors.IsNotAssigned will // be returned. // // A volume can be assigned to at most one storage instance, and a // storage instance can have at most one associated volume. StorageInstance() (names.StorageTag, error) // Info returns the volume's VolumeInfo, or a NotProvisioned // error if the volume has not yet been provisioned. Info() (VolumeInfo, error) // Params returns the parameters for provisioning the volume, // if it has not already been provisioned. Params returns true if the // returned parameters are usable for provisioning, otherwise false. Params() (VolumeParams, bool) }
Volume describes a volume (disk, logical volume, etc.) in the environment.
type VolumeAttachment ¶
type VolumeAttachment interface { Lifer // Volume returns the tag of the related Volume. Volume() names.VolumeTag // Machine returns the tag of the related Machine. Machine() names.MachineTag // Info returns the volume attachment's VolumeAttachmentInfo, or a // NotProvisioned error if the attachment has not yet been made. // // TODO(axw) use a different error, rather than NotProvisioned // (say, NotAttached or NotAssociated). Info() (VolumeAttachmentInfo, error) // Params returns the parameters for creating the volume attachment, // if it has not already been made. Params returns true if the returned // parameters are usable for creating an attachment, otherwise false. Params() (VolumeAttachmentParams, bool) }
VolumeAttachment describes an attachment of a volume to a machine.
type VolumeAttachmentInfo ¶
type VolumeAttachmentInfo struct { DeviceName string `bson:"devicename,omitempty"` DeviceLink string `bson:"devicelink,omitempty"` BusAddress string `bson:"busaddress,omitempty"` ReadOnly bool `bson:"read-only"` }
VolumeAttachmentInfo describes information about a volume attachment.
type VolumeAttachmentParams ¶
type VolumeAttachmentParams struct {
ReadOnly bool `bson:"read-only"`
}
VolumeAttachmentParams records parameters for attaching a volume to a machine.
type VolumeInfo ¶
type VolumeInfo struct { HardwareId string `bson:"hardwareid,omitempty"` Size uint64 `bson:"size"` Pool string `bson:"pool"` VolumeId string `bson:"volumeid"` Persistent bool `bson:"persistent"` }
VolumeInfo describes information about a volume.
type VolumeParams ¶
type VolumeParams struct { Pool string `bson:"pool"` Size uint64 `bson:"size"` // contains filtered or unexported fields }
VolumeParams records parameters for provisioning a new volume.
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 ¶
- action.go
- addmachine.go
- address.go
- allcollections.go
- allwatcher.go
- annotations.go
- block.go
- blockdevices.go
- charm.go
- cleanup.go
- clock.go
- collection.go
- constraints.go
- container.go
- database.go
- distribution.go
- endpoint.go
- environ.go
- envuser.go
- errors.go
- filesystem.go
- images.go
- interface.go
- ipaddresses.go
- leadership.go
- life.go
- logs.go
- machine.go
- meterstatus.go
- metrics.go
- metricsmanager.go
- minimumunits.go
- mongo.go
- multienv.go
- multiwatcher.go
- networkinterfaces.go
- networks.go
- open.go
- policy.go
- pool.go
- ports.go
- reboot.go
- relation.go
- relationunit.go
- requestednetworks.go
- restore.go
- sequence.go
- service.go
- settings.go
- spaces.go
- state.go
- status.go
- status_model.go
- storage.go
- subnets.go
- tools.go
- txns.go
- unit.go
- unitagent.go
- upgrade.go
- upgrades.go
- user.go
- volume.go
- watcher.go
Directories ¶
Path | Synopsis |
---|---|
Package backups contains all the stand-alone backup-related functionality for juju state.
|
Package backups contains all the stand-alone backup-related functionality for juju state. |
The lease package exists to implement distributed lease management on top of mgo/txn, and to expose assert operations that allow us to gate other mgo/txn transactions on lease state.
|
The lease package exists to implement distributed lease management on top of mgo/txn, and to expose assert operations that allow us to gate other mgo/txn transactions on lease state. |
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. |