juju: github.com/juju/juju/cmd/jujud/agent Index | Files | Directories

package agent

import "github.com/juju/juju/cmd/jujud/agent"

agent contains jujud's machine agent.

Index

Package Files

agent.go bootstrap.go caasoperator.go caasunitinit.go checkconnection.go introspection.go machine.go unit.go

Variables

var (
    // Should be an explicit dependency, can't do it cleanly yet.
    // Exported for testing.
    CaasOperatorManifolds = caasoperator.Manifolds
)
var ProductionMongoWriteConcern = true

Variable to override in tests, default is true

func ConnectAsAgent Uses

func ConnectAsAgent(a agent.Agent) (io.Closer, error)

ConnectAsAgent really connects to the API specified in the agent config. It's extracted so tests can pass something else in.

func DefaultIntrospectionSocketName Uses

func DefaultIntrospectionSocketName(entityTag names.Tag) string

DefaultIntrospectionSocketName returns the socket name to use for the abstract domain socket that the introspection worker serves requests over.

func GetJujuVersion Uses

func GetJujuVersion(machineAgent string, dataDir string) (version.Number, error)

GetJujuVersion gets the version of the agent from agent's config file

func MachineAgentFactoryFn Uses

func MachineAgentFactoryFn(
    agentConfWriter AgentConfigWriter,
    bufferedLogger *logsender.BufferedLogWriter,
    newIntrospectionSocketName func(names.Tag) string,
    preUpgradeSteps upgrades.PreUpgradeStepsFunc,
    rootDir string,
) machineAgentFactoryFnType

MachineAgentFactoryFn returns a function which instantiates a MachineAgent given a machineId.

func NewCheckConnectionCommand Uses

func NewCheckConnectionCommand(config AgentConf, connect ConnectFunc) cmd.Command

NewCheckConnectionCommand returns a command that will test connecting to the API with details from the agent's config.

func NewMachineAgentCmd Uses

func NewMachineAgentCmd(
    ctx *cmd.Context,
    machineAgentFactory machineAgentFactoryFnType,
    agentInitializer AgentInitializer,
    configFetcher AgentConfigWriter,
) cmd.Command

NewMachineAgentCmd creates a Command which handles parsing command-line arguments and instantiating and running a MachineAgent.

type AgentConf Uses

type AgentConf interface {

    // AddFlags injects common agent flags into f.
    AddFlags(f *gnuflag.FlagSet)

    // CheckArgs reports whether the given args are valid for this agent.
    CheckArgs(args []string) error

    // DataDir returns the directory where this agent should store its data.
    DataDir() string

    // ReadConfig reads the agent's config from its config file.
    ReadConfig(tag string) error

    // CurrentConfig returns the agent config for this agent.
    CurrentConfig() agent.Config

    // ChangeConfig modifies this configuration using the given mutator.
    ChangeConfig(change agent.ConfigMutator) error
}

AgentConf is a terribly confused interface.

Parts of it are a mixin for cmd.Command implementations; others are a mixin for agent.Agent implementations; others bridge the two. We should be aiming to separate the cmd responsibilities from the agent responsibilities.

func NewAgentConf Uses

func NewAgentConf(dataDir string) AgentConf

NewAgentConf returns a new value that satisfies AgentConf

type AgentConfigWriter Uses

type AgentConfigWriter interface {
    // ReadConfig reads the config for the given tag from disk.
    ReadConfig(tag string) error
    // ChangeConfig executes the given agent.ConfigMutator in a
    // thread-safe context.
    ChangeConfig(agent.ConfigMutator) error
    // CurrentConfig returns a copy of the in-memory agent config.
    CurrentConfig() agent.Config
}

AgentConfigWriter encapsulates disk I/O operations with the agent config.

type AgentInitializer Uses

type AgentInitializer interface {
    AddFlags(*gnuflag.FlagSet)
    CheckArgs([]string) error
    // DataDir returns the directory where this agent should store its data.
    DataDir() string
}

AgentInitializer handles initializing a type for use as a Jujud agent.

type BootstrapCommand Uses

