Documentation ¶
Index ¶
- Variables
- func IsBadActionError(err error) bool
- func IsMissingHookError(err error) bool
- func NewBadActionError(actionName, problem string) error
- func NewMissingHookError(hookName string) error
- type ActionData
- type CommandInfo
- type Context
- type ContextRelation
- func (ctx *ContextRelation) FakeId() string
- func (ctx *ContextRelation) Id() int
- func (ctx *ContextRelation) Name() string
- func (ctx *ContextRelation) ReadSettings(unit string) (settings params.Settings, err error)
- func (ctx *ContextRelation) Settings() (jujuc.Settings, error)
- func (ctx *ContextRelation) UnitNames() []string
- func (ctx *ContextRelation) WriteSettings() (err error)
- type Factory
- type HookContext
- func (c *HookContext) ActionData() (*ActionData, error)
- func (ctx *HookContext) ActionName() (string, error)
- func (ctx *HookContext) ActionParams() (map[string]interface{}, error)
- func (ctx *HookContext) AddMetric(key, value string, created time.Time) error
- func (ctx *HookContext) AvailabilityZone() (string, bool)
- func (ctx *HookContext) ClosePorts(protocol string, fromPort, toPort int) error
- func (ctx *HookContext) ConfigSettings() (charm.Settings, error)
- func (ctx *HookContext) FlushContext(process string, ctxErr error) (err error)
- func (ctx *HookContext) GetProcess() *os.Process
- func (ctx *HookContext) GetRebootPriority() jujuc.RebootPriority
- func (ctx *HookContext) HookRelation() (jujuc.ContextRelation, bool)
- func (ctx *HookContext) HookStorageInstance() (*storage.StorageInstance, bool)
- func (context *HookContext) HookVars(paths Paths) []string
- func (ctx *HookContext) Id() string
- func (ctx *HookContext) OpenPorts(protocol string, fromPort, toPort int) error
- func (ctx *HookContext) OpenedPorts() []network.PortRange
- func (ctx *HookContext) OwnerTag() string
- func (ctx *HookContext) PrivateAddress() (string, bool)
- func (ctx *HookContext) PublicAddress() (string, bool)
- func (ctx *HookContext) Relation(id int) (jujuc.ContextRelation, bool)
- func (ctx *HookContext) RelationIds() []int
- func (ctx *HookContext) RemoteUnitName() (string, bool)
- func (ctx *HookContext) RequestReboot(priority jujuc.RebootPriority) error
- func (ctx *HookContext) SetActionFailed() error
- func (ctx *HookContext) SetActionMessage(message string) error
- func (ctx *HookContext) SetProcess(process *os.Process)
- func (ctx *HookContext) SetRebootPriority(priority jujuc.RebootPriority)
- func (ctx *HookContext) StorageInstance(storageId string) (*storage.StorageInstance, bool)
- func (ctx *HookContext) UnitName() string
- func (ctx *HookContext) UpdateActionResults(keys []string, value string) error
- type Paths
- type PortRange
- type PortRangeInfo
- type RelationCache
- func (cache *RelationCache) InvalidateMember(memberName string)
- func (cache *RelationCache) MemberNames() (memberNames []string)
- func (cache *RelationCache) Prune(memberNames []string)
- func (cache *RelationCache) RemoveMember(memberName string)
- func (cache *RelationCache) Settings(unitName string) (params.Settings, error)
- type RelationInfo
- type RelationsFunc
- type Runner
- type SettingsFunc
- type SettingsMap
Constants ¶
This section is empty.
Variables ¶
var ErrActionNotAvailable = errors.New("action no longer available")
var ErrNoProcess = errors.New("no process to kill")
var ErrReboot = errors.New("reboot after hook")
var ErrRequeueAndReboot = errors.New("reboot now")
Functions ¶
func IsBadActionError ¶
func IsMissingHookError ¶
func NewBadActionError ¶
func NewMissingHookError ¶
Types ¶
type ActionData ¶
type ActionData struct { ActionName string ActionTag names.ActionTag ActionParams map[string]interface{} ActionFailed bool ResultsMessage string ResultsMap map[string]interface{} }
ActionData contains the tag, parameters, and results of an Action.
type CommandInfo ¶
type Context ¶
type Context interface { jujuc.Context Id() string HookVars(paths Paths) []string ActionData() (*ActionData, error) SetProcess(process *os.Process) FlushContext(badge string, failure error) error }
Context exposes jujuc.Context, and additional methods needed by Runner.
type ContextRelation ¶
type ContextRelation struct {
// contains filtered or unexported fields
}
ContextRelation is the implementation of jujuc.ContextRelation.
func NewContextRelation ¶
func NewContextRelation(ru *uniter.RelationUnit, cache *RelationCache) *ContextRelation
NewContextRelation creates a new context for the given relation unit. The unit-name keys of members supplies the initial membership.
func (*ContextRelation) FakeId ¶
func (ctx *ContextRelation) FakeId() string
func (*ContextRelation) Id ¶
func (ctx *ContextRelation) Id() int
func (*ContextRelation) Name ¶
func (ctx *ContextRelation) Name() string
func (*ContextRelation) ReadSettings ¶
func (ctx *ContextRelation) ReadSettings(unit string) (settings params.Settings, err error)
func (*ContextRelation) UnitNames ¶
func (ctx *ContextRelation) UnitNames() []string
func (*ContextRelation) WriteSettings ¶
func (ctx *ContextRelation) WriteSettings() (err error)
WriteSettings persists all changes made to the unit's relation settings.
type Factory ¶
type Factory interface { // NewCommandRunner returns an execution context suitable for running // an arbitrary script. NewCommandRunner(commandInfo CommandInfo) (Runner, error) // NewHookRunner returns an execution context suitable for running the // supplied hook definition (which must be valid). NewHookRunner(hookInfo hook.Info) (Runner, error) // NewActionRunner returns an execution context suitable for running the // action identified by the supplied id. NewActionRunner(actionId string) (Runner, error) }
Factory represents a long-lived object that can create execution contexts relevant to a specific unit. In its current state, it is somewhat bizarre and inconsistent; its main value is as an evolutionary step towards a better division of responsibilities across worker/uniter and its subpackages.
func NewFactory ¶
func NewFactory( state *uniter.State, unitTag names.UnitTag, getRelationInfos RelationsFunc, paths Paths, ) ( Factory, error, )
NewFactory returns a Factory capable of creating execution contexts backed by the supplied unit's supplied API connection.
type HookContext ¶
type HookContext struct {
// contains filtered or unexported fields
}
HookContext is the implementation of jujuc.Context.
func (*HookContext) ActionData ¶
func (c *HookContext) ActionData() (*ActionData, error)
ActionData returns the context's internal action data. It's meant to be transitory; it exists to allow uniter and runner code to keep working as it did; it should be considered deprecated, and not used by new clients.
func (*HookContext) ActionName ¶
func (ctx *HookContext) ActionName() (string, error)
ActionName returns the name of the action.
func (*HookContext) ActionParams ¶
func (ctx *HookContext) ActionParams() (map[string]interface{}, error)
ActionParams simply returns the arguments to the Action.
func (*HookContext) AddMetric ¶
func (ctx *HookContext) AddMetric(key, value string, created time.Time) error
AddMetrics adds metrics to the hook context.
func (*HookContext) AvailabilityZone ¶
func (ctx *HookContext) AvailabilityZone() (string, bool)
func (*HookContext) ClosePorts ¶
func (ctx *HookContext) ClosePorts(protocol string, fromPort, toPort int) error
func (*HookContext) ConfigSettings ¶
func (ctx *HookContext) ConfigSettings() (charm.Settings, error)
func (*HookContext) FlushContext ¶
func (ctx *HookContext) FlushContext(process string, ctxErr error) (err error)
func (*HookContext) GetProcess ¶
func (ctx *HookContext) GetProcess() *os.Process
func (*HookContext) GetRebootPriority ¶
func (ctx *HookContext) GetRebootPriority() jujuc.RebootPriority
func (*HookContext) HookRelation ¶
func (ctx *HookContext) HookRelation() (jujuc.ContextRelation, bool)
func (*HookContext) HookStorageInstance ¶
func (ctx *HookContext) HookStorageInstance() (*storage.StorageInstance, bool)
func (*HookContext) HookVars ¶
func (context *HookContext) HookVars(paths Paths) []string
HookVars returns an os.Environ-style list of strings necessary to run a hook such that it can know what environment it's operating in, and can call back into context.
func (*HookContext) Id ¶
func (ctx *HookContext) Id() string
func (*HookContext) OpenPorts ¶
func (ctx *HookContext) OpenPorts(protocol string, fromPort, toPort int) error
func (*HookContext) OpenedPorts ¶
func (ctx *HookContext) OpenedPorts() []network.PortRange
func (*HookContext) OwnerTag ¶
func (ctx *HookContext) OwnerTag() string
func (*HookContext) PrivateAddress ¶
func (ctx *HookContext) PrivateAddress() (string, bool)
func (*HookContext) PublicAddress ¶
func (ctx *HookContext) PublicAddress() (string, bool)
func (*HookContext) Relation ¶
func (ctx *HookContext) Relation(id int) (jujuc.ContextRelation, bool)
func (*HookContext) RelationIds ¶
func (ctx *HookContext) RelationIds() []int
func (*HookContext) RemoteUnitName ¶
func (ctx *HookContext) RemoteUnitName() (string, bool)
func (*HookContext) RequestReboot ¶
func (ctx *HookContext) RequestReboot(priority jujuc.RebootPriority) error
func (*HookContext) SetActionFailed ¶
func (ctx *HookContext) SetActionFailed() error
SetActionFailed sets the fail state of the action.
func (*HookContext) SetActionMessage ¶
func (ctx *HookContext) SetActionMessage(message string) error
SetActionMessage sets a message for the Action, usually an error message.
func (*HookContext) SetProcess ¶
func (ctx *HookContext) SetProcess(process *os.Process)
func (*HookContext) SetRebootPriority ¶
func (ctx *HookContext) SetRebootPriority(priority jujuc.RebootPriority)
func (*HookContext) StorageInstance ¶
func (ctx *HookContext) StorageInstance(storageId string) (*storage.StorageInstance, bool)
func (*HookContext) UnitName ¶
func (ctx *HookContext) UnitName() string
func (*HookContext) UpdateActionResults ¶
func (ctx *HookContext) UpdateActionResults(keys []string, value string) error
UpdateActionResults inserts new values for use with action-set and action-fail. The results struct will be delivered to the state server upon completion of the Action. It returns an error if not called on an Action-containing HookContext.
type Paths ¶
type Paths interface { // GetToolsDir returns the filesystem path to the dirctory containing // the hook tool symlinks. GetToolsDir() string // GetCharmDir returns the filesystem path to the directory in which // the charm is installed. GetCharmDir() string // GetJujucSocket returns the path to the socket used by the hook tools // to communicate back to the executing uniter process. It might be a // filesystem path, or it might be abstract. GetJujucSocket() string }
Paths exposes the paths needed by Runner.
type PortRange ¶
PortRange contains a port range and a relation id. Used as key to pendingRelations and is only exported for testing.
type PortRangeInfo ¶
type PortRangeInfo struct { ShouldOpen bool RelationTag names.RelationTag }
PortRangeInfo contains information about a pending open- or close-port operation for a port range. This is only exported for testing.
type RelationCache ¶
type RelationCache struct {
// contains filtered or unexported fields
}
RelationCache stores a relation's remote unit membership and settings. Member settings are stored until invalidated or removed by name; settings of non-member units are stored only until the cache is pruned.
func NewRelationCache ¶
func NewRelationCache(readSettings SettingsFunc, memberNames []string) *RelationCache
NewRelationCache creates a new RelationCache that will use the supplied SettingsFunc to populate itself on demand. Initial membership is determined by memberNames.
func (*RelationCache) InvalidateMember ¶
func (cache *RelationCache) InvalidateMember(memberName string)
InvalidateMember ensures that the named remote unit will be considered a member of the relation, and that the next attempt to read its settings will use fresh data.
func (*RelationCache) MemberNames ¶
func (cache *RelationCache) MemberNames() (memberNames []string)
MemberNames returns the names of the remote units present in the relation.
func (*RelationCache) Prune ¶
func (cache *RelationCache) Prune(memberNames []string)
Prune resets the membership to the supplied list, and discards the settings of all non-member units.
func (*RelationCache) RemoveMember ¶
func (cache *RelationCache) RemoveMember(memberName string)
RemoveMember ensures that the named remote unit will not be considered a member of the relation,
type RelationInfo ¶
type RelationInfo struct { RelationUnit *uniter.RelationUnit MemberNames []string }
type RelationsFunc ¶
type RelationsFunc func() map[int]*RelationInfo
RelationsFunc is used to get snapshots of relation membership at context creation time.
type Runner ¶
type Runner interface { // Context returns the context against which the runner executes. Context() Context // RunHook executes the hook with the supplied name. RunHook(name string) error // RunAction executes the action with the supplied name. RunAction(name string) error // RunCommands executes the supplied script. RunCommands(commands string) (*utilexec.ExecResponse, error) }
Runner is reponsible for invoking commands in a context.
type SettingsFunc ¶
SettingsFunc returns the relation settings for a unit.
type SettingsMap ¶
SettingsMap is a map from unit name to relation settings.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
The worker/uniter/runner/jujuc package implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state.
|
The worker/uniter/runner/jujuc package implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state. |