Documentation
¶
Index ¶
- func AddSubnets(api NetworkBacking, args params.AddSubnetsParams) (params.ErrorResults, error)
- func AllZones(api NetworkBacking) (params.ZoneResults, error)
- func BackingSubnetToParamsSubnet(subnet BackingSubnet) params.Subnet
- func CreateSpaces(backing NetworkBacking, args params.CreateSpacesParams) (results params.ErrorResults, err error)
- func GetObservedNetworkConfig(source NetworkConfigSource) ([]params.NetworkConfig, error)
- func ListSubnets(api NetworkBacking, args params.SubnetsFilters) (results params.ListSubnetsResults, err error)
- func MergeProviderAndObservedNetworkConfigs(providerConfigs, observedConfigs []params.NetworkConfig) []params.NetworkConfig
- func NetworkConfigFromInterfaceInfo(interfaceInfos []network.InterfaceInfo) []params.NetworkConfig
- func NetworkConfigsToStateArgs(networkConfig []params.NetworkConfig) ([]state.LinkLayerDeviceArgs, []state.LinkLayerDeviceAddress)
- func NetworkingEnvironFromModelConfig(configGetter environs.EnvironConfigGetter) (environs.NetworkingEnviron, error)
- func NewAddSubnetsCache(api NetworkBacking) *addSubnetsCache
- func NewStateShim(st *state.State) *stateShim
- func SupportsSpaces(backing environs.EnvironConfigGetter) error
- type BackingSpace
- type BackingSubnet
- type BackingSubnetInfo
- type NetworkBacking
- type NetworkConfigSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSubnets ¶
func AddSubnets(api NetworkBacking, args params.AddSubnetsParams) (params.ErrorResults, error)
AddSubnets adds.
func AllZones ¶
func AllZones(api NetworkBacking) (params.ZoneResults, error)
AllZones is defined on the API interface.
func BackingSubnetToParamsSubnet ¶
func BackingSubnetToParamsSubnet(subnet BackingSubnet) params.Subnet
func CreateSpaces ¶
func CreateSpaces(backing NetworkBacking, args params.CreateSpacesParams) (results params.ErrorResults, err error)
CreateSpaces creates a new Juju network space, associating the specified subnets with it (optional; can be empty).
func GetObservedNetworkConfig ¶
func GetObservedNetworkConfig(source NetworkConfigSource) ([]params.NetworkConfig, error)
GetObservedNetworkConfig uses the given source to find all available network interfaces and their assigned addresses, and returns the result as []params.NetworkConfig. In addition to what the source returns, a few additional transformations are done:
- On any OS, the state (UP/DOWN) of each interface and the DeviceIndex field, will be correctly populated. Loopback interfaces are also properly detected and will have InterfaceType set LoopbackInterface.
- On Linux only, the InterfaceType field will be reliably detected for a few types: BondInterface, BridgeInterface, VLAN_8021QInterface.
- Also on Linux, for interfaces that are discovered to be ports on a bridge, the ParentInterfaceName will be populated with the name of the bridge.
- ConfigType fields will be set to ConfigManual when no address is detected, or ConfigStatic when it is.
- TODO: any IPv6 addresses found will be ignored and treated as empty ATM.
Result entries will be grouped by InterfaceName, in the same order they are returned by the given source.
func ListSubnets ¶
func ListSubnets(api NetworkBacking, args params.SubnetsFilters) (results params.ListSubnetsResults, err error)
ListSubnets lists all the available subnets or only those matching all given optional filters.
func MergeProviderAndObservedNetworkConfigs ¶
func MergeProviderAndObservedNetworkConfigs(providerConfigs, observedConfigs []params.NetworkConfig) []params.NetworkConfig
MergeProviderAndObservedNetworkConfigs returns the effective network configs, using observedConfigs as a base and selectively updating it using the matching providerConfigs for each interface.
func NetworkConfigFromInterfaceInfo ¶
func NetworkConfigFromInterfaceInfo(interfaceInfos []network.InterfaceInfo) []params.NetworkConfig
NetworkConfigFromInterfaceInfo converts a slice of network.InterfaceInfo into the equivalent params.NetworkConfig slice.
func NetworkConfigsToStateArgs ¶
func NetworkConfigsToStateArgs(networkConfig []params.NetworkConfig) ( []state.LinkLayerDeviceArgs, []state.LinkLayerDeviceAddress, )
NetworkConfigsToStateArgs splits the given networkConfig into a slice of state.LinkLayerDeviceArgs and a slice of state.LinkLayerDeviceAddress. The input is expected to come from MergeProviderAndObservedNetworkConfigs and to be sorted.
func NetworkingEnvironFromModelConfig ¶
func NetworkingEnvironFromModelConfig(configGetter environs.EnvironConfigGetter) (environs.NetworkingEnviron, error)
NetworkingEnvironFromModelConfig constructs and returns environs.NetworkingEnviron using the given configGetter. Returns an error satisfying errors.IsNotSupported() if the model config does not support networking features.
func NewAddSubnetsCache ¶
func NewAddSubnetsCache(api NetworkBacking) *addSubnetsCache
func NewStateShim ¶
func SupportsSpaces ¶
func SupportsSpaces(backing environs.EnvironConfigGetter) error
SupportsSpaces checks if the environment implements NetworkingEnviron and also if it supports spaces.
Types ¶
type BackingSpace ¶
type BackingSpace interface { // 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() network.Id // Zones returns a list of availability zone(s) that this // space is in. It can be empty if the provider does not support // availability zones. Zones() []string // Life returns the lifecycle state of the space Life() params.Life }
BackingSpace defines the methods supported by a Space entity stored persistently.
type BackingSubnet ¶
type BackingSubnet interface { CIDR() string VLANTag() int ProviderId() network.Id AvailabilityZones() []string Status() string SpaceName() string Life() params.Life }
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 ¶
type BackingSubnetInfo struct { // ProviderId is a provider-specific network id. This may be empty. ProviderId network.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 // 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 params.Life }
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:
- subnetDoc.AvailabilityZone becomes subnetDoc.AvailabilityZones, adding an upgrade step to migrate existing non empty zones on subnet docs. Also change state.Subnet.AvailabilityZone to
- add subnetDoc.SpaceName - no upgrade step needed, as it will only be used for new space-aware subnets.
- 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 NetworkBacking ¶
type NetworkBacking interface { environs.EnvironConfigGetter // AvailabilityZones returns all cached availability zones (i.e. // not from the provider, but in state). AvailabilityZones() ([]providercommon.AvailabilityZone, error) // SetAvailabilityZones replaces the cached list of availability // zones with the given zones. SetAvailabilityZones([]providercommon.AvailabilityZone) error // AddSpace creates a space AddSpace(Name string, ProviderId network.Id, Subnets []string, Public bool) 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) // ModelTag returns the tag of the model this state is associated to. ModelTag() names.ModelTag }
Backing defines the methods needed by the API facade to store and retrieve information from the underlying persistency layer (state DB).
type NetworkConfigSource ¶
type NetworkConfigSource interface { // SysClassNetPath returns the Linux kernel userspace SYSFS path used by // this source. DefaultNetworkConfigSource() uses network.SysClassNetPath. SysClassNetPath() string // Interfaces returns information about all network interfaces on the // machine as []net.Interface. Interfaces() ([]net.Interface, error) // InterfaceAddresses returns information about all addresses assigned to // the network interface with the given name. InterfaceAddresses(name string) ([]net.Addr, error) }
NetworkConfigSource defines the necessary calls to obtain the network configuration of a machine.
func DefaultNetworkConfigSource ¶
func DefaultNetworkConfigSource() NetworkConfigSource
DefaultNetworkConfigSource returns a NetworkConfigSource backed by the net package, to be used with GetObservedNetworkConfig().