agent

package
v0.0.0-...-a7271ac Latest Latest
Warning

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

Go to latest
Published: May 4, 2014 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LxcBridge        = "LXC_BRIDGE"
	ProviderType     = "PROVIDER_TYPE"
	ContainerType    = "CONTAINER_TYPE"
	Namespace        = "NAMESPACE"
	StorageDir       = "STORAGE_DIR"
	StorageAddr      = "STORAGE_ADDR"
	AgentServiceName = "AGENT_SERVICE_NAME"
	MongoServiceName = "MONGO_SERVICE_NAME"
)

Variables

View Source
var DefaultLogDir = path.Join(osenv.LogDir, "juju")

DefaultLogDir defines the default log directory for juju agents.

Functions

func ConfigPath

func ConfigPath(dataDir, agentName string) string

ConfigPath returns the full path to the agent config file. NOTE: Delete this once all agents accept --config instead of --data-dir - it won't be needed anymore.

func Dir

func Dir(dataDir, agentName string) string

Dir returns the agent-specific data directory.

Types

type AgentConfigParams

type AgentConfigParams struct {
	DataDir           string
	LogDir            string
	Jobs              []params.MachineJob
	UpgradedToVersion version.Number
	Tag               string
	Password          string
	Nonce             string
	StateAddresses    []string
	APIAddresses      []string
	CACert            []byte
	Values            map[string]string
}

type BootstrapMachineConfig

type BootstrapMachineConfig struct {
	// Constraints holds the bootstrap machine's constraints.
	// This value is also used for the environment-level constraints.
	Constraints constraints.Value

	// Jobs holds the jobs that the machine agent will run.
	Jobs []params.MachineJob

	// InstanceId holds the instance id of the bootstrap machine.
	InstanceId instance.Id

	// Characteristics holds hardware information on the
	// bootstrap machine.
	Characteristics instance.HardwareCharacteristics
}

BootstrapMachineConfig holds configuration information to attach to the bootstrap machine.

type Config

type Config interface {
	// DataDir returns the data directory. Each agent has a subdirectory
	// containing the configuration files.
	DataDir() string

	// LogDir returns the log directory. All logs from all agents on
	// the machine are written to this directory.
	LogDir() string

	// Jobs returns a list of MachineJobs that need to run.
	Jobs() []params.MachineJob

	// Tag returns the tag of the entity on whose behalf the state connection
	// will be made.
	Tag() string

	// Dir returns the agent's directory.
	Dir() string

	// Nonce returns the nonce saved when the machine was provisioned
	// TODO: make this one of the key/value pairs.
	Nonce() string

	// CACert returns the CA certificate that is used to validate the state or
	// API servier's certificate.
	CACert() []byte

	// OpenAPI tries to connect to an API end-point.  If a non-empty
	// newPassword is returned, OpenAPI will have written the configuration
	// with the new password; the caller should set the connecting entity's
	// password accordingly.
	OpenAPI(dialOpts api.DialOpts) (st *api.State, newPassword string, err error)

	// APIAddresses returns the addresses needed to connect to the api server
	APIAddresses() ([]string, error)

	// OpenState tries to open a direct connection to the state database using
	// the given Conf.
	OpenState(policy state.Policy) (*state.State, error)

	// Write writes the agent configuration.
	Write() error

	// WriteCommands returns shell commands to write the agent configuration.
	// It returns an error if the configuration does not have all the right
	// elements.
	WriteCommands(serie string) ([]string, error)

	// APIServerDetails returns the details needed to run an API server.
	APIServerDetails() (port int, cert, key []byte)

	// UpgradedToVersion returns the version for which all upgrade steps have been
	// successfully run, which is also the same as the initially deployed version.
	UpgradedToVersion() version.Number

	// WriteUpgradedToVersion updates the config's UpgradedToVersion and writes
	// the new agent configuration.
	WriteUpgradedToVersion(newVersion version.Number) error

	// Value returns the value associated with the key, or an empty string if
	// the key is not found.
	Value(key string) string

	// SetValue updates the value for the specified key.
	SetValue(key, value string)

	StateInitializer
}

The Config interface is the sole way that the agent gets access to the configuration information for the machine and unit agents. There should only be one instance of a config object for any given agent, and this interface is passed between multiple go routines. The mutable methods are protected by a mutex, and it is expected that the caller doesn't modify any slice that may be returned.

NOTE: should new mutating methods be added to this interface, consideration is needed around the synchronisation as a single instance is used in multiple go routines.

func NewAgentConfig

func NewAgentConfig(configParams AgentConfigParams) (Config, error)

NewAgentConfig returns a new config object suitable for use for a machine or unit agent.

func NewStateMachineConfig

func NewStateMachineConfig(configParams StateMachineConfigParams) (Config, error)

NewStateMachineConfig returns a configuration suitable for a machine running the state server.

func ReadConf

func ReadConf(configFilePath string) (Config, error)

ReadConf reads configuration data from the given location.

type StateInitializer

type StateInitializer interface {
	InitializeState(envCfg *config.Config, machineCfg BootstrapMachineConfig, timeout state.DialOpts, policy state.Policy) (*state.State, *state.Machine, error)
}

InitializeState should be called on the bootstrap machine's agent configuration. It uses that information to dial the state server and initialize it. It also generates a new password for the bootstrap machine and calls Write to save the the configuration.

The envCfg values will be stored in the state's EnvironConfig; the machineCfg values will be used to configure the bootstrap Machine, and its constraints will be also be used for the environment-level constraints. The connection to the state server will respect the given timeout parameter.

InitializeState returns the newly initialized state and bootstrap machine. If it fails, the state may well be irredeemably compromised.

type StateMachineConfigParams

type StateMachineConfigParams struct {
	AgentConfigParams
	StateServerCert []byte
	StateServerKey  []byte
	StatePort       int
	APIPort         int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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