agent

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2013 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(dataDir, agentName string) string

Dir returns the agent-specific data directory.

func InitialStateConfiguration

func InitialStateConfiguration(agentConfig Config, cfg *config.Config, timeout state.DialOpts) (*state.State, error)

Types

type AgentConfigParams

type AgentConfigParams struct {
	DataDir        string
	Tag            string
	Password       string
	Nonce          string
	StateAddresses []string
	APIAddresses   []string
	CACert         []byte
}

type Config

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

	// 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, the password used to connect to the state
	// should be changed accordingly - the caller should set the entity's
	// password accordingly.
	OpenAPI(dialOpts api.DialOpts) (st *api.State, newPassword string, err error)

	// OpenState tries to open a direct connection to the state database using
	// the given Conf.
	OpenState() (*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() ([]string, error)

	// GenerateNewPassword creates a new random password and saves this.  The
	// new password string is returned.
	GenerateNewPassword() (string, error)

	// PasswordHash returns a hash of the password that is stored for state and
	// api connections.
	PasswordHash() string

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

func NewAgentConfig

func NewAgentConfig(params AgentConfigParams) (Config, error)

NewAgentConfig returns a new config object suitable for use for a unit agent. As the unit agent becomes entirely APIified, we should remove the state addresses from here.

func NewStateMachineConfig

func NewStateMachineConfig(params StateMachineConfigParams) (Config, error)

func ReadConf

func ReadConf(dataDir, tag string) (Config, error)

ReadConf reads configuration data for the given entity from the given data directory.

type StateMachineConfigParams

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

Jump to

Keyboard shortcuts

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