juju: github.com/juju/juju/apiserver/common/networkingcommon Index | Files | Directories

package networkingcommon

import "github.com/juju/juju/apiserver/common/networkingcommon"

Index

Package Files

linklayer.go networkconfigapi.go shims.go types.go

func BackingSubnetToParamsSubnet Uses

func BackingSubnetToParamsSubnet(subnet BackingSubnet) params.Subnet

func BackingSubnetToParamsSubnetV2 Uses

func BackingSubnetToParamsSubnetV2(subnet BackingSubnet) params.SubnetV2

BackingSubnetToParamsSubnetV2 converts a network backing subnet to the new version of the subnet API parameter.

func FanConfigResultToFanConfig Uses

func FanConfigResultToFanConfig(config params.FanConfigResult) (network.FanConfig, error)

func FanConfigToFanConfigResult Uses

func FanConfigToFanConfigResult(config network.FanConfig) params.FanConfigResult

func NetworkInterfacesToStateArgs Uses

func NetworkInterfacesToStateArgs(devs corenetwork.InterfaceInfos) (
    []state.LinkLayerDeviceArgs,
    []state.LinkLayerDeviceAddress,
)

NetworkInterfacesToStateArgs splits the given interface list into a slice of state.LinkLayerDeviceArgs and a slice of state.LinkLayerDeviceAddress.

func NewSpaceShim Uses

func NewSpaceShim(sp *state.Space) *spaceShim

NewSpaceShim creates new subnet shim to be used by subnets and spaces Facades.

func NewSubnetShim Uses

func NewSubnetShim(sub *state.Subnet) *subnetShim

NewSubnetShim creates new subnet shim to be used by subnets and spaces Facades.

type AddSubnetsState Uses

type AddSubnetsState interface {
    // AddSubnetOps returns transaction operations required to ensure that the
    // input subnet is added to state.
    AddSubnetOps(network.SubnetInfo) ([]txn.Op, error)
}

AddSubnetsState describes methods required to add new subnets.

type BackingSpace Uses

type BackingSpace interface {
    // ID returns the ID of the space.
    Id() string

    // Name returns the space name.
    Name() string

    // Subnets returns the subnets in the space
    Subnets() ([]BackingSubnet, error)

    // ProviderId returns the network ID of the provider
    ProviderId() corenetwork.Id
}

BackingSpace defines the methods supported by a Space entity stored persistently.

type BackingSubnet Uses

type BackingSubnet interface {
    ID() string
    CIDR() string
    VLANTag() int
    ProviderId() corenetwork.Id
    ProviderNetworkId() corenetwork.Id
    AvailabilityZones() []string
    Status() string
    SpaceName() string
    SpaceID() string
    Life() life.Value
}

BackingSubnet defines the methods supported by a Subnet entity stored persistently.

TODO(dimitern): Once the state backing is implemented, remove this and just use *state.Subnet.

type BackingSubnetInfo Uses

type BackingSubnetInfo struct {
    // ProviderId is a provider-specific network id. This may be empty.
    ProviderId corenetwork.Id

    // ProviderNetworkId is the id of the network containing this
    // subnet from the provider's perspective. It can be empty if the
    // provider doesn't support distinct networks.
    ProviderNetworkId corenetwork.Id

    // CIDR of the network, in 123.45.67.89/24 format.
    CIDR string

    // VLANTag needs to be between 1 and 4094 for VLANs and 0 for normal
    // networks. It's defined by IEEE 802.1Q standard.
    VLANTag int

    // AvailabilityZones describes which availability zone(s) this
    // subnet is in. It can be empty if the provider does not support
    // availability zones.
    AvailabilityZones []string

    // SpaceName holds the juju network space this subnet is
    // associated with. Can be empty if not supported.
    SpaceName string
    SpaceID   string

    // Status holds the status of the subnet. Normally this will be
    // calculated from the reference count and Life of a subnet.
    Status string

    // Live holds the life of the subnet
    Life life.Value
}

BackingSubnetInfo describes a single subnet to be added in the backing store.

TODO(dimitern): Replace state.SubnetInfo with this and remove BackingSubnetInfo, once the rest of state backing methods and the following pre-reqs are done: * Subnets need a reference count to calculate Status. * ensure EC2 and MAAS providers accept empty IDs as Subnets() args

and return all subnets, including the AvailabilityZones (for EC2;
empty for MAAS as zones are orthogonal to networks).

type LinkLayerAccessor Uses

type LinkLayerAccessor interface {
    // AllLinkLayerDevices returns all currently known
    // layer-2 devices for the machine.
    AllLinkLayerDevices() ([]LinkLayerDevice, error)

    // AllAddresses returns all IP addresses assigned to the machine's
    // link-layer devices
    AllAddresses() ([]LinkLayerAddress, error)
}

LinkLayerAccessor describes an entity that can return link-layer data related to it.

type LinkLayerAddress Uses

