agent

package
v0.0.0-...-f88c608 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 80 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectAsAgent

func ConnectAsAgent(ctx context.Context, 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 MachineAgentFactoryFn

func MachineAgentFactoryFn(
	agentConfWriter agentconfig.AgentConfigWriter,
	bufferedLogger *logsender.BufferedLogWriter,
	preUpgradeSteps PreUpgradeStepsFunc,
	upgradeSteps UpgradeStepsFunc,
	rootDir string,
) machineAgentFactoryFnType

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

func NewCheckConnectionCommand

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

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

func NewMachineAgentCommand

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

NewMachineAgentCommand creates a Command that handles parsing command-line arguments and instantiating and running a MachineAgent.

Types

type AgentInitializer

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 CommandRunner

type CommandRunner interface {
	RunCommands(run exec.RunParams) (*exec.ExecResponse, error)
}

CommandRunner allows to run commands on the underlying system

type ConnectFunc

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

ConnectFunc connects to the API as the given agent.

type MachineAgent

type MachineAgent struct {
	agentconfig.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

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

NewMachineAgent instantiates a new MachineAgent.

func (*MachineAgent) ChangeConfig

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

func (*MachineAgent) Done

func (a *MachineAgent) Done(err error)

Done signals the machine agent is finished

func (*MachineAgent) Restart

func (a *MachineAgent) Restart() error

Restart restarts the agent's service.

func (*MachineAgent) Run

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

Run runs a machine agent.

func (*MachineAgent) Stop

func (a *MachineAgent) Stop() error

Stop stops the machine agent.

func (*MachineAgent) Tag

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

func (*MachineAgent) Wait

func (a *MachineAgent) Wait() error

Wait waits for the machine agent to finish.

func (*MachineAgent) WorkersStarted

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 ModelCommand

type ModelCommand struct {
	agentconf.AgentConf
	cmd.CommandBase

	ModelUUID string
	// contains filtered or unexported fields
}

ModelCommand is a cmd.Command responsible for running a model agent.

func NewModelCommand

func NewModelCommand(
	bufferedLogger *logsender.BufferedLogWriter,
) *ModelCommand

NewModelCommand creates a new ModelCommand instance properly initialized

func (*ModelCommand) Done

func (m *ModelCommand) Done(err error)

Done signals the model agent is finished

func (*ModelCommand) Info

func (m *ModelCommand) Info() *cmd.Info

Info implements Command

func (*ModelCommand) Init

func (m *ModelCommand) Init(args []string) error

Init initializers the command for running

func (*ModelCommand) Run

func (m *ModelCommand) Run(ctx *cmd.Context) error

Run implements Command

func (*ModelCommand) SetFlags

func (m *ModelCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags implements Command

func (*ModelCommand) Stop

func (m *ModelCommand) Stop() error

Stop implements worker

func (*ModelCommand) Tag

func (m *ModelCommand) Tag() names.Tag

func (*ModelCommand) Wait

func (m *ModelCommand) Wait() error

func (*ModelCommand) Workers

func (m *ModelCommand) Workers() (worker.Worker, error)

type PreUpgradeStepsFunc

type PreUpgradeStepsFunc func(state.ModelType) upgrades.PreUpgradeStepsFunc

The following allows the upgrade steps to be overridden by brittle integration tests.

type UpgradeStepsFunc

type UpgradeStepsFunc = upgrades.UpgradeStepsFunc

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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