network

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	EOF = iota
	LITERAL
	NUMBER
)
View Source
const DefaultLXDBridge = "lxdbr0"

DefaultLXDBridge is the bridge that gets used for LXD containers

View Source
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().

View Source
const UnknownId = ""

UnknownId can be used whenever an Id is needed but not known.

Variables

View Source
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.

View Source
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.

View Source
var SpaceInvalidChars = regexp.MustCompile("[^0-9a-z-]")

SpaceInvalidChars is a regexp for validating that space names contain no invalid characters.

Functions

func ConvertSpaceName

func ConvertSpaceName(name string, existing set.Strings) string

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

func DecimalToIPv4(addr uint32) net.IP

DecimalToIPv4 converts a decimal to the dotted quad IP address format.

func ExactScopeMatch

func ExactScopeMatch(addr Address, addrScopes ...Scope) bool

ExactScopeMatch checks if an address exactly matches any of the specified scopes.

func GetBridgePorts

func GetBridgePorts(sysPath, bridgeName string) []string

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 HostPortsToStrings

func HostPortsToStrings(hps []HostPort) []string

HostPortsToStrings converts each HostPort to string calling its NetAddr() method.

func IPv4ToDecimal

func IPv4ToDecimal(ipv4Addr net.IP) (uint32, error)

IPv4ToDecimal converts a dotted quad IP address to its decimal equivalent.

func IsNoAddressError

func IsNoAddressError(err error) bool

IsNoAddressError reports whether err was created with NoAddressError().

func NaturallySortDeviceNames

func NaturallySortDeviceNames(names ...string) []string

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

func NoAddressError(addressKind string) error

NoAddressError returns an error which satisfies IsNoAddressError(). The given addressKind specifies what kind of address is missing, usually "private" or "public".

func PrioritizeInternalHostPorts

func PrioritizeInternalHostPorts(hps []HostPort, machineLocal bool) []string

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 SelectInternalHostPort

func SelectInternalHostPort(hps []HostPort, machineLocal bool) string

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

func SelectInternalHostPorts(hps []HostPort, machineLocal bool) []string

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 SelectMongoHostPortsByScope

func SelectMongoHostPortsByScope(hostPorts []HostPort, machineLocal bool) []string

func SelectMongoHostPortsBySpaces

func SelectMongoHostPortsBySpaces(hostPorts []HostPort, spaces []SpaceName) ([]string, bool)

SelectMongoHostPorts returns the most suitable HostPort (as string) to use as a Juju Controller (API/state server) endpoint given the list of hostPorts. It first tries to find the first HostPort bound to the spaces provided, then, if that fails, uses the older selection method based on scope. When machineLocal is true and an address can't be selected by space both ScopeCloudLocal and ScopeMachineLocal addresses are considered during the selection, otherwise just ScopeCloudLocal are.

func SelectPublicHostPort

func SelectPublicHostPort(hps []HostPort) string

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 SortInterfaceInfo

func SortInterfaceInfo(interfaces []InterfaceInfo)

SortInterfaceInfo sorts a slice of InterfaceInfo on DeviceIndex in ascending order.

func SortPortRanges

func SortPortRanges(portRanges []PortRange)

SortPortRanges sorts the given ports, first by protocol, then by number.

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

func FilterBridgeAddresses(addresses []Address) []Address

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

func HostsWithoutPort(hps []HostPort) []Address

HostsWithoutPort strips the port from each HostPort, returning just the addresses.

func MergedAddresses

func MergedAddresses(machineAddresses, providerAddresses []Address) []Address

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

func NewAddress(value string) Address

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

func NewAddressOnSpace(spaceName string, value string) Address

NewAddressOnSpace creates a new Address, deriving its type and scope from the value and associating it with the given spaceName.

func NewAddresses

func NewAddresses(inAddresses ...string) (outAddresses []Address)

NewAddresses is a convenience function to create addresses from a a variable number of string arguments.

func NewAddressesOnSpace

func NewAddressesOnSpace(spaceName string, inAddresses ...string) (outAddresses []Address)

NewAddressesOnSpace is a convenience function to create addresses on the same space, from a a variable number of string arguments.

func NewScopedAddress

func NewScopedAddress(value string, scope Scope) Address

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

func ResolvableHostnames(addrs []Address) []Address

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 SelectAddressBySpaces

func SelectAddressBySpaces(addresses []Address, spaceNames ...SpaceName) (Address, bool)

SelectAddressBySpaces picks the first address from the given slice that has the given space name associated.

func SelectControllerAddress

func SelectControllerAddress(addresses []Address, machineLocal bool) (Address, bool)

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

func SelectInternalAddress(addresses []Address, machineLocal bool) (Address, bool)

SelectInternalAddress picks one address from a slice that can be used as an endpoint for juju internal communication. If there are 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 SelectPublicAddress

func SelectPublicAddress(addresses []Address) (Address, bool)

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) GoString

func (a Address) GoString() string

GoString implements fmt.GoStringer.

func (Address) String

func (a Address) String() 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 BySpaceName

type BySpaceName []SpaceInfo

func (BySpaceName) Len

func (s BySpaceName) Len() int

func (BySpaceName) Less

func (s BySpaceName) Less(i, j int) bool

func (BySpaceName) Swap

func (s BySpaceName) Swap(i, j int)

type DNSConfig

type DNSConfig struct {
	Nameservers   []Address
	SearchDomains []string
}

DNSConfig holds a list of DNS nameserver addresses and default search domains.

func ParseResolvConf

func ParseResolvConf(path string) (*DNSConfig, error)

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:

  1. if a 'nameserver' or 'search' without a value is found;
  2. 'nameserver' with more than one value (trailing comments starting with '#' or ';' after the value are allowed).
  3. 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 HostPort

type HostPort struct {
	Address
	Port int
}

HostPort associates an address with a port.

func AddressesWithPort

func AddressesWithPort(addrs []Address, port int) []HostPort

AddressesWithPort returns the given addresses all associated with the given port.

func CollapseHostPorts

func CollapseHostPorts(serversHostPorts [][]HostPort) []HostPort

CollapseHostPorts returns a flattened list of HostPorts keeping the same order they appear in serversHostPorts.

func DropDuplicatedHostPorts

func DropDuplicatedHostPorts(hps []HostPort) []HostPort

DropDuplicatedHostPorts removes any HostPorts duplicates from the given slice and returns the result.

func EnsureFirstHostPort

func EnsureFirstHostPort(first HostPort, hps []HostPort) []HostPort

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

func FilterUnusableHostPorts(hps []HostPort) []HostPort

FilterUnusableHostPorts returns a copy of the given HostPorts after removing any addresses unlikely to be usable (ScopeMachineLocal or ScopeLinkLocal).

func NewHostPorts

func NewHostPorts(port int, addresses ...string) []HostPort

NewHostPorts creates a list of HostPorts from each given string address and port.

func ParseHostPort

func ParseHostPort(hp string) (*HostPort, error)

ParseHostPort converts a string containing a single host and port value to a HostPort.

func ParseHostPorts

func ParseHostPorts(hostPorts ...string) ([]HostPort, error)

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

func ResolveOrDropHostnames(hps []HostPort) []HostPort

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 SelectHostsPortBySpaces

func SelectHostsPortBySpaces(hps []HostPort, spaceNames ...SpaceName) ([]HostPort, bool)

SelectHostsPortBySpaces picks the first HostPort from the given slice that has the given space name associated.

func (HostPort) GoString

func (hp HostPort) GoString() string

GoString implements fmt.GoStringer.

func (HostPort) NetAddr

func (hp HostPort) NetAddr() string

NetAddr returns the host-port as an address suitable for calling net.Dial.

func (HostPort) String

func (hp HostPort) String() string

String implements Stringer.

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

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

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 Port

type Port struct {
	Protocol string
	Number   int
}

Port identifies a network port number for a particular protocol.

NOTE(dimitern): This is deprecated and should be removed, use PortRange instead. There are a few places which still use Port, especially in apiserver/params, so it can't be removed yet.

func (Port) GoString

func (p Port) GoString() string

GoString implements fmt.GoStringer.

func (Port) String

func (p Port) String() string

String implements Stringer.

type PortRange

type PortRange struct {
	FromPort int
	ToPort   int
	Protocol string
}

PortRange represents a single range of ports.

func CollapsePorts

func CollapsePorts(ports []Port) (result []PortRange)

CollapsePorts collapses a slice of ports into port ranges.

NOTE(dimitern): This is deprecated and should be removed when possible. It still exists, because in a few places slices of Ports are converted to PortRanges internally.

func MustParsePortRange

func MustParsePortRange(portRange string) PortRange

MustParsePortRange converts a raw port-range string into a PortRange. If the string is invalid, the function panics.

func ParsePortRange

func ParsePortRange(inPortRange string) (PortRange, error)

ParsePortRange builds a PortRange from the provided string. If the string does not include a protocol then "tcp" is used. Validate() gets called on the result before returning. If validation fails the invalid PortRange is still returned. Example strings: "80/tcp", "443", "12345-12349/udp".

func ParsePortRanges

func ParsePortRanges(inPortRanges string) ([]PortRange, error)

ParsePortRanges splits the provided string on commas and extracts a PortRange from each part of the split string. Whitespace is ignored. Example strings: "80/tcp", "80,443,1234/udp", "123-456, 25/tcp".

func (PortRange) ConflictsWith

func (a PortRange) ConflictsWith(b PortRange) bool

ConflictsWith determines if the two port ranges conflict.

func (PortRange) GoString

func (p PortRange) GoString() string

func (PortRange) String

func (p PortRange) String() string

func (PortRange) Validate

func (p PortRange) Validate() error

IsValid determines if the port range is valid.

type PortSet

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

PortSet is a set-like container of Port values.

func NewPortSet

func NewPortSet(portRanges ...PortRange) PortSet

NewPortSet creates a map of protocols to sets of stringified port numbers.

func (*PortSet) Add

func (ps *PortSet) Add(protocol string, port int)

Add adds a port to the PortSet.

func (*PortSet) AddRanges

func (ps *PortSet) AddRanges(portRanges ...PortRange)

AddRanges adds port ranges to the PortSet.

func (*PortSet) Contains

func (ps *PortSet) Contains(protocol string, port int) bool

Contains returns true if the provided port is in the set.

func (*PortSet) ContainsRanges

func (ps *PortSet) ContainsRanges(portRanges ...PortRange) bool

ContainsRanges returns true if the provided port ranges are in the set.

func (PortSet) Difference

func (ps PortSet) Difference(other PortSet) PortSet

Difference returns a new PortSet of the values that are not in the other PortSet.

func (PortSet) Intersection

func (ps PortSet) Intersection(other PortSet) PortSet

Intersection returns a new PortSet of the values that are in both this set and the other, but not in just one of either.

func (PortSet) IsEmpty

func (ps PortSet) IsEmpty() bool

IsEmpty returns true if the PortSet is empty.

func (PortSet) PortNumbers

func (ps PortSet) PortNumbers(protocol string) []int

PortNumbers returns a list of all the port numbers in the set for the given protocol.

func (PortSet) PortRanges

func (ps PortSet) PortRanges(protocols ...string) []PortRange

PortRanges returns a list of all the port ranges in the set for the given protocols. If no protocols are provided all known protocols in the set are used.

func (PortSet) PortStrings

func (ps PortSet) PortStrings(protocol string) []string

PortStrings returns a list of stringified ports in the set for the given protocol. This is strictly a convenience method for situations where another API requires a list of strings.

func (PortSet) Ports

func (ps PortSet) Ports(protocols ...string) []Port

PortNumbers returns a list of all the port numbers in the set for the given protocols. If no protocols are provided then all known protocols in the set are used.

func (PortSet) Protocols

func (ps PortSet) Protocols() []string

Protocols returns a list of protocols known to the PortSet.

func (*PortSet) Remove

func (ps *PortSet) Remove(protocol string, port int)

Remove removes the given port from the set.

func (*PortSet) RemoveRanges

func (ps *PortSet) RemoveRanges(portRanges ...PortRange)

RemoveRanges removes all ports in the given PortRange values from the set.

func (PortSet) Size

func (ps PortSet) Size() int

Size returns the number of ports in the set.

func (PortSet) Union

func (ps PortSet) Union(other PortSet) PortSet

Union returns a new PortSet of the shared values that are common between both PortSets.

func (PortSet) Values

func (ps PortSet) Values() []Port

Values returns a list of all the ports in the set.

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

const (
	ScopeUnknown      Scope = ""
	ScopePublic       Scope = "public"
	ScopeCloudLocal   Scope = "local-cloud"
	ScopeMachineLocal Scope = "local-machine"
	ScopeLinkLocal    Scope = "link-local"
)

type SpaceInfo

type SpaceInfo struct {
	Name       string
	ProviderId Id
	Subnets    []SubnetInfo
}

type SpaceName

type SpaceName string

SpaceName holds the Juju space name of an address.

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 network 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.
	SpaceProviderId Id
}

SubnetInfo describes the bare minimum information for a subnet, which the provider knows about but juju might not yet.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL