Documentation
¶
Overview ¶
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.
Index ¶
- func CommandNames() (names []string)
- func EnsureSymlinks(dir string) (err error)
- func NewActionFailCommand(ctx Context) cmd.Command
- func NewActionGetCommand(ctx Context) cmd.Command
- func NewActionSetCommand(ctx Context) cmd.Command
- func NewAddMetricCommand(ctx Context) cmd.Command
- func NewClosePortCommand(ctx Context) cmd.Command
- func NewCommand(ctx Context, name string) (cmd.Command, error)
- func NewConfigGetCommand(ctx Context) cmd.Command
- func NewJujuLogCommand(ctx Context) cmd.Command
- func NewJujuRebootCommand(ctx Context) cmd.Command
- func NewOpenPortCommand(ctx Context) cmd.Command
- func NewOpenedPortsCommand(ctx Context) cmd.Command
- func NewOwnerGetCommand(ctx Context) cmd.Command
- func NewRelationGetCommand(ctx Context) cmd.Command
- func NewRelationIdsCommand(ctx Context) cmd.Command
- func NewRelationListCommand(ctx Context) cmd.Command
- func NewRelationSetCommand(ctx Context) cmd.Command
- func NewStorageGetCommand(ctx Context) cmd.Command
- func NewUnitGetCommand(ctx Context) cmd.Command
- type ActionFailCommand
- type ActionGetCommand
- type ActionSetCommand
- type AddMetricCommand
- type CmdGetter
- type ConfigGetCommand
- type Context
- type ContextRelation
- type JujuLogCommand
- type JujuRebootCommand
- type Jujuc
- type Metric
- type OpenedPortsCommand
- type OwnerGetCommand
- type RebootPriority
- type RelationGetCommand
- type RelationIdsCommand
- type RelationListCommand
- type RelationSetCommand
- type Request
- type Server
- type Settings
- type StorageGetCommand
- type UnitGetCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandNames ¶
func CommandNames() (names []string)
CommandNames returns the names of all jujuc commands.
func EnsureSymlinks ¶
EnsureSymlinks creates a symbolic link to jujuc within dir for each hook command. If the commands already exist, this operation does nothing. If dir is a symbolic link, it will be dereferenced first.
func NewActionFailCommand ¶
NewActionFailCommand returns a new ActionFailCommand with the given context.
func NewActionGetCommand ¶
NewActionGetCommand returns an ActionGetCommand for use with the given context.
func NewActionSetCommand ¶
NewActionSetCommand returns a new ActionSetCommand with the given context.
func NewAddMetricCommand ¶
NewAddMetricCommand generates a new AddMetricCommand.
func NewClosePortCommand ¶
func NewCommand ¶
NewCommand returns an instance of the named Command, initialized to execute against the supplied Context.
func NewConfigGetCommand ¶
func NewJujuLogCommand ¶
func NewJujuRebootCommand ¶
func NewOpenPortCommand ¶
func NewOpenedPortsCommand ¶
func NewOwnerGetCommand ¶
func NewRelationGetCommand ¶
func NewRelationIdsCommand ¶
func NewRelationListCommand ¶
func NewRelationSetCommand ¶
func NewStorageGetCommand ¶
func NewUnitGetCommand ¶
Types ¶
type ActionFailCommand ¶
type ActionFailCommand struct { cmd.CommandBase // contains filtered or unexported fields }
ActionFailCommand implements the action-fail command.
func (*ActionFailCommand) Info ¶
func (c *ActionFailCommand) Info() *cmd.Info
Info returns the content for --help.
func (*ActionFailCommand) Init ¶
func (c *ActionFailCommand) Init(args []string) error
Init sets the fail message and checks for malformed invocations.
func (*ActionFailCommand) Run ¶
func (c *ActionFailCommand) Run(ctx *cmd.Context) error
Run sets the Action's fail state.
func (*ActionFailCommand) SetFlags ¶
func (c *ActionFailCommand) SetFlags(f *gnuflag.FlagSet)
SetFlags handles any option flags, but there are none.
type ActionGetCommand ¶
type ActionGetCommand struct { cmd.CommandBase // contains filtered or unexported fields }
ActionGetCommand implements the action-get command.
func (*ActionGetCommand) Info ¶
func (c *ActionGetCommand) Info() *cmd.Info
Info returns the content for --help.
func (*ActionGetCommand) Init ¶
func (c *ActionGetCommand) Init(args []string) error
Init makes sure there are no additional unknown arguments to action-get.
func (*ActionGetCommand) Run ¶
func (c *ActionGetCommand) Run(ctx *cmd.Context) error
Run recurses into the params map for the Action, given the list of keys into the map, and returns either the keyed value, or nothing. In the case of an empty keys list, the entire params map will be returned.
func (*ActionGetCommand) SetFlags ¶
func (c *ActionGetCommand) SetFlags(f *gnuflag.FlagSet)
SetFlags handles known option flags; in this case, [--output={json|yaml}] and --help.
type ActionSetCommand ¶
type ActionSetCommand struct { cmd.CommandBase // contains filtered or unexported fields }
ActionSetCommand implements the action-set command.
func (*ActionSetCommand) Info ¶
func (c *ActionSetCommand) Info() *cmd.Info
Info returns the content for --help.
func (*ActionSetCommand) Init ¶
func (c *ActionSetCommand) Init(args []string) error
Init accepts maps in the form of key=value, key.key2.keyN....=value
func (*ActionSetCommand) Run ¶
func (c *ActionSetCommand) Run(ctx *cmd.Context) error
Run adds the given <key list>/<value> pairs, such as foo.bar=baz to the existing map of results for the Action.
func (*ActionSetCommand) SetFlags ¶
func (c *ActionSetCommand) SetFlags(f *gnuflag.FlagSet)
SetFlags handles known option flags.
type AddMetricCommand ¶
type AddMetricCommand struct { cmd.CommandBase Metrics []Metric // contains filtered or unexported fields }
AddMetricCommand implements the add-metric command.
func (*AddMetricCommand) Info ¶
func (c *AddMetricCommand) Info() *cmd.Info
Info returns the command infor structure for the add-metric command.
func (*AddMetricCommand) Init ¶
func (c *AddMetricCommand) Init(args []string) error
Init parses the command's parameters.
type ConfigGetCommand ¶
type ConfigGetCommand struct { cmd.CommandBase Key string // The key to show. If empty, show all. All bool // contains filtered or unexported fields }
ConfigGetCommand implements the config-get command.
func (*ConfigGetCommand) Info ¶
func (c *ConfigGetCommand) Info() *cmd.Info
func (*ConfigGetCommand) Init ¶
func (c *ConfigGetCommand) Init(args []string) error
func (*ConfigGetCommand) SetFlags ¶
func (c *ConfigGetCommand) SetFlags(f *gnuflag.FlagSet)
type Context ¶
type Context interface { // Unit returns the executing unit's name. UnitName() string // PublicAddress returns the executing unit's public address. PublicAddress() (string, bool) // PrivateAddress returns the executing unit's private address. PrivateAddress() (string, bool) // AvailabilityZone returns the executing unit's availablilty zone. AvailabilityZone() (string, bool) // OpenPorst marks the supplied port range for opening when the // executing unit's service is exposed. OpenPorts(protocol string, fromPort, toPort int) error // ClosePorts ensures the supplied port range is closed even when // the executing unit's service is exposed (unless it is opened // separately by a co- located unit). ClosePorts(protocol string, fromPort, toPort int) error // OpenedPorts returns all port ranges currently opened by this // unit on its assigned machine. The result is sorted first by // protocol, then by number. OpenedPorts() []network.PortRange // Config returns the current service configuration of the executing unit. ConfigSettings() (charm.Settings, error) // ActionParams returns the map of params passed with an Action. ActionParams() (map[string]interface{}, error) // UpdateActionResults inserts new values for use with action-set. // The results struct will be delivered to the state server upon // completion of the Action. UpdateActionResults(keys []string, value string) error // SetActionMessage sets a message for the Action. SetActionMessage(string) error // SetActionFailed sets a failure state for the Action. SetActionFailed() error // HookRelation returns the ContextRelation associated with the executing // hook if it was found, and whether it was found. HookRelation() (ContextRelation, bool) // RemoteUnitName returns the name of the remote unit the hook execution // is associated with if it was found, and whether it was found. RemoteUnitName() (string, bool) // Relation returns the relation with the supplied id if it was found, and // whether it was found. Relation(id int) (ContextRelation, bool) // RelationIds returns the ids of all relations the executing unit is // currently participating in. RelationIds() []int // OwnerTag returns the user tag of the service the executing // units belongs to. OwnerTag() string // AddMetric records a metric to return after hook execution. AddMetric(string, string, time.Time) error // RequestReboot will set the reboot flag to true on the machine agent RequestReboot(prio RebootPriority) error // StorageInstance returns the storage instance with the given id. StorageInstance(storageId string) (*storage.StorageInstance, bool) // HookStorageInstance returns the storage instance associated // the executing hook. HookStorageInstance() (*storage.StorageInstance, bool) }
Context is the interface that all hook helper commands depend on to interact with the rest of the system.
type ContextRelation ¶
type ContextRelation interface { // Id returns an integer which uniquely identifies the relation. Id() int // Name returns the name the locally executing charm assigned to this relation. Name() string // FakeId returns a string of the form "relation-name:123", which uniquely // identifies the relation to the hook. In reality, the identification // of the relation is the integer following the colon, but the composed // name is useful to humans observing it. FakeId() string // Settings allows read/write access to the local unit's settings in // this relation. Settings() (Settings, error) // UnitNames returns a list of the remote units in the relation. UnitNames() []string // ReadSettings returns the settings of any remote unit in the relation. ReadSettings(unit string) (params.Settings, error) }
ContextRelation expresses the capabilities of a hook with respect to a relation.
type JujuLogCommand ¶
type JujuLogCommand struct { cmd.CommandBase Message string Debug bool Level string // contains filtered or unexported fields }
JujuLogCommand implements the juju-log command.
func (*JujuLogCommand) Info ¶
func (c *JujuLogCommand) Info() *cmd.Info
func (*JujuLogCommand) Init ¶
func (c *JujuLogCommand) Init(args []string) error
func (*JujuLogCommand) SetFlags ¶
func (c *JujuLogCommand) SetFlags(f *gnuflag.FlagSet)
type JujuRebootCommand ¶
type JujuRebootCommand struct { cmd.CommandBase Now bool // contains filtered or unexported fields }
JujuRebootCommand implements the juju-reboot command.
func (*JujuRebootCommand) Info ¶
func (c *JujuRebootCommand) Info() *cmd.Info
func (*JujuRebootCommand) Init ¶
func (c *JujuRebootCommand) Init(args []string) error
func (*JujuRebootCommand) SetFlags ¶
func (c *JujuRebootCommand) SetFlags(f *gnuflag.FlagSet)
type Jujuc ¶
type Jujuc struct {
// contains filtered or unexported fields
}
Jujuc implements the jujuc command in the form required by net/rpc.
type OpenedPortsCommand ¶
type OpenedPortsCommand struct { cmd.CommandBase // contains filtered or unexported fields }
OpenedPortsCommand implements the opened-ports command.
func (*OpenedPortsCommand) Info ¶
func (c *OpenedPortsCommand) Info() *cmd.Info
func (*OpenedPortsCommand) Init ¶
func (c *OpenedPortsCommand) Init(args []string) error
func (*OpenedPortsCommand) SetFlags ¶
func (c *OpenedPortsCommand) SetFlags(f *gnuflag.FlagSet)
type OwnerGetCommand ¶
type OwnerGetCommand struct { cmd.CommandBase Key string // contains filtered or unexported fields }
OwnerGetCommand implements the owner-get command.
func (*OwnerGetCommand) Info ¶
func (c *OwnerGetCommand) Info() *cmd.Info
func (*OwnerGetCommand) Init ¶
func (c *OwnerGetCommand) Init(args []string) error
func (*OwnerGetCommand) SetFlags ¶
func (c *OwnerGetCommand) SetFlags(f *gnuflag.FlagSet)
type RebootPriority ¶
type RebootPriority int
const ( // noop RebootSkip RebootPriority = iota // wait for current hook to finish before rebooting RebootAfterHook // reboot immediately, killing and requeueing the calling hook RebootNow )
type RelationGetCommand ¶
type RelationGetCommand struct { cmd.CommandBase RelationId int Key string UnitName string // contains filtered or unexported fields }
RelationGetCommand implements the relation-get command.
func (*RelationGetCommand) Info ¶
func (c *RelationGetCommand) Info() *cmd.Info
func (*RelationGetCommand) Init ¶
func (c *RelationGetCommand) Init(args []string) error
func (*RelationGetCommand) SetFlags ¶
func (c *RelationGetCommand) SetFlags(f *gnuflag.FlagSet)
type RelationIdsCommand ¶
type RelationIdsCommand struct { cmd.CommandBase Name string // contains filtered or unexported fields }
RelationIdsCommand implements the relation-ids command.
func (*RelationIdsCommand) Info ¶
func (c *RelationIdsCommand) Info() *cmd.Info
func (*RelationIdsCommand) Init ¶
func (c *RelationIdsCommand) Init(args []string) error
func (*RelationIdsCommand) SetFlags ¶
func (c *RelationIdsCommand) SetFlags(f *gnuflag.FlagSet)
type RelationListCommand ¶
type RelationListCommand struct { cmd.CommandBase RelationId int // contains filtered or unexported fields }
RelationListCommand implements the relation-list command.
func (*RelationListCommand) Info ¶
func (c *RelationListCommand) Info() *cmd.Info
func (*RelationListCommand) Init ¶
func (c *RelationListCommand) Init(args []string) (err error)
func (*RelationListCommand) SetFlags ¶
func (c *RelationListCommand) SetFlags(f *gnuflag.FlagSet)
type RelationSetCommand ¶
type RelationSetCommand struct { cmd.CommandBase RelationId int Settings map[string]string // contains filtered or unexported fields }
RelationSetCommand implements the relation-set command.
func (*RelationSetCommand) Info ¶
func (c *RelationSetCommand) Info() *cmd.Info
func (*RelationSetCommand) Init ¶
func (c *RelationSetCommand) Init(args []string) error
func (*RelationSetCommand) SetFlags ¶
func (c *RelationSetCommand) SetFlags(f *gnuflag.FlagSet)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements a server that serves command invocations via a unix domain socket.
func NewServer ¶
NewServer creates an RPC server bound to socketPath, which can execute remote command invocations against an appropriate Context. It will not actually do so until Run is called.
type StorageGetCommand ¶
type StorageGetCommand struct { cmd.CommandBase // contains filtered or unexported fields }
StorageGetCommand implements the storage-get command.
func (*StorageGetCommand) Info ¶
func (c *StorageGetCommand) Info() *cmd.Info
func (*StorageGetCommand) Init ¶
func (c *StorageGetCommand) Init(args []string) error
func (*StorageGetCommand) SetFlags ¶
func (c *StorageGetCommand) SetFlags(f *gnuflag.FlagSet)
type UnitGetCommand ¶
type UnitGetCommand struct { cmd.CommandBase Key string // contains filtered or unexported fields }
UnitGetCommand implements the unit-get command.
func (*UnitGetCommand) Info ¶
func (c *UnitGetCommand) Info() *cmd.Info
func (*UnitGetCommand) Init ¶
func (c *UnitGetCommand) Init(args []string) error
func (*UnitGetCommand) SetFlags ¶
func (c *UnitGetCommand) SetFlags(f *gnuflag.FlagSet)