agent

package
v0.0.0-...-be26699 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2015 License: AGPL-3.0 Imports: 96 Imported by: 0

Documentation

Overview

agent contains jujud's machine agent.

Index

Constants

This section is empty.

Variables

View Source
var ProductionMongoWriteConcern = true

Variable to override in tests, default is true

Functions

func MachineAgentFactoryFn

func MachineAgentFactoryFn(
	agentConfWriter AgentConfigWriter,
	apiAddressSetter apiaddressupdater.APIAddressSetter,
) func(string) *MachineAgent

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

func NewEnvironmentStorageDataSource

func NewEnvironmentStorageDataSource(stor storage.Storage) simplestreams.DataSource

NewEnvironmentStorageDataSource returns a new datasource that retrieves metadata from environment storage.

func NewMachineAgentCmd

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

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

func NewUpgradeWorkerContext

func NewUpgradeWorkerContext() *upgradeWorkerContext

func OpenAPIState

func OpenAPIState(agentConfig agent.Config, a Agent) (_ *api.State, _ *apiagent.Entity, outErr error)

OpenAPIState opens the API using the given information. The agent's password is changed if the fallback password was used to connect to the API.

func OpenAPIStateUsingInfo

func OpenAPIStateUsingInfo(info *api.Info, a Agent, oldPassword string) (*api.State, error)

OpenAPIStateUsingInfo opens the API using the given API information, and returns the opened state and the api entity with the given tag.

Types

type APIStateUpgrader

type APIStateUpgrader interface {
	SetVersion(string, version.Binary) error
}

APIStateUpgrader defines the methods on the Upgrader that agents call.

type Agent

type Agent interface {
	Tag() names.Tag
	ChangeConfig(agent.ConfigMutator) error
}

type AgentConf

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
	// ReadConfig reads the agent's config from its config file.
	ReadConfig(tag string) error
	// ChangeConfig modifies this configuration using the given mutator.
	ChangeConfig(change agent.ConfigMutator) error
	// CurrentConfig returns the agent config for this agent.
	CurrentConfig() agent.Config
	// SetAPIHostPorts satisfies worker/apiaddressupdater/APIAddressSetter.
	SetAPIHostPorts(servers [][]network.HostPort) error
	// SetStateServingInfo satisfies worker/certupdater/SetStateServingInfo.
	SetStateServingInfo(info params.StateServingInfo) error
	// DataDir returns the directory where this agent should store its data.
	DataDir() string
}

func NewAgentConf

func NewAgentConf(dataDir string) AgentConf

NewAgentConf returns a new value that satisfies AgentConf

type AgentConfigWriter

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

type AgentInitializer interface {
	AddFlags(*gnuflag.FlagSet)
	CheckArgs([]string) error
}

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

type AgentState

type AgentState interface {
	// SetAgentVersion sets the tools version that the agent is
	// currently running.
	SetAgentVersion(v version.Binary) error
	Tag() string
	Life() state.Life
}

The AgentState interface is implemented by state types that represent running agents.

type MachineAgent

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

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

func NewMachineAgent

func NewMachineAgent(
	machineId string,
	agentConfWriter AgentConfigWriter,
	apiAddressSetter apiaddressupdater.APIAddressSetter,
	upgradeWorkerContext *upgradeWorkerContext,
	runner worker.Runner,
) *MachineAgent

NewMachineAgent instantiates a new MachineAgent.

func (*MachineAgent) APIWorker

func (a *MachineAgent) APIWorker() (_ worker.Worker, err error)

APIWorker returns a Worker that connects to the API and starts any workers that need an API connection.

func (*MachineAgent) BeginRestore

func (a *MachineAgent) BeginRestore() error

BeginRestore will flag the agent to disallow all commands since restore should be running and therefore making changes that would override anything done.

func (*MachineAgent) ChangeConfig

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

func (*MachineAgent) Dying

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

Dying returns the channel that can be used to see if the machine agent is terminating.

func (*MachineAgent) EndRestore

func (a *MachineAgent) EndRestore()

EndRestore will flag the agent to allow all commands This being invoked means that restore process failed since success restarts the agent.

func (*MachineAgent) IsRestorePreparing

func (a *MachineAgent) IsRestorePreparing() bool

IsRestorePreparing returns bool representing if we are in restore mode but not running restore.

func (*MachineAgent) IsRestoreRunning

func (a *MachineAgent) IsRestoreRunning() bool

IsRestoreRunning returns bool representing if we are in restore mode and running the actual restore process.

func (*MachineAgent) PrepareRestore

func (a *MachineAgent) PrepareRestore() error

PrepareRestore will flag the agent to allow only a limited set of commands defined in "github.com/juju/juju/apiserver".allowedMethodsAboutToRestore the most noteworthy is: Backups.Restore: this will ensure that we can do all the file movements required for restore and no one will do changes while we do that. it will return error if the machine is already in this state.

func (*MachineAgent) Restart

func (a *MachineAgent) Restart() error

Restart restarts the agent's service.

func (*MachineAgent) Run

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

Run runs a machine agent.

func (*MachineAgent) StateWorker

func (a *MachineAgent) StateWorker() (worker.Worker, error)

StateWorker returns a worker running all the workers that require a *state.State connection.

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 MongoSessioner

type MongoSessioner interface {
	MongoSession() *mgo.Session
}

type UnitAgent

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

func NewUnitAgent(ctx *cmd.Context) *UnitAgent

NewUnitAgent creates a new UnitAgent value properly initialized.

func (*UnitAgent) APIWorkers

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

func (*UnitAgent) Info

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

Info returns usage information for the command.

func (*UnitAgent) Init

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

Init initializes the command for running.

func (*UnitAgent) Run

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

Run runs a unit agent.

func (*UnitAgent) SetFlags

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

func (*UnitAgent) Stop

func (a *UnitAgent) Stop() error

Stop stops the unit agent.

func (*UnitAgent) Tag

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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