broker

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Copyright 2019 Canonical Ltd. Licensed under the AGPLv3, see LICENCE file for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureAvailabilityZone

func ConfigureAvailabilityZone(managerConfig container.ManagerConfig, machineZone AvailabilityZoner) (container.ManagerConfig, error)

ConfigureAvailabilityZone reads the availability zone from the machine and adds the resulting information to the the manager config.

func New

func New(config Config) (environs.InstanceBroker, error)

New creates a new InstanceBroker from the Config

func NewKVMBroker

func NewKVMBroker(
	prepareHost PrepareHostFunc,
	api APICalls,
	manager container.Manager,
	agentConfig agent.Config,
) (environs.InstanceBroker, error)

NewKVMBroker creates a Broker that can be used to start KVM guests in a similar fashion to normal StartInstance requests. prepareHost is a callback that will be called when a new container is about to be started. It provides the intersection point where the host can update itself to be ready for whatever changes are necessary to have a functioning container. (such as bridging host devices.) manager is the infrastructure to actually launch the container. agentConfig is currently only used to find out the 'default' bridge to use when a specific network device is not specified in StartInstanceParams. This should be deprecated. And hopefully removed in the future.

func NewLXDBroker

func NewLXDBroker(
	prepareHost PrepareHostFunc,
	api APICalls,
	manager container.Manager,
	agentConfig agent.Config,
) (environs.InstanceBroker, error)

NewLXDBroker creates a Broker that can be used to start LXD containers in a similar fashion to normal StartInstance requests. prepareHost is a callback that will be called when a new container is about to be started. It provides the intersection point where the host can update itself to be ready for whatever changes are necessary to have a functioning container. (such as bridging host devices.) manager is the infrastructure to actually launch the container. agentConfig is currently only used to find out the 'default' bridge to use when a specific network device is not specified in StartInstanceParams. This should be deprecated. And hopefully removed in the future.

Types

type APICalls

type APICalls interface {
	ContainerConfig() (params.ContainerConfig, error)
	PrepareContainerInterfaceInfo(names.MachineTag) (corenetwork.InterfaceInfos, error)
	GetContainerProfileInfo(names.MachineTag) ([]*apiprovisioner.LXDProfileResult, error)
	ReleaseContainerAddresses(names.MachineTag) error
	SetHostMachineNetworkConfig(names.MachineTag, []params.NetworkConfig) error
	HostChangesForContainer(containerTag names.MachineTag) ([]network.DeviceToBridge, int, error)
}

type AvailabilityZoner

type AvailabilityZoner interface {
	AvailabilityZone() (string, error)
}

type Config

type Config struct {
	Name          string
	ContainerType instance.ContainerType
	ManagerConfig container.ManagerConfig
	APICaller     APICalls
	AgentConfig   agent.Config
	MachineTag    names.MachineTag
	MachineLock   machinelock.Lock
	GetNetConfig  NetConfigFunc
}

Config describes the resources used by the instance broker.

func (Config) Validate

func (c Config) Validate() error

Validate validates the instance broker configuration.

type ContainerBrokerFunc

ContainerBrokerFunc is used to align the constructors of the various brokers so that we can create them with the same arguments.

type HostPreparer

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

HostPreparer calls out to the PrepareAPI to find out what changes need to be done on this host to allow a new container to be started.

func NewHostPreparer

func NewHostPreparer(params HostPreparerParams) *HostPreparer

NewHostPreparer creates a HostPreparer using the supplied parameters

func (*HostPreparer) Prepare

func (hp *HostPreparer) Prepare(containerTag names.MachineTag) error

Prepare applies changes to the host machine that are necessary to create the requested container.

type HostPreparerParams

type HostPreparerParams struct {
	API                PrepareAPI
	ObserveNetworkFunc func() ([]params.NetworkConfig, error)
	AcquireLockFunc    func(string, <-chan struct{}) (func(), error)
	CreateBridger      func() (network.Bridger, error)
	AbortChan          <-chan struct{}
	MachineTag         names.MachineTag
	Logger             loggo.Logger
}

HostPreparerParams is the configuration for HostPreparer

type NetConfigFunc

type NetConfigFunc func(corenetwork.ConfigSource) ([]params.NetworkConfig, error)

NetConfigFunc returns a slice of NetworkConfig from a source config.

type NewBrokerFunc

type NewBrokerFunc func(Config) (environs.InstanceBroker, error)

NewBrokerFunc returns a Instance Broker.

type PrepareAPI

type PrepareAPI interface {
	// HostChangesForContainer returns the list of bridges to be created on the
	// host machine, and the time to sleep after creating the bridges before
	// bringing them up.
	HostChangesForContainer(names.MachineTag) ([]network.DeviceToBridge, int, error)
	// SetHostMachineNetworkConfig allows us to report back the host machine's
	// current networking config. This is called after we've created new
	// bridges to inform the Controller what the current networking interfaces
	// are.
	SetHostMachineNetworkConfig(names.MachineTag, []params.NetworkConfig) error
}

PrepareAPI is the functional interface that we need to be able to ask what changes are necessary, and to then report back what changes have been done to the host machine.

type PrepareHostFunc

type PrepareHostFunc func(containerTag names.MachineTag, log loggo.Logger, abort <-chan struct{}) error

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