Documentation
¶
Index ¶
- func BridgeNameForDevice(device string) string
- type Address
- type BridgePolicy
- func (p *BridgePolicy) FindMissingBridgesForContainer(host Machine, guest Container, allSubnets corenetwork.SubnetInfos) ([]network.DeviceToBridge, int, error)
- func (p *BridgePolicy) PopulateContainerLinkLayerDevices(host Machine, guest Container, askProviderForAddress bool) (corenetwork.InterfaceInfos, error)
- type Container
- type LinkLayerDevice
- type Machine
- type MachineShim
- type NetworkService
- type Subnet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BridgeNameForDevice ¶
BridgeNameForDevice returns a name to use for a new device that bridges the device with the input name. The policy is to:
- Add br- to device name (to keep current behaviour), if it does not fit in 15 characters then:
- 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 { DeviceName() string // SubnetCIDR returns the CIDR of the subnet this IP address comes from. SubnetCIDR() string }
Address is an indirection for state.Address.
func NewAddress ¶
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(ctx context.Context, networkService NetworkService, netBondReconfigureDelay int, containerNetworkingMethod containermanager.NetworkingMethod, ) (*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, allSubnets corenetwork.SubnetInfos, ) ([]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, allSubnets network.SubnetInfos) (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(allSubnets network.SubnetInfos) (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 ¶
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 NetworkService ¶
type NetworkService interface { // GetAllSpaces returns all spaces for the model. GetAllSpaces(ctx context.Context) (network.SpaceInfos, error) // GetAllSubnets returns all the subnets for the model. GetAllSubnets(ctx context.Context) (network.SubnetInfos, error) }
NetworkService is the interface that is used to interact with the network spaces/subnets.