containerizer

package
v0.0.0-...-298751d Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BridgeNameForDevice

func BridgeNameForDevice(device string) string

BridgeNameForDevice returns a name to use for a new device that bridges the device with the input name. The policy is to:

  1. Add br- to device name (to keep current behaviour), if it does not fit in 15 characters then:
  2. Add b- to device name, if it doesn't fit in 15 characters then:

3a. For devices starting in 'en' remove 'en' and add 'b-' 3b. For all other devices

	'b-' + 6-char hash of name + '-' + last 6 chars of name
 4. If using the device name directly always replace '.' with '-'
    to make sure that bridges from VLANs won't break

Types

type Address

type Address interface {
	Subnet() (Subnet, error)
	DeviceName() string
}

Address is an indirection for state.Address.

func NewAddress

func NewAddress(a *state.Address) Address

NewAddress wraps the given state.Address in an addressShim.

type BridgePolicy

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

BridgePolicy defines functionality that helps us create and define bridges for guests inside a host machine, along with the creation of network devices on those bridges for the containers to use.

func NewBridgePolicy

func NewBridgePolicy(cfgGetter environs.ConfigGetter, st SpaceBacking) (*BridgePolicy, error)

NewBridgePolicy returns a new BridgePolicy for the input environ config getter and state indirection.

func (*BridgePolicy) FindMissingBridgesForContainer

func (p *BridgePolicy) FindMissingBridgesForContainer(
	host Machine, guest Container,
) ([]network.DeviceToBridge, int, error)

FindMissingBridgesForContainer looks at the spaces that the container should have access to, and returns any host devices need to be bridged for use as the container network. This will return an Error if the container requires a space that the host machine cannot provide.

func (*BridgePolicy) PopulateContainerLinkLayerDevices

func (p *BridgePolicy) PopulateContainerLinkLayerDevices(
	host Machine, guest Container, askProviderForAddress bool,
) (corenetwork.InterfaceInfos, error)

PopulateContainerLinkLayerDevices generates and returns link-layer devices for the input guest, setting each device to be a child of the corresponding bridge on the host machine. It also records when one of the desired spaces is available on the host machine, but not currently bridged.

type Container

type Container interface {
	Machine
	ContainerType() instance.ContainerType
	Constraints() (constraints.Value, error)
}

Container is an indirection for state.Machine, describing a container.

type LinkLayerDevice

type LinkLayerDevice interface {
	Name() string
	Type() network.LinkLayerDeviceType
	MACAddress() string
	ParentName() string
	ParentDevice() (LinkLayerDevice, error)
	EthernetDeviceForBridge(name string, askForProviderAddress bool) (network.InterfaceInfo, error)
	Addresses() ([]*state.Address, error)
	VirtualPortType() network.VirtualPortType

	// These are recruited in tests. See comment on Machine below.
	MTU() uint
	IsUp() bool
	IsAutoStart() bool
}

LinkLayerDevice is an indirection for state.LinkLayerDevice. It facilitates testing the provisioner's use of this package.

func NewLinkLayerDevice

func NewLinkLayerDevice(dev *state.LinkLayerDevice) LinkLayerDevice

NewLinkLayerDevice wraps the given state.LinkLayerDevice in a linkLayerDevice.

type Machine

type Machine interface {
	Id() string
	AllDeviceAddresses() ([]Address, error)
	AllSpaces() (set.Strings, error)
	SetLinkLayerDevices(devicesArgs ...state.LinkLayerDeviceArgs) (err error)
	AllLinkLayerDevices() ([]LinkLayerDevice, error)

	// TODO (manadart 2018-10-10) These methods are used in tests, which rely
	// on the StateSuite. Some of them are recruited via the Container
	// interface below, but they are all located here for simplicity.
	// A better approach could be sought that does not require their
	// presence here.
	SetDevicesAddresses(devicesAddresses ...state.LinkLayerDeviceAddress) (err error)
	SetConstraints(cons constraints.Value) (err error)
	RemoveAllAddresses() error
	Raw() *state.Machine
}

Machine is an indirection for state.Machine, describing a machine that is to host containers.

type MachineShim

type MachineShim struct {
	*state.Machine
}

MachineShim implements Machine. It is required to mock the return of LinkLayerDevicesForSpaces, which includes raw state.LinkLayerDevice references.

func NewMachine

func NewMachine(m *state.Machine) *MachineShim

NewMachine wraps the given state.machine in a MachineShim.

func (*MachineShim) AllDeviceAddresses

func (m *MachineShim) AllDeviceAddresses() ([]Address, error)

AllDeviceAddresses implements Machine by wrapping each state.Address reference in returned collection with the local Address implementation.

func (*MachineShim) AllLinkLayerDevices

func (m *MachineShim) AllLinkLayerDevices() ([]LinkLayerDevice, error)

AllLinkLayerDevices implements Machine by wrapping each state.LinkLayerDevice reference in returned collection with the local LinkLayerDevice implementation.

func (*MachineShim) Raw

func (m *MachineShim) Raw() *state.Machine

Raw returns the inner state.Machine reference.

type SpaceBacking

type SpaceBacking interface {
	AllSpaceInfos() (network.SpaceInfos, error)
}

SpaceBacking describes the retrieval of all spaces from the DB.

type Subnet

type Subnet interface {
	SpaceID() string
}

Subnet is an indirection for state.Subnet.

Jump to

Keyboard shortcuts

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