Documentation ¶
Index ¶
- Constants
- Variables
- type APIs
- type EC2InstanceMetadataCache
- func (cache *EC2InstanceMetadataCache) AllocENI(useCustomCfg bool, sg []*string, subnet string) (string, error)
- func (cache *EC2InstanceMetadataCache) AllocIPAddress(eniID string) error
- func (cache *EC2InstanceMetadataCache) AllocIPAddresses(eniID string, numIPs int) error
- func (cache *EC2InstanceMetadataCache) DeallocIPAddresses(eniID string, ips []string) error
- func (cache *EC2InstanceMetadataCache) DescribeAllENIs() (eniMetadata []ENIMetadata, tagMap map[string]TagMap, trunkENI string, ...)
- func (cache *EC2InstanceMetadataCache) FreeENI(eniName string) error
- func (cache *EC2InstanceMetadataCache) GetAttachedENIs() (eniList []ENIMetadata, err error)
- func (cache *EC2InstanceMetadataCache) GetENIIPv4Limit() (int, error)
- func (cache *EC2InstanceMetadataCache) GetENILimit() (int, error)
- func (cache *EC2InstanceMetadataCache) GetIPv4sFromEC2(eniID string) (addrList []*ec2.NetworkInterfacePrivateIpAddress, err error)
- func (cache *EC2InstanceMetadataCache) GetLocalIPv4() string
- func (cache *EC2InstanceMetadataCache) GetPrimaryENI() string
- func (cache *EC2InstanceMetadataCache) GetPrimaryENImac() string
- func (cache *EC2InstanceMetadataCache) GetVPCIPv4CIDRs() []string
- func (cache *EC2InstanceMetadataCache) IsUnmanagedENI(eniID string) bool
- func (cache *EC2InstanceMetadataCache) SetUnmanagedENIs(eniIDs []string)
- func (cache *EC2InstanceMetadataCache) WaitForENIAndIPsAttached(eni string, wantedSecondaryIPs int) (eniMetadata ENIMetadata, err error)
- type ENIMetadata
- type InstanceTypeLimits
- type StringSet
- type TagMap
Constants ¶
const (
// UnknownInstanceType indicates that the instance type is not yet supported
UnknownInstanceType = "vpc ip resource(eni ip limit): unknown instance type"
)
Variables ¶
var ( // ErrENINotFound is an error when ENI is not found. ErrENINotFound = errors.New("ENI is not found") // ErrAllSecondaryIPsNotFound is returned when not all secondary IPs on an ENI have been assigned ErrAllSecondaryIPsNotFound = errors.New("All secondary IPs not found") // ErrNoSecondaryIPsFound is returned when not all secondary IPs on an ENI have been assigned ErrNoSecondaryIPsFound = errors.New("No secondary IPs have been assigned to this ENI") // ErrNoNetworkInterfaces occurs when DescribeNetworkInterfaces(eniID) returns no network interfaces ErrNoNetworkInterfaces = errors.New("No network interfaces found for ENI") )
var InstanceNetworkingLimits = map[string]InstanceTypeLimits{}/* 342 elements not displayed */
InstanceNetworkingLimits contains a mapping from instance type to networking limits for the type. Documentation found at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI
Functions ¶
This section is empty.
Types ¶
type APIs ¶
type APIs interface { // AllocENI creates an ENI and attaches it to the instance AllocENI(useCustomCfg bool, sg []*string, subnet string) (eni string, err error) // FreeENI detaches ENI interface and deletes it FreeENI(eniName string) error // GetAttachedENIs retrieves eni information from instance metadata service GetAttachedENIs() (eniList []ENIMetadata, err error) // GetIPv4sFromEC2 returns the IPv4 addresses for a given ENI GetIPv4sFromEC2(eniID string) (addrList []*ec2.NetworkInterfacePrivateIpAddress, err error) // DescribeAllENIs calls EC2 and returns the ENIMetadata and a tag map for each ENI DescribeAllENIs() (eniMetadata []ENIMetadata, tagMap map[string]TagMap, trunkENI string, err error) // AllocIPAddress allocates an IP address for an ENI AllocIPAddress(eniID string) error // AllocIPAddresses allocates numIPs IP addresses on a ENI AllocIPAddresses(eniID string, numIPs int) error // DeallocIPAddresses deallocates the list of IP addresses from a ENI DeallocIPAddresses(eniID string, ips []string) error // GetVPCIPv4CIDRs returns VPC's CIDRs from instance metadata GetVPCIPv4CIDRs() []string // GetLocalIPv4 returns the primary IP address on the primary ENI interface GetLocalIPv4() string // GetPrimaryENI returns the primary ENI GetPrimaryENI() string // GetENIIPv4Limit return IP address limit per ENI based on EC2 instance type GetENIIPv4Limit() (int, error) // GetENILimit returns the number of ENIs that can be attached to an instance GetENILimit() (int, error) // GetPrimaryENImac returns the mac address of the primary ENI GetPrimaryENImac() string // SetUnmanagedENIs sets the list of unmanaged ENI IDs SetUnmanagedENIs(eniIDs []string) // IsUnmanagedENI checks if an ENI is unmanaged IsUnmanagedENI(eniID string) bool // WaitForENIAndIPsAttached waits until the ENI has been attached and the secondary IPs have been added WaitForENIAndIPsAttached(eni string, wantedSecondaryIPs int) (ENIMetadata, error) }
APIs defines interfaces calls for adding/getting/deleting ENIs/secondary IPs. The APIs are not thread-safe.
type EC2InstanceMetadataCache ¶
type EC2InstanceMetadataCache struct {
// contains filtered or unexported fields
}
EC2InstanceMetadataCache caches instance metadata
func New ¶
func New(useCustomNetworking bool) (*EC2InstanceMetadataCache, error)
New creates an EC2InstanceMetadataCache
func (*EC2InstanceMetadataCache) AllocENI ¶
func (cache *EC2InstanceMetadataCache) AllocENI(useCustomCfg bool, sg []*string, subnet string) (string, error)
AllocENI creates an ENI and attaches it to the instance returns: newly created ENI ID
func (*EC2InstanceMetadataCache) AllocIPAddress ¶
func (cache *EC2InstanceMetadataCache) AllocIPAddress(eniID string) error
AllocIPAddress allocates an IP address for an ENI
func (*EC2InstanceMetadataCache) AllocIPAddresses ¶ added in v1.1.0
func (cache *EC2InstanceMetadataCache) AllocIPAddresses(eniID string, numIPs int) error
AllocIPAddresses allocates numIPs of IP address on an ENI
func (*EC2InstanceMetadataCache) DeallocIPAddresses ¶ added in v1.5.0
func (cache *EC2InstanceMetadataCache) DeallocIPAddresses(eniID string, ips []string) error
DeallocIPAddresses allocates numIPs of IP address on an ENI
func (*EC2InstanceMetadataCache) DescribeAllENIs ¶ added in v1.6.1
func (cache *EC2InstanceMetadataCache) DescribeAllENIs() (eniMetadata []ENIMetadata, tagMap map[string]TagMap, trunkENI string, err error)
DescribeAllENIs calls EC2 to refrech the ENIMetadata and tags for all attached ENIs
func (*EC2InstanceMetadataCache) FreeENI ¶
func (cache *EC2InstanceMetadataCache) FreeENI(eniName string) error
FreeENI detaches and deletes the ENI interface
func (*EC2InstanceMetadataCache) GetAttachedENIs ¶
func (cache *EC2InstanceMetadataCache) GetAttachedENIs() (eniList []ENIMetadata, err error)
GetAttachedENIs retrieves ENI information from meta data service
func (*EC2InstanceMetadataCache) GetENIIPv4Limit ¶ added in v1.6.4
func (cache *EC2InstanceMetadataCache) GetENIIPv4Limit() (int, error)
GetENIIPv4Limit return IP address limit per ENI based on EC2 instance type
func (*EC2InstanceMetadataCache) GetENILimit ¶
func (cache *EC2InstanceMetadataCache) GetENILimit() (int, error)
GetENILimit returns the number of ENIs can be attached to an instance
func (*EC2InstanceMetadataCache) GetIPv4sFromEC2 ¶ added in v1.6.1
func (cache *EC2InstanceMetadataCache) GetIPv4sFromEC2(eniID string) (addrList []*ec2.NetworkInterfacePrivateIpAddress, err error)
GetIPv4sFromEC2 calls EC2 and returns a list of all addresses on the ENI
func (*EC2InstanceMetadataCache) GetLocalIPv4 ¶
func (cache *EC2InstanceMetadataCache) GetLocalIPv4() string
GetLocalIPv4 returns the primary IP address on the primary interface
func (*EC2InstanceMetadataCache) GetPrimaryENI ¶
func (cache *EC2InstanceMetadataCache) GetPrimaryENI() string
GetPrimaryENI returns the primary ENI
func (*EC2InstanceMetadataCache) GetPrimaryENImac ¶ added in v1.2.1
func (cache *EC2InstanceMetadataCache) GetPrimaryENImac() string
GetPrimaryENImac returns the mac address of primary eni
func (*EC2InstanceMetadataCache) GetVPCIPv4CIDRs ¶ added in v1.3.0
func (cache *EC2InstanceMetadataCache) GetVPCIPv4CIDRs() []string
GetVPCIPv4CIDRs returns VPC CIDRs
func (*EC2InstanceMetadataCache) IsUnmanagedENI ¶ added in v1.7.2
func (cache *EC2InstanceMetadataCache) IsUnmanagedENI(eniID string) bool
IsUnmanagedENI returns if the eni is unmanaged
func (*EC2InstanceMetadataCache) SetUnmanagedENIs ¶ added in v1.7.2
func (cache *EC2InstanceMetadataCache) SetUnmanagedENIs(eniIDs []string)
SetUnmanagedENIs Set unmanaged ENI set
func (*EC2InstanceMetadataCache) WaitForENIAndIPsAttached ¶ added in v1.7.2
func (cache *EC2InstanceMetadataCache) WaitForENIAndIPsAttached(eni string, wantedSecondaryIPs int) (eniMetadata ENIMetadata, err error)
type ENIMetadata ¶
type ENIMetadata struct { // ENIID is the id of network interface ENIID string // MAC is the mac address of network interface MAC string // DeviceNumber is the device number of network interface DeviceNumber int // 0 means it is primary interface // SubnetIPv4CIDR is the ipv4 cider of network interface SubnetIPv4CIDR string // The ip addresses allocated for the network interface IPv4Addresses []*ec2.NetworkInterfacePrivateIpAddress }
ENIMetadata contains information about an ENI
func (ENIMetadata) PrimaryIPv4Address ¶ added in v1.6.1
func (eni ENIMetadata) PrimaryIPv4Address() string
PrimaryIPv4Address returns the primary IP of this node
type InstanceTypeLimits ¶ added in v1.6.4
InstanceTypeLimits keeps track of limits for an instance type
type StringSet ¶ added in v1.6.4
StringSet is a set of strings
func (*StringSet) Difference ¶ added in v1.6.4
Difference compares this StringSet with another
func (*StringSet) SortedList ¶ added in v1.6.4
SortedList returnsa sorted string slice from this set