machiner

package
v0.0.0-...-4308112 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetObservedNetworkConfig = corenetwork.GetObservedNetworkConfig

GetObservedNetworkConfig is patched for testing.

View Source
var NewMachiner = func(cfg Config) (worker.Worker, error) {
	if err := cfg.Validate(); err != nil {
		return nil, errors.Annotate(err, "validating config")
	}
	handler := &Machiner{config: cfg}
	w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
		Handler: handler,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}

NewMachiner returns a Worker that will wait for the identified machine to become Dying and make it Dead; or until the machine becomes Dead by other means.

The machineDead function will be called immediately after the machine's lifecycle is updated to Dead.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency manifold that runs a machiner worker, using the resource names defined in the supplied config.

Types

type APIMachineAccessor

type APIMachineAccessor struct {
	State *machiner.Client
}

func (APIMachineAccessor) Machine

func (a APIMachineAccessor) Machine(ctx context.Context, tag names.MachineTag) (Machine, error)

type Config

type Config struct {
	// MachineAccessor provides a means of observing and updating the
	// machine's state.
	MachineAccessor MachineAccessor

	// Tag is the machine's tag.
	Tag names.MachineTag

	// ClearMachineAddressesOnStart indicates whether or not to clear
	// the machine's machine addresses when the worker starts.
	ClearMachineAddressesOnStart bool
}

Config defines the configuration for a machiner worker.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate reports whether or not the configuration is valid.

type Machine

type Machine interface {
	Refresh(context.Context) error
	Life() life.Value
	EnsureDead(context.Context) error
	SetMachineAddresses(ctx context.Context, addresses []network.MachineAddress) error
	SetStatus(ctx context.Context, machineStatus status.Status, info string, data map[string]interface{}) error
	Watch(context.Context) (watcher.NotifyWatcher, error)
	SetObservedNetworkConfig(ctx context.Context, netConfig []params.NetworkConfig) error
}

type MachineAccessor

type MachineAccessor interface {
	Machine(context.Context, names.MachineTag) (Machine, error)
}

type Machiner

type Machiner struct {
	// contains filtered or unexported fields
}

Machiner is responsible for a machine agent's lifecycle.

func (*Machiner) Handle

func (mr *Machiner) Handle(ctx context.Context) error

func (*Machiner) SetUp

func (mr *Machiner) SetUp(ctx context.Context) (watcher.NotifyWatcher, error)

func (*Machiner) TearDown

func (mr *Machiner) TearDown() error

type ManifoldConfig

type ManifoldConfig struct {
	AgentName     string
	APICallerName string
}

ManifoldConfig defines the names of the manifolds on which a Manifold will depend.

Jump to

Keyboard shortcuts

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