type LinkLayerAddress interface {
    // DeviceName is the name of the device to which this address is assigned.
    DeviceName() string

    // Value returns the actual IP address.
    Value() string

    // Origin indicates the authority that is maintaining this address.
    Origin() network.Origin

    // SetProviderIDOps returns the operations required to set the input
    // provider ID for the address.
    SetProviderIDOps(id network.Id) ([]txn.Op, error)

    // SetOriginOps returns the transaction operations required to change
    // the origin for this address.
    SetOriginOps(origin network.Origin) []txn.Op

    // SetProviderNetIDsOps returns the transaction operations required to ensure
    // that the input provider IDs are set against the address.
    SetProviderNetIDsOps(networkID, subnetID network.Id) []txn.Op

    // RemoveOps returns the transaction operations required to remove this
    // address and if required, its provider ID.
    RemoveOps() []txn.Op

    // UpdateOps returns the transaction operations required to update the device
    // so that it reflects the incoming arguments.
    UpdateOps(state.LinkLayerDeviceAddress) ([]txn.Op, error)
}

LinkLayerAddress describes a single layer-3 network address assigned to a layer-2 device.

type LinkLayerAndSubnetsState Uses

type LinkLayerAndSubnetsState interface {
    LinkLayerState
    AddSubnetsState
}

LinkLayerAndSubnetsState describes a persistence indirection that includes the ability to update link-layer data and add discovered subnets.

type LinkLayerDevice Uses

type LinkLayerDevice interface {
    // MACAddress is the hardware address of the device.
    MACAddress() string

    // Name is the name of the device.
    Name() string

    // ProviderID returns the provider-specific identifier for this device.
    ProviderID() network.Id

    // Type returns the device's type.
    Type() network.LinkLayerDeviceType

    // SetProviderIDOps returns the operations required to set the input
    // provider ID for the link-layer device.
    SetProviderIDOps(id network.Id) ([]txn.Op, error)

    // RemoveOps returns the transaction operations required to remove this
    // device and if required, its provider ID.
    RemoveOps() []txn.Op

    // UpdateOps returns the transaction operations required to update the
    // device so that it reflects the incoming arguments.
    UpdateOps(state.LinkLayerDeviceArgs) []txn.Op

    // AddAddressOps returns transaction operations required
    // to add the input address to the device.
    AddAddressOps(state.LinkLayerDeviceAddress) ([]txn.Op, error)
}

LinkLayerDevice describes a single layer-2 network device.

type LinkLayerMachine Uses

type LinkLayerMachine interface {
    LinkLayerAccessor
    LinkLayerWriter

    // Id returns the ID for the machine.
    Id() string

    // AssertAliveOp returns a transaction operation for asserting
    // that the machine is currently alive.
    AssertAliveOp() txn.Op
}

LinkLayerMachine describes a machine that can return its link-layer data and assert that it is alive in preparation for updating such data.

type LinkLayerState Uses

type LinkLayerState interface {
    // Machine returns the machine for which link-layer data is being set.
    Machine(string) (LinkLayerMachine, error)

    // AllSubnetInfos returns all known model subnets.
    // It is used for correctly setting the subnet
    // of addresses in Fan networks.
    AllSubnetInfos() (network.SubnetInfos, error)

    // ApplyOperation applied the model operation that sets link-layer data.
    ApplyOperation(state.ModelOperation) error
}

LinkLayerState describes methods required for sanitising and persisting link-layer data sourced from a single machine.

type LinkLayerWriter Uses

type LinkLayerWriter interface {
    // AddLinkLayerDeviceOps returns transaction operations for adding the
    // input link-layer device and the supplied addresses to the machine.
    AddLinkLayerDeviceOps(state.LinkLayerDeviceArgs, ...state.LinkLayerDeviceAddress) ([]txn.Op, error)
}

LinkLayerWriter describes an entity that can have link-layer devices added to it.

type MachineLinkLayerOp Uses

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

MachineLinkLayerOp is a base type for model operations that update link-layer data for a single machine/host/container.

func NewMachineLinkLayerOp Uses

func NewMachineLinkLayerOp(machine LinkLayerMachine, incoming network.InterfaceInfos) *MachineLinkLayerOp

NewMachineLinkLayerOp returns a reference that can be embedded in a model operation for updating the input machine's link layer data.

func (*MachineLinkLayerOp) AssertAliveOp Uses

func (o *MachineLinkLayerOp) AssertAliveOp() txn.Op

AssertAliveOp returns a transaction operation for asserting that the machine for which we are updating link-layer data is alive.

func (*MachineLinkLayerOp) ClearProcessed Uses

func (o *MachineLinkLayerOp) ClearProcessed()

ClearProcessed ensures that any record of processed devices and addresses is effectively zeroed. This should be called before each transaction attempt.

func (*MachineLinkLayerOp) DeviceAddresses Uses

func (o *MachineLinkLayerOp) DeviceAddresses(dev LinkLayerDevice) []LinkLayerAddress

DeviceAddresses returns all currently known IP addresses assigned to the input device.

func (*MachineLinkLayerOp) Done Uses

func (o *MachineLinkLayerOp) Done(err error) error

Done (state.ModelOperation) returns the result of running the operation.

func (*MachineLinkLayerOp) ExistingAddresses Uses

func (o *MachineLinkLayerOp) ExistingAddresses() []LinkLayerAddress

ExistingAddresses is a property accessor for the currently known addresses assigned to machine link-layer devices.

func (*MachineLinkLayerOp) ExistingDevices Uses

func (o *MachineLinkLayerOp) ExistingDevices() []LinkLayerDevice

ExistingDevices is a property accessor for the currently known machine link-layer devices.

func (*MachineLinkLayerOp) Incoming Uses

func (o *MachineLinkLayerOp) Incoming() network.InterfaceInfos

Incoming is a property accessor for the link-layer data we are processing.

func (*MachineLinkLayerOp) IsAddrProcessed Uses

func (o *MachineLinkLayerOp) IsAddrProcessed(name, ipAddr string) bool

IsAddrProcessed returns a boolean indicating whether the input incoming device/address pair matches an entry that was marked as processed by the method above.

func (*MachineLinkLayerOp) IsDevProcessed Uses

func (o *MachineLinkLayerOp) IsDevProcessed(dev network.InterfaceInfo) bool

IsDevProcessed returns a boolean indicating whether the input incoming device matches a known device that was marked as processed by the method above.

func (*MachineLinkLayerOp) MarkAddrProcessed Uses

func (o *MachineLinkLayerOp) MarkAddrProcessed(name, ipAddr string)

MarkAddrProcessed indicates that the input (known) IP address was present in the incoming data for the device with input hardware address.

func (*MachineLinkLayerOp) MarkDevProcessed Uses

func (o *MachineLinkLayerOp) MarkDevProcessed(name string)

MarkDevProcessed indicates that the input device name was present in the incoming data and its updates have been handled by the build step.

func (*MachineLinkLayerOp) MatchingIncoming Uses

func (o *MachineLinkLayerOp) MatchingIncoming(dev LinkLayerDevice) *network.InterfaceInfo

MatchingIncoming returns the first incoming interface that matches the input known device based on name. Nil is returned if there is no match.

func (*MachineLinkLayerOp) MatchingIncomingAddrs Uses

func (o *MachineLinkLayerOp) MatchingIncomingAddrs(name string) []state.LinkLayerDeviceAddress

MatchingIncomingAddrs finds all the primary addresses on devices matching the input name, and returns them as state args. TODO (manadart 2020-07-15): We should investigate making an enhanced core/network address type instead of this state type. It would embed ProviderAddress and could be obtained directly via a method or property of InterfaceInfos.

func (*MachineLinkLayerOp) PopulateExistingAddresses Uses

func (o *MachineLinkLayerOp) PopulateExistingAddresses() error

PopulateExistingAddresses retrieves all current link-layer device addresses for the machine.

func (*MachineLinkLayerOp) PopulateExistingDevices Uses

func (o *MachineLinkLayerOp) PopulateExistingDevices() error

PopulateExistingDevices retrieves all current link-layer devices for the machine.

type NetworkBacking Uses

type NetworkBacking interface {
    environs.EnvironConfigGetter

    // AvailabilityZones returns all cached availability zones (i.e.
    // not from the provider, but in state).
    AvailabilityZones() (corenetwork.AvailabilityZones, error)

    // SetAvailabilityZones replaces the cached list of availability
    // zones with the given zones.
    SetAvailabilityZones(corenetwork.AvailabilityZones) error

    // AddSpace creates a space
    AddSpace(string, corenetwork.Id, []string, bool) (BackingSpace, error)

    // AllSpaces returns all known Juju network spaces.
    AllSpaces() ([]BackingSpace, error)

    // AddSubnet creates a backing subnet for an existing subnet.
    AddSubnet(BackingSubnetInfo) (BackingSubnet, error)

    // AllSubnets returns all backing subnets.
    AllSubnets() ([]BackingSubnet, error)

    SubnetByCIDR(cidr string) (BackingSubnet, error)

    // ModelTag returns the tag of the model this state is associated to.
    ModelTag() names.ModelTag
}

NetworkBacking defines the methods needed by the API facade to store and retrieve information from the underlying persistence layer (state DB).

type NetworkConfigAPI Uses

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

func NewNetworkConfigAPI Uses

func NewNetworkConfigAPI(st *state.State, getCanModify common.GetAuthFunc) (*NetworkConfigAPI, error)

NewNetworkConfigAPI constructs a new common network configuration API and returns its reference.

func (*NetworkConfigAPI) SetObservedNetworkConfig Uses

func (api *NetworkConfigAPI) SetObservedNetworkConfig(args params.SetMachineNetworkConfig) error

SetObservedNetworkConfig reads the network config for the machine identified by the input args. This config is merged with the new network config supplied in the same args and updated if it has changed.

Directories

PathSynopsis
mocksPackage mocks is a generated GoMock package.

Package networkingcommon imports 15 packages (graph) and is imported by 180 packages. Updated 2020-09-24. Refresh now. Tools for package owners.