juju: github.com/juju/juju/network/containerizer Index | Files

package containerizer

import "github.com/juju/juju/network/containerizer"


Package Files

bridgepolicy.go shim.go

func BridgeNameForDevice Uses

func BridgeNameForDevice(device string) string

The general 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

type Application Uses

type Application interface {
    Charm() (Charm, bool, error)
    Name() string
    EndpointBindings() (map[string]string, error)

type BridgePolicy Uses

type BridgePolicy struct {
    // contains filtered or unexported fields

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

func NewBridgePolicy Uses

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 Uses

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 Uses

func (p *BridgePolicy) PopulateContainerLinkLayerDevices(host Machine, guest Container) error

PopulateContainerLinkLayerDevices sets the link-layer devices of 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 Charm Uses

type Charm interface {
    LXDProfile() *jujucharm.LXDProfile
    Revision() int

type Container Uses

type Container interface {
    ContainerType() instance.ContainerType
    Units() ([]Unit, error)
    Constraints() (constraints.Value, error)

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

type LinkLayerDevice Uses

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

    // 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.

type Machine Uses

type Machine interface {
    Id() string
    AllSpaces() (set.Strings, error)
    LinkLayerDevicesForSpaces(infos network.SpaceInfos) (map[string][]LinkLayerDevice, 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)
    SetParentLinkLayerDevicesBeforeTheirChildren(devicesArgs []state.LinkLayerDeviceArgs) 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 Uses

type MachineShim struct {

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

func NewMachine Uses

func NewMachine(m *state.Machine) *MachineShim

func (*MachineShim) AllLinkLayerDevices Uses

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) LinkLayerDevicesForSpaces Uses

func (m *MachineShim) LinkLayerDevicesForSpaces(spaces network.SpaceInfos) (map[string][]LinkLayerDevice, error)

LinkLayerDevicesForSpaces implements Machine by unwrapping the inner state.Machine call and wrapping the raw state.LinkLayerDevice references with the local LinkLayerDevice implementation.

func (*MachineShim) Raw Uses

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

Raw returns the inner state.Machine reference.

func (*MachineShim) Units Uses

func (m *MachineShim) Units() ([]Unit, error)

type SpaceBacking Uses

type SpaceBacking interface {
    AllSpaces() ([]*state.Space, error)

SpaceBacking describes the retrieval of all spaces from the DB.

type Spaces Uses

type Spaces interface {
    // GetByID returns the space for the input ID or an error if not found.
    GetByID(id string) (network.SpaceInfo, error)
    // GetByName returns the space for the input name or an error if not found.
    GetByName(name string) (network.SpaceInfo, error)

Spaces describes a cache of all space info for a model.

func NewSpaces Uses

func NewSpaces(st SpaceBacking) (Spaces, error)

NewSpaces uses the input backing to populate and return a cache of spaces.

type Unit Uses

type Unit interface {
    Application() (Application, error)
    Name() string

Package containerizer imports 14 packages (graph) and is imported by 4 packages. Updated 2019-10-15. Refresh now. Tools for package owners.