type BootstrapCommand struct {
    cmd.CommandBase
    AgentConf
    BootstrapParamsFile string
    Timeout             time.Duration
}

BootstrapCommand represents a jujud bootstrap command.

func NewBootstrapCommand Uses

func NewBootstrapCommand() *BootstrapCommand

NewBootstrapCommand returns a new BootstrapCommand that has been initialized.

func (*BootstrapCommand) Info Uses

func (c *BootstrapCommand) Info() *cmd.Info

Info returns a description of the command.

func (*BootstrapCommand) Init Uses

func (c *BootstrapCommand) Init(args []string) error

Init initializes the command for running.

func (*BootstrapCommand) Run Uses

func (c *BootstrapCommand) Run(_ *cmd.Context) error

Run initializes state for an environment.

func (*BootstrapCommand) SetFlags Uses

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

SetFlags adds the flags for this command to the passed gnuflag.FlagSet.

type CAASUnitInitCommand Uses

type CAASUnitInitCommand struct {
    cmd.CommandBase

    Wait bool
    Send bool
    Args struct {
        Unit               string `json:"unit"`
        OperatorFile       string `json:"operator-file"`
        OperatorCACertFile string `json:"operator-ca-cert-file"`
        CharmDir           string `json:"charm-dir"`
    }
    // contains filtered or unexported fields
}

CAASUnitInitCommand represents a jujud bootstrap command.

func NewCAASUnitInitCommand Uses

func NewCAASUnitInitCommand() *CAASUnitInitCommand

NewCAASUnitInitCommand returns a new CAASUnitInitCommand that has been initialized.

func (*CAASUnitInitCommand) Info Uses

func (c *CAASUnitInitCommand) Info() *cmd.Info

Info returns a description of the command.

func (*CAASUnitInitCommand) Init Uses

func (c *CAASUnitInitCommand) Init(args []string) error

func (*CAASUnitInitCommand) Run Uses

func (c *CAASUnitInitCommand) Run(ctx *cmd.Context) (errOut error)

func (*CAASUnitInitCommand) SetFlags Uses

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

type CaasOperatorAgent Uses

type CaasOperatorAgent struct {
    cmd.CommandBase
    AgentConf

    ApplicationName string
    // contains filtered or unexported fields
}

CaasOperatorAgent is a cmd.Command responsible for running a CAAS operator agent.

func NewCaasOperatorAgent Uses

func NewCaasOperatorAgent(
    ctx *cmd.Context,
    bufferedLogger *logsender.BufferedLogWriter,
    configure func(*caasoperator.ManifoldsConfig) error,
) (*CaasOperatorAgent, error)

NewCaasOperatorAgent creates a new CAASOperatorAgent instance properly initialized.

func (*CaasOperatorAgent) ChangeConfig Uses

func (op *CaasOperatorAgent) ChangeConfig(mutate agent.ConfigMutator) error

ChangeConfig implements Agent.

func (*CaasOperatorAgent) Done Uses

func (op *CaasOperatorAgent) Done(err error)

Done signals the machine agent is finished

func (*CaasOperatorAgent) Info Uses

func (op *CaasOperatorAgent) Info() *cmd.Info

Info implements Command.

func (*CaasOperatorAgent) Init Uses

func (op *CaasOperatorAgent) Init(args []string) error

Init initializes the command for running.

func (*CaasOperatorAgent) Run Uses

func (op *CaasOperatorAgent) Run(ctx *cmd.Context) (err error)

Run implements Command.

func (*CaasOperatorAgent) SetFlags Uses

func (op *CaasOperatorAgent) SetFlags(f *gnuflag.FlagSet)

SetFlags implements Command.

func (*CaasOperatorAgent) Stop Uses

func (op *CaasOperatorAgent) Stop() error

Stop implements Worker.

func (*CaasOperatorAgent) Tag Uses

func (op *CaasOperatorAgent) Tag() names.Tag

Tag implements Agent.

func (*CaasOperatorAgent) Wait Uses

func (op *CaasOperatorAgent) Wait() error

Wait waits for the CaasOperator agent to finish.

func (*CaasOperatorAgent) Workers Uses

func (op *CaasOperatorAgent) Workers() (worker.Worker, error)

Workers returns a dependency.Engine running the operator's responsibilities.

type ConnectFunc Uses

type ConnectFunc func(agent.Agent) (io.Closer, error)

ConnectFunc connects to the API as the given agent.

type MachineAgent Uses

type MachineAgent struct {
    AgentConfigWriter
    // contains filtered or unexported fields
}

MachineAgent is responsible for tying together all functionality needed to orchestrate a Jujud instance which controls a machine.

func NewMachineAgent Uses

func NewMachineAgent(
    agentTag names.Tag,
    agentConfWriter AgentConfigWriter,
    bufferedLogger *logsender.BufferedLogWriter,
    runner *worker.Runner,
    loopDeviceManager looputil.LoopDeviceManager,
    newIntrospectionSocketName func(names.Tag) string,
    preUpgradeSteps upgrades.PreUpgradeStepsFunc,
    rootDir string,
    isCaasAgent bool,
) (*MachineAgent, error)

NewMachineAgent instantiates a new MachineAgent.

func (*MachineAgent) ChangeConfig Uses

func (a *MachineAgent) ChangeConfig(mutate agent.ConfigMutator) error

func (*MachineAgent) Done Uses

func (a *MachineAgent) Done(err error)

Done signals the machine agent is finished

func (*MachineAgent) Restart Uses

func (a *MachineAgent) Restart() error

Restart restarts the agent's service.

func (*MachineAgent) Run Uses

func (a *MachineAgent) Run(ctx *cmd.Context) (err error)

Run runs a machine agent.

func (*MachineAgent) Stop Uses

func (a *MachineAgent) Stop() error

Stop stops the machine agent.

func (*MachineAgent) Tag Uses

func (a *MachineAgent) Tag() names.Tag

func (*MachineAgent) Wait Uses

func (a *MachineAgent) Wait() error

Wait waits for the machine agent to finish.

func (*MachineAgent) WorkersStarted Uses

func (a *MachineAgent) WorkersStarted() <-chan struct{}

WorkersStarted returns a channel that's closed once all top level workers have been started. This is provided for testing purposes.

type UnitAgent Uses

type UnitAgent struct {
    cmd.CommandBase
    AgentConf

    UnitName string
    // contains filtered or unexported fields
}

UnitAgent is a cmd.Command responsible for running a unit agent.

func NewUnitAgent Uses

func NewUnitAgent(ctx *cmd.Context, bufferedLogger *logsender.BufferedLogWriter) (*UnitAgent, error)

NewUnitAgent creates a new UnitAgent value properly initialized.

func (*UnitAgent) APIWorkers Uses

func (a *UnitAgent) APIWorkers() (worker.Worker, error)

APIWorkers returns a dependency.Engine running the unit agent's responsibilities.

func (*UnitAgent) ChangeConfig Uses

func (a *UnitAgent) ChangeConfig(mutate agent.ConfigMutator) error

func (*UnitAgent) Done Uses

func (a *UnitAgent) Done(err error)

Done signals the unit agent is finished

func (*UnitAgent) Info Uses

func (a *UnitAgent) Info() *cmd.Info

Info returns usage information for the command.

func (*UnitAgent) Init Uses

func (a *UnitAgent) Init(args []string) error

Init initializes the command for running.

func (*UnitAgent) Run Uses

func (a *UnitAgent) Run(ctx *cmd.Context) (err error)

Run runs a unit agent.

func (*UnitAgent) SetFlags Uses

func (a *UnitAgent) SetFlags(f *gnuflag.FlagSet)

func (*UnitAgent) Stop Uses

func (a *UnitAgent) Stop() error

Stop stops the unit agent.

func (*UnitAgent) Tag Uses

func (a *UnitAgent) Tag() names.Tag

func (*UnitAgent) Wait Uses

func (a *UnitAgent) Wait() error

Wait waits for the unit agent to finish

Directories

PathSynopsis
agenttest
caasoperator
engine
engine/enginetest
machine
model
unit

Package agent imports 112 packages (graph) and is imported by 71 packages. Updated 2019-12-09. Refresh now. Tools for package owners.