juju: github.com/juju/juju/container/broker Index | Files | Directories

package broker

import "github.com/juju/juju/container/broker"

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

Index

Package Files

broker.go host_preparer.go instance_broker.go kvm-broker.go lxd-broker.go

func ConfigureAvailabilityZone Uses

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 Uses

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

New creates a new InstanceBroker from the Config

func NewKVMBroker Uses

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 Uses

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.

type APICalls Uses

type APICalls interface {
    ContainerConfig() (params.ContainerConfig, error)
    PrepareContainerInterfaceInfo(names.MachineTag) ([]corenetwork.InterfaceInfo, error)
    GetContainerInterfaceInfo(names.MachineTag) ([]corenetwork.InterfaceInfo, 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)
}

go:generate mockgen -package mocks -destination mocks/apicalls_mock.go github.com/juju/juju/container/broker APICalls

type AvailabilityZoner Uses

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

type Config Uses

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 Uses

func (c Config) Validate() error

Validate validates the instance broker configuration.

type ContainerBrokerFunc Uses

type ContainerBrokerFunc func(PrepareHostFunc, APICalls, container.Manager, agent.Config) (environs.InstanceBroker, error)

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

type HostPreparer Uses

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 Uses

func NewHostPreparer(params HostPreparerParams) *HostPreparer

NewHostPreparer creates a HostPreparer using the supplied parameters

func (*HostPreparer) Prepare Uses

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 Uses

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 Uses

type NetConfigFunc func(common.NetworkConfigSource) ([]params.NetworkConfig, error)

NetConfigFunc returns a slice of NetworkConfig from a source config.

type NewBrokerFunc Uses

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

NewBrokerFunc returns a Instance Broker.

type PrepareAPI Uses

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 Uses

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

Directories

PathSynopsis
mocksPackage mocks is a generated GoMock package.

Package broker imports 27 packages (graph) and is imported by 8 packages. Updated 2019-12-06. Refresh now. Tools for package owners.