Documentation ¶
Index ¶
- Constants
- Variables
- func APIHostPortsToNoProxyString(ahp [][]HostPort) string
- func CalculateOverlaySegment(underlayCIDR string, fan FanConfigEntry) (*net.IPNet, error)
- func ConvertSpaceName(name string, existing set.Strings) string
- func DecimalToIPv4(addr uint32) net.IP
- func ExactScopeMatch(addr Address, addrScopes ...Scope) bool
- func FormatAsCIDR(addresses []string) ([]string, error)
- func GetBridgePorts(sysPath, bridgeName string) []string
- func GetDefaultRoute() (net.IP, string, error)
- func HostPortsToStrings(hps []HostPort) []string
- func IPv4ToDecimal(ipv4Addr net.IP) (uint32, error)
- func IsNoAddressError(err error) bool
- func NaturallySortDeviceNames(names ...string) []string
- func NoAddressError(addressKind string) error
- func PrioritizeInternalHostPorts(hps []HostPort, machineLocal bool) []string
- func QuoteSpaceSet(vals set.Strings) string
- func QuoteSpaces(vals []string) string
- func SelectInternalHostPort(hps []HostPort, machineLocal bool) string
- func SelectInternalHostPorts(hps []HostPort, machineLocal bool) []string
- func SelectPublicHostPort(hps []HostPort) string
- func SortAddresses(addrs []Address)
- func SortHostPorts(hps []HostPort)
- func SortIngressRules(IngressRules []IngressRule)
- func SortInterfaceInfo(interfaces []InterfaceInfo)
- func SubnetInAnyRange(cidrs []*net.IPNet, subnet *net.IPNet) bool
- func SupportsIPv6() bool
- type Address
- func FilterBridgeAddresses(addresses []Address) []Address
- func HostsWithoutPort(hps []HostPort) []Address
- func MergedAddresses(machineAddresses, providerAddresses []Address) []Address
- func NewAddress(value string) Address
- func NewAddressOnSpace(spaceName string, value string) Address
- func NewAddresses(inAddresses ...string) (outAddresses []Address)
- func NewAddressesOnSpace(spaceName string, inAddresses ...string) (outAddresses []Address)
- func NewScopedAddress(value string, scope Scope) Address
- func ResolvableHostnames(addrs []Address) []Address
- func SelectAddressesBySpaceNames(addresses []Address, spaceNames ...SpaceName) ([]Address, bool)
- func SelectControllerAddress(addresses []Address, machineLocal bool) (Address, bool)
- func SelectInternalAddress(addresses []Address, machineLocal bool) (Address, bool)
- func SelectInternalAddresses(addresses []Address, machineLocal bool) []Address
- func SelectPublicAddress(addresses []Address) (Address, bool)
- type AddressType
- type Bridger
- type DNSConfig
- type DeviceToBridge
- type FanConfig
- type FanConfigEntry
- type HostPort
- func AddressesWithPort(addrs []Address, port int) []HostPort
- func CollapseHostPorts(serversHostPorts [][]HostPort) []HostPort
- func EnsureFirstHostPort(first HostPort, hps []HostPort) []HostPort
- func FilterUnusableHostPorts(hps []HostPort) []HostPort
- func NewHostPorts(port int, addresses ...string) []HostPort
- func ParseHostPort(hp string) (*HostPort, error)
- func ParseHostPorts(hostPorts ...string) ([]HostPort, error)
- func ResolveOrDropHostnames(hps []HostPort) []HostPort
- func SelectHostPortsBySpaceNames(hps []HostPort, spaceNames ...SpaceName) ([]HostPort, bool)
- func UniqueHostPorts(hostPorts []HostPort) []HostPort
- type Id
- type IngressRule
- type IngressRuleSlice
- type InterfaceAddress
- type InterfaceConfigType
- type InterfaceInfo
- type InterfaceType
- type NetworkInfo
- type ProviderInterfaceInfo
- type Route
- type Scope
- type ScriptResult
- type SpaceInfo
- type SpaceName
- type SubnetInfo
Constants ¶
const ( // LoopbackIPv4CIDR is the loopback CIDR range for IPv4. LoopbackIPv4CIDR = "127.0.0.0/8" // LoopbackIPv6CIDR is the loopback CIDR range for IPv6. LoopbackIPv6CIDR = "::1/128" )
const ( EOF = iota LITERAL NUMBER )
const DefaultKVMBridge = "virbr0"
DefaultKVMBridge is the bridge that is set up by installing libvirt-bin Note: we don't import this from 'container' to avoid import loops
const DefaultLXCBridge = "lxcbr0"
DefaultLXCBridge is the bridge that gets used for LXC containers
const DefaultLXDBridge = "lxdbr0"
DefaultLXDBridge is the bridge that gets used for LXD containers
const SysClassNetPath = "/sys/class/net"
SysClassNetRoot is the full Linux SYSFS path containing information about each network interface on the system. Used as argument to ParseInterfaceType().
const UnknownId = ""
UnknownId can be used whenever an Id is needed but not known.
Variables ¶
var GenerateVirtualMACAddress = func() string { digits := make([]interface{}, 3) for i := range digits { digits[i] = rand.Intn(256) } return fmt.Sprintf(macAddressTemplate, digits...) }
GenerateVirtualMACAddress creates a random MAC address within the address space implied by macAddressTemplate above.
var InterfaceByNameAddrs = func(name string) ([]net.Addr, error) { iface, err := net.InterfaceByName(name) if err != nil { return nil, err } return iface.Addrs() }
InterfaceByNameAddrs returns the addresses for the given interface name. It's exported to facilitate cross-package testing.
var LXCNetDefaultConfig = "/etc/default/lxc-net"
LXCNetDefaultConfig is the location of the default network config of the lxc package. It's exported to allow cross-package testing.
var ResolverFunc = net.ResolveIPAddr
Export for testing
var SpaceInvalidChars = regexp.MustCompile("[^0-9a-z-]")
SpaceInvalidChars is a regexp for validating that space names contain no invalid characters.
Functions ¶
func APIHostPortsToNoProxyString ¶
APIHostPortsToNoProxyString converts list of lists of NetAddrs() to a NoProxy-like comma separated string, ignoring local addresses
func CalculateOverlaySegment ¶
func CalculateOverlaySegment(underlayCIDR string, fan FanConfigEntry) (*net.IPNet, error)
CalculateOverlaySegment takes underlay CIDR and FAN config entry and cuts the segment of overlay that corresponds to this underlay: eg. for FAN 172.31/16 -> 243/8 and physical subnet 172.31.64/20 we get FAN subnet 243.64/12.
func ConvertSpaceName ¶
ConvertSpaceName converts names between provider space names and valid juju space names. TODO(mfoord): once MAAS space name rules are in sync with juju space name rules this can go away.
func DecimalToIPv4 ¶
DecimalToIPv4 converts a decimal to the dotted quad IP address format.
func ExactScopeMatch ¶
ExactScopeMatch checks if an address exactly matches any of the specified scopes.
func FormatAsCIDR ¶
FormatAsCIDR converts the specified IP addresses to a slice of CIDRs. It attempts to resolve any address represented as hostnames before formatting.
func GetBridgePorts ¶
GetBridgePorts extracts and returns the names of all interfaces configured as ports of the given bridgeName from the Linux kernel userspace SYSFS location "<sysPath/<bridgeName>/brif/*". SysClassNetPath should be passed as sysPath. Returns an empty result if the ports cannot be determined reliably for any reason, or if there are no configured ports for the bridge.
Example call: network.GetBridgePorts(network.SysClassNetPath, "br-eth1")
func GetDefaultRoute ¶
GetDefaultRoute returns the IP address and device name of default gateway on the machine. If we don't support OS, or we don't have a default route, we return nothing (not an error!).
func HostPortsToStrings ¶
HostPortsToStrings converts each HostPort to string calling its NetAddr() method.
func IPv4ToDecimal ¶
IPv4ToDecimal converts a dotted quad IP address to its decimal equivalent.
func IsNoAddressError ¶
IsNoAddressError reports whether err was created with NoAddressError().
func NaturallySortDeviceNames ¶
NaturallySortDeviceNames returns an ordered list of names based on a natural ordering where 'natural' is an ordering of the string value in alphabetical order, execept that multi-digit numbers are ordered as a single character.
For example, sorting:
[ br-eth10 br-eth1 br-eth2 ]
would sort as:
[ br-eth1 br-eth2 br-eth10 ]
In purely alphabetical sorting "br-eth10" would be sorted before "br-eth2" because "1" is sorted as smaller than "2", while in natural sorting "br-eth2" is sorted before "br-eth10" because "2" is sorted as smaller than "10".
This also extends to multiply repeated numbers (e.g., VLANs).
For example, sorting:
[ br-eth2 br-eth10.10 br-eth200.0 br-eth1.0 br-eth2.0 ]
would sort as:
[ br-eth1.0 br-eth2 br-eth2.0 br-eth10.10 br-eth200.0 ]
func NoAddressError ¶
NoAddressError returns an error which satisfies IsNoAddressError(). The given addressKind specifies what kind of address(es) is(are) missing, usually "private" or "public".
func PrioritizeInternalHostPorts ¶
PrioritizeInternalHostPorts orders the provided addresses by best match for use as an endpoint for juju internal communication and returns them in NetAddr form. If there are no suitable addresses then an empty slice is returned.
func QuoteSpaceSet ¶
QuoteSpaceSet is the same as QuoteSpaces, but ensures that a set.Strings gets sorted values output.
func QuoteSpaces ¶
QuoteSpaces takes a slice of space names, and returns a nicely formatted form so they show up legible in log messages, etc.
func SelectInternalHostPort ¶
SelectInternalHostPort picks one HostPort from a slice that can be used as an endpoint for juju internal communication and returns it in its NetAddr form. If there are no suitable addresses, the empty string is returned.
func SelectInternalHostPorts ¶
SelectInternalHostPorts picks the best matching HostPorts from a slice that can be used as an endpoint for juju internal communication and returns them in NetAddr form. If there are no suitable addresses, an empty slice is returned.
func SelectPublicHostPort ¶
SelectPublicHostPort picks one HostPort from a slice that would be appropriate to display as a publicly accessible endpoint. If there are no suitable candidates, the empty string is returned.
func SortAddresses ¶
func SortAddresses(addrs []Address)
SortAddresses sorts the given Address slice according to the sortOrder of each address. See Address.sortOrder() for more info.
func SortHostPorts ¶
func SortHostPorts(hps []HostPort)
SortHostPorts sorts the given HostPort slice according to the sortOrder of each HostPort's embedded Address. See Address.sortOrder() for more info.
func SortIngressRules ¶
func SortIngressRules(IngressRules []IngressRule)
SortIngressRules sorts the given rules, first by protocol, then by ports.
func SortInterfaceInfo ¶
func SortInterfaceInfo(interfaces []InterfaceInfo)
SortInterfaceInfo sorts a slice of InterfaceInfo on DeviceIndex in ascending order.
func SubnetInAnyRange ¶
SubnetInAnyRange returns true if the subnet's address range is fully contained in any of the specified subnet blocks.
func SupportsIPv6 ¶
func SupportsIPv6() bool
SupportsIPv6 reports whether the platform supports IPv6 networking functionality.
Source: https://github.com/golang/net/blob/master/internal/nettest/stack.go
Types ¶
type Address ¶
type Address struct { Value string Type AddressType Scope SpaceName SpaceProviderId Id }
Address represents the location of a machine, including metadata about what kind of location the address describes.
func FilterBridgeAddresses ¶
FilterBridgeAddresses removes addresses seen as a Bridge address (the IP address used only to connect to local containers), rather than a remote accessible address.
func HostsWithoutPort ¶
HostsWithoutPort strips the port from each HostPort, returning just the addresses.
func MergedAddresses ¶
MergedAddresses provides a single list of addresses without duplicates suitable for returning as an address list for a machine. TODO (cherylj) Add explicit unit tests - tracked with bug #1544158
func NewAddress ¶
NewAddress creates a new Address, deriving its type from the value and using ScopeUnknown as scope. It's a shortcut to calling NewScopedAddress(value, ScopeUnknown).
func NewAddressOnSpace ¶
NewAddressOnSpace creates a new Address, deriving its type and scope from the value and associating it with the given spaceName.
func NewAddresses ¶
NewAddresses is a convenience function to create addresses from a variable number of string arguments.
func NewAddressesOnSpace ¶
NewAddressesOnSpace is a convenience function to create addresses on the same space, from a a variable number of string arguments.
func NewScopedAddress ¶
NewScopedAddress creates a new Address, deriving its type from the value.
If the specified scope is ScopeUnknown, then NewScopedAddress will attempt derive the scope based on reserved IP address ranges. Because passing ScopeUnknown is fairly common, NewAddress() above does exactly that.
func ResolvableHostnames ¶
ResolvableHostnames returns the set of all DNS resolvable names from addrs. Note that 'localhost' is always considered resolvable because it can be used both as an IPv4 or IPv6 endpoint (e.g., in IPv6-only networks).
func SelectAddressesBySpaceNames ¶
SelectAddressesBySpaceNames filters the input slice of Addresses down to those in the input space names.
func SelectControllerAddress ¶
SelectControllerAddress returns the most suitable address to use as a Juju Controller (API/state server) endpoint given the list of addresses. The second return value is false when no address can be returned. When machineLocal is true both ScopeCloudLocal and ScopeMachineLocal addresses are considered during the selection, otherwise just ScopeCloudLocal are.
func SelectInternalAddress ¶
SelectInternalAddress picks one address from a slice that can be used as an endpoint for juju internal communication. If there are no suitable addresses, then ok is false (and an empty address is returned). If a suitable address was found then ok is true.
func SelectInternalAddresses ¶
SelectInternalAddresses picks the best addresses from a slice that can be used as an endpoint for juju internal communication. I nil slice is returned if there are no suitable addresses identified.
func SelectPublicAddress ¶
SelectPublicAddress picks one address from a slice that would be appropriate to display as a publicly accessible endpoint. If there are no suitable addresses, then ok is false (and an empty address is returned). If a suitable address is then ok is true.
func (Address) String ¶
String returns a string representation of the address, in the form: `<scope>:<address-value>@<space-name>(id:<space-provider-id)`; for example:
public:c2-54-226-162-124.compute-1.amazonaws.com@public-api(id:42)
If the scope is ScopeUnknown, the initial "<scope>:" prefix will be omitted. If the SpaceName is blank, the "@<space-name>" suffix will be omitted. Finally, if the SpaceProviderId is empty the suffix "(id:<space-provider-id>)" part will be omitted as well.
type AddressType ¶
type AddressType string
AddressType represents the possible ways of specifying a machine location by either a hostname resolvable by dns lookup, or IPv4 or IPv6 address.
const ( HostName AddressType = "hostname" IPv4Address AddressType = "ipv4" IPv6Address AddressType = "ipv6" )
func DeriveAddressType ¶
func DeriveAddressType(value string) AddressType
DeriveAddressType attempts to detect the type of address given.
type Bridger ¶
type Bridger interface { // Turns existing devices into bridged devices. // TODO(frobware) - we may want a different type to encompass // and reflect how bridging should be done vis-a-vis what // needs to be bridged. Bridge(devices []DeviceToBridge, reconfigureDelay int) error }
Bridger creates network bridges to support addressable containers.
func DefaultEtcNetworkInterfacesBridger ¶
DefaultEtcNetworkInterfacesBridger returns a Bridger instance that can parse an interfaces(5) to transform existing devices into bridged devices.
type DNSConfig ¶
DNSConfig holds a list of DNS nameserver addresses and default search domains.
func ParseResolvConf ¶
ParseResolvConf parses a resolv.conf(5) file at the given path (usually "/etc/resolv.conf"), if present. Returns the values of any 'nameserver' stanzas, and the last 'search' stanza found. Values in the result will appear in the order found, including duplicates. Parsing errors will be returned in these cases:
- if a 'nameserver' or 'search' without a value is found;
- 'nameserver' with more than one value (trailing comments starting with '#' or ';' after the value are allowed).
- if any value containing '#' or ';' (e.g. 'nameserver 8.8.8.8#bad'), because values and comments following them must be separated by whitespace.
No error is returned if the file is missing. See resolv.conf(5) man page for details.
type DeviceToBridge ¶
type DeviceToBridge struct { // DeviceName is the name of the device on the machine that should // be bridged. DeviceName string // BridgeName is the name of the bridge that we want created. BridgeName string // MACAddress is the MAC address of the device to be bridged MACAddress string }
DeviceToBridge gives the information about a particular device that should be bridged.
type FanConfig ¶
type FanConfig []FanConfigEntry
FanConfig defines a set of fan configurations for the model.
func ParseFanConfig ¶
ParseFanConfig parses fan configuration from model-config in the format: "underlay1=overlay1 underlay2=overlay2" eg. "172.16.0.0/16=253.0.0.0/8 10.0.0.0/12:254.0.0.0/7"
type FanConfigEntry ¶
FanConfigEntry defines a configuration for single fan.
type HostPort ¶
HostPort associates an address with a port.
func AddressesWithPort ¶
AddressesWithPort returns the given addresses all associated with the given port.
func CollapseHostPorts ¶
CollapseHostPorts returns a flattened list of HostPorts keeping the same order they appear in serversHostPorts.
func EnsureFirstHostPort ¶
EnsureFirstHostPort scans the given list of HostPorts and if "first" is found, it moved to index 0. Otherwise, if "first" is not in the list, it's inserted at index 0.
func FilterUnusableHostPorts ¶
FilterUnusableHostPorts returns a copy of the given HostPorts after removing any addresses unlikely to be usable (ScopeMachineLocal or ScopeLinkLocal).
func NewHostPorts ¶
NewHostPorts creates a list of HostPorts from each given string address and port.
func ParseHostPort ¶
ParseHostPort converts a string containing a single host and port value to a HostPort.
func ParseHostPorts ¶
ParseHostPorts creates a list of HostPorts parsing each given string containing address:port. An error is returned if any string cannot be parsed as HostPort.
func ResolveOrDropHostnames ¶
ResolveOrDropHostnames tries to resolve each address of type HostName (except for "localhost" - it's kept unchanged) using the local resolver. If successful, each IP address corresponding to the hostname is inserted in the same order. If not successful, a debug log is added and the hostname is removed from the list. Duplicated addresses after the resolving is done are removed.
func SelectHostPortsBySpaceNames ¶
SelectHostPortsBySpaceNames filters the input slice of HostPorts down to those in the input space names.
func UniqueHostPorts ¶
UniqueHostPorts returns the given hostPorts after filtering out any duplicates, preserving the input order.
func (HostPort) Less ¶
Less reports whether hp1 is ordered before hp2 according to the criteria used by SortHostPorts.
type Id ¶
type Id string
Id defines a provider-specific network id.
const AnySubnet Id = ""
AnySubnet when passed as a subnet id should be interpreted by the providers as "the subnet id does not matter". It's up to the provider how to handle this case - it might return an error.
type IngressRule ¶
type IngressRule struct { // PortRange is the range of ports for which incoming // packets are allowed. network.PortRange // SourceCIDRs is a list of IP address blocks expressed in CIDR format // to which this rule applies. SourceCIDRs []string }
IngressRule represents a range of ports and sources from which to allow ingress by incoming packets.
func MustNewIngressRule ¶
func MustNewIngressRule(protocol string, from, to int, sourceCIDRs ...string) IngressRule
MustNewIngressRule returns an IngressRule for the specified port range. If no explicit source ranges are specified, there is no restriction from where incoming traffic originates. The method will panic if there is an error.
func NewIngressRule ¶
func NewIngressRule(protocol string, from, to int, sourceCIDRs ...string) (IngressRule, error)
NewIngressRule returns an IngressRule for the specified port range. If no explicit source ranges are specified, there is no restriction from where incoming traffic originates.
func NewOpenIngressRule ¶
func NewOpenIngressRule(protocol string, from, to int) IngressRule
NewOpenIngressRule returns an IngressRule for the specified port range. There is no restriction from where incoming traffic originates.
func (IngressRule) GoString ¶
func (r IngressRule) GoString() string
GoString is used to print values passed as an operand to a %#v format.
func (IngressRule) String ¶
func (r IngressRule) String() string
String is the string representation of IngressRule.
type IngressRuleSlice ¶
type IngressRuleSlice []IngressRule
func (IngressRuleSlice) Len ¶
func (p IngressRuleSlice) Len() int
func (IngressRuleSlice) Less ¶
func (p IngressRuleSlice) Less(i, j int) bool
func (IngressRuleSlice) Swap ¶
func (p IngressRuleSlice) Swap(i, j int)
type InterfaceAddress ¶
InterfaceAddress represents a single address attached to the interface.
type InterfaceConfigType ¶
type InterfaceConfigType string
InterfaceConfigType defines valid network interface configuration types. See interfaces(5) for details
const ( ConfigUnknown InterfaceConfigType = "" ConfigDHCP InterfaceConfigType = "dhcp" ConfigStatic InterfaceConfigType = "static" ConfigManual InterfaceConfigType = "manual" ConfigLoopback InterfaceConfigType = "loopback" )
type InterfaceInfo ¶
type InterfaceInfo struct { // DeviceIndex specifies the order in which the network interface // appears on the host. The primary interface has an index of 0. DeviceIndex int // MACAddress is the network interface's hardware MAC address // (e.g. "aa:bb:cc:dd:ee:ff"). MACAddress string // CIDR of the network, in 123.45.67.89/24 format. CIDR string // ProviderId is a provider-specific NIC id. ProviderId Id // ProviderSubnetId is the provider-specific id for the associated // subnet. ProviderSubnetId Id // ProviderNetworkId is the provider-specific id for the // associated network. ProviderNetworkId Id // ProviderSpaceId is the provider-specific id for the associated space, if // known and supported. ProviderSpaceId Id // ProviderVLANId is the provider-specific id of the VLAN for this // interface. ProviderVLANId Id // ProviderAddressId is the provider-specific id of the assigned address. ProviderAddressId Id // AvailabilityZones describes the availability zones the associated // subnet is in. AvailabilityZones []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 // InterfaceName is the raw OS-specific network device name (e.g. // "eth1", even for a VLAN eth1.42 virtual interface). InterfaceName string // ParentInterfaceName is the name of the parent interface to use, if known. ParentInterfaceName string // InterfaceType is the type of the interface. InterfaceType InterfaceType // Disabled is true when the interface needs to be disabled on the // machine, e.g. not to configure it. Disabled bool // NoAutoStart is true when the interface should not be configured // to start automatically on boot. By default and for // backwards-compatibility, interfaces are configured to // auto-start. NoAutoStart bool // ConfigType determines whether the interface should be // configured via DHCP, statically, manually, etc. See // interfaces(5) for more information. ConfigType InterfaceConfigType // Address contains an optional static IP address to configure for // this network interface. The subnet mask to set will be inferred // from the CIDR value. Address Address // DNSServers contains an optional list of IP addresses and/or // hostnames to configure as DNS servers for this network // interface. DNSServers []Address // MTU is the Maximum Transmission Unit controlling the maximum size of the // protocol packats that the interface can pass through. It is only used // when > 0. MTU int // DNSSearchDomains contains the default DNS domain to use for non-FQDN // lookups. DNSSearchDomains []string // Gateway address, if set, defines the default gateway to // configure for this network interface. For containers this // usually is (one of) the host address(es). GatewayAddress Address // Routes defines a list of routes that should be added when this interface // is brought up, and removed when this interface is stopped. Routes []Route // IsDefaultGateway is set if this device is a default gw on a machine. IsDefaultGateway bool }
InterfaceInfo describes a single network interface available on an instance. For providers that support networks, this will be available at StartInstance() time. TODO(mue): Rename to InterfaceConfig due to consistency later.
func (*InterfaceInfo) ActualInterfaceName ¶
func (i *InterfaceInfo) ActualInterfaceName() string
ActualInterfaceName returns raw interface name for raw interface (e.g. "eth0") and virtual interface name for virtual interface (e.g. "eth0.42")
func (*InterfaceInfo) CIDRAddress ¶
func (i *InterfaceInfo) CIDRAddress() string
CIDRAddress returns Address.Value combined with CIDR mask.
func (*InterfaceInfo) IsVLAN ¶
func (i *InterfaceInfo) IsVLAN() bool
IsVLAN returns true when the interface is a VLAN interface.
func (*InterfaceInfo) IsVirtual ¶
func (i *InterfaceInfo) IsVirtual() bool
IsVirtual returns true when the interface is a virtual device, as opposed to a physical device (e.g. a VLAN or a network alias)
type InterfaceType ¶
type InterfaceType string
InterfaceType defines valid network interface types.
const ( UnknownInterface InterfaceType = "" LoopbackInterface InterfaceType = "loopback" EthernetInterface InterfaceType = "ethernet" VLAN_8021QInterface InterfaceType = "802.1q" BondInterface InterfaceType = "bond" BridgeInterface InterfaceType = "bridge" )
func ParseInterfaceType ¶
func ParseInterfaceType(sysPath, interfaceName string) InterfaceType
ParseInterfaceType parses the DEVTYPE attribute from the Linux kernel userspace SYSFS location "<sysPath/<interfaceName>/uevent" and returns it as InterfaceType. SysClassNetPath should be passed as sysPath. Returns UnknownInterface if the type cannot be reliably determined for any reason.
Example call: network.ParseInterfaceType(network.SysClassNetPath, "br-eth1")
type NetworkInfo ¶
type NetworkInfo struct { // MACAddress is the network interface's hardware MAC address // (e.g. "aa:bb:cc:dd:ee:ff"). MACAddress string // InterfaceName is the OS-specific interface name, eg. "eth0" or "eno1.412" InterfaceName string // Addresses contains a list of addresses configured on the interface. Addresses []InterfaceAddress }
NetworkInfo describes one interface with assigned IP addresses, it's a mirror of params.NetworkInfo.
type ProviderInterfaceInfo ¶
type ProviderInterfaceInfo struct { // InterfaceName is the raw OS-specific network device name (e.g. // "eth1", even for a VLAN eth1.42 virtual interface). InterfaceName string // ProviderId is a provider-specific NIC id. ProviderId Id // MACAddress is the network interface's hardware MAC address // (e.g. "aa:bb:cc:dd:ee:ff"). MACAddress string }
ProviderInterfaceInfo holds enough information to identify an interface or link layer device to a provider so that it can be queried or manipulated. Its initial purpose is to pass to provider.ReleaseContainerAddresses.
type Route ¶
type Route struct { // DestinationCIDR is the subnet that we want a controlled route to. DestinationCIDR string // GatewayIP is the IP (v4 or v6) that should be used for traffic that is // bound for DestinationCIDR GatewayIP string // Metric is the weight to apply to this route. Metric int }
Route defines a single route to a subnet via a defined gateway.
type Scope ¶
type Scope string
Scope denotes the context a location may apply to. If a name or address can be reached from the wider internet, it is considered public. A private network address is either specific to the cloud or cloud subnet a machine belongs to, or to the machine itself for containers.
type SpaceInfo ¶
type SpaceInfo struct { Name string ProviderId Id Subnets []SubnetInfo }
type SubnetInfo ¶
type SubnetInfo struct { // CIDR of the network, in 123.45.67.89/24 format. Can be empty if // unknown. CIDR string // ProviderId is a provider-specific subnet id. This the only // required field. ProviderId Id // VLANTag needs to be between 1 and 4094 for VLANs and 0 for // normal networks. It's defined by IEEE 802.1Q standard, and used // to define a VLAN network. For more information, see: // http://en.wikipedia.org/wiki/IEEE_802.1Q. 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 // SpaceProviderId holds the provider Id of the space associated // with this subnet. Can be empty if not supported. // TODO(babbageclunk): change this to ProviderSpaceId to be // consistent with the InterfaceInfo.Provider*Id fields. SpaceProviderId Id // ProviderNetworkId holds the provider id of the network // containing this subnet, for example VPC id for EC2. ProviderNetworkId Id }
SubnetInfo describes the bare minimum information for a subnet, which the provider knows about but juju might not yet.