jujuc

package
v0.0.0-...-6337964 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2014 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

The worker/uniter/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

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 NewClosePortCommand

func NewClosePortCommand(ctx Context) cmd.Command

func NewCommand

func NewCommand(ctx Context, name string) (cmd.Command, error)

NewCommand returns an instance of the named Command, initialized to execute against the supplied Context.

func NewConfigGetCommand

func NewConfigGetCommand(ctx Context) cmd.Command

func NewJujuLogCommand

func NewJujuLogCommand(ctx Context) cmd.Command

func NewOpenPortCommand

func NewOpenPortCommand(ctx Context) cmd.Command

func NewOwnerGetCommand

func NewOwnerGetCommand(ctx Context) cmd.Command

func NewRelationGetCommand

func NewRelationGetCommand(ctx Context) cmd.Command

func NewRelationIdsCommand

func NewRelationIdsCommand(ctx Context) cmd.Command

func NewRelationListCommand

func NewRelationListCommand(ctx Context) cmd.Command

func NewRelationSetCommand

func NewRelationSetCommand(ctx Context) cmd.Command

func NewUnitGetCommand

func NewUnitGetCommand(ctx Context) cmd.Command

Types

type CmdGetter

type CmdGetter func(contextId, cmdName string) (cmd.Command, error)

CmdGetter looks up a Command implementation connected to a particular Context.

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) Run

func (c *ConfigGetCommand) Run(ctx *cmd.Context) 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)

	// OpenPort marks the supplied port for opening when the executing unit's
	// service is exposed.
	OpenPort(protocol string, port int) error

	// ClosePort ensures the supplied port is closed even when the executing
	// unit's service is exposed (unless it is opened separately by a co-
	// located unit).
	ClosePort(protocol string, port int) error

	// Config returns the current service configuration of the executing unit.
	ConfigSettings() (charm.Settings, 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 owner of the service the executing units belongs to
	OwnerTag() string
}

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.RelationSettings, 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) Run

func (c *JujuLogCommand) Run(ctx *cmd.Context) error

func (*JujuLogCommand) SetFlags

func (c *JujuLogCommand) 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.

func (*Jujuc) Main

func (j *Jujuc) Main(req Request, resp *exec.ExecResponse) error

Main runs the Command specified by req, and fills in resp. A single command is run at a time.

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) Run

func (c *OwnerGetCommand) Run(ctx *cmd.Context) error

func (*OwnerGetCommand) SetFlags

func (c *OwnerGetCommand) SetFlags(f *gnuflag.FlagSet)

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) Run

func (c *RelationGetCommand) Run(ctx *cmd.Context) 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) Run

func (c *RelationIdsCommand) Run(ctx *cmd.Context) 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) Run

func (c *RelationListCommand) Run(ctx *cmd.Context) 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) Run

func (c *RelationSetCommand) Run(ctx *cmd.Context) (err error)

func (*RelationSetCommand) SetFlags

func (c *RelationSetCommand) SetFlags(f *gnuflag.FlagSet)

type Request

type Request struct {
	ContextId   string
	Dir         string
	CommandName string
	Args        []string
}

Request contains the information necessary to run a Command remotely.

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

func NewServer(getCmd CmdGetter, socketPath string) (*Server, error)

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.

func (*Server) Close

func (s *Server) Close()

Close immediately stops accepting connections, and blocks until all existing connections have been closed.

func (*Server) Run

func (s *Server) Run() (err error)

Run accepts new connections until it encounters an error, or until Close is called, and then blocks until all existing connections have been closed.

type Settings

type Settings interface {
	Map() params.RelationSettings
	Set(string, string)
	Delete(string)
}

Settings is implemented by types that manipulate unit settings.

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) Run

func (c *UnitGetCommand) Run(ctx *cmd.Context) error

func (*UnitGetCommand) SetFlags

func (c *UnitGetCommand) SetFlags(f *gnuflag.FlagSet)

Jump to

Keyboard shortcuts

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