awsutils

package
v1.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: Apache-2.0 Imports: 17 Imported by: 36

Documentation

Index

Constants

View Source
const (

	// UnknownInstanceType indicates that the instance type is not yet supported
	UnknownInstanceType = "vpc ip resource(eni ip limit): unknown instance type"
)

Variables

View Source
var ErrENINotFound = errors.New("ENI is not found")

ErrENINotFound is an error when ENI is not found.

View Source
var InstanceENIsAvailable = map[string]int{}/* 222 elements not displayed */

InstanceENIsAvailable contains a mapping of instance types to the number of ENIs available which is described at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI

View Source
var InstanceIPsAvailable = map[string]int{}/* 222 elements not displayed */

InstanceIPsAvailable contains a mapping of instance types to the number of IPs per ENI 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)

	// DescribeENI returns the IPv4 addresses of ENI interface and ENI attachment ID
	DescribeENI(eniID string) (addrList []*ec2.NetworkInterfacePrivateIpAddress, attachemdID *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

	// GetVPCIPv4CIDR returns VPC's 1st CIDR
	GetVPCIPv4CIDR() string

	// GetVPCIPv4CIDRs returns VPC's CIDRs
	GetVPCIPv4CIDRs() []*string

	// GetLocalIPv4 returns the primary IP address on the primary ENI interface
	GetLocalIPv4() string

	// GetPrimaryENI returns the primary ENI
	GetPrimaryENI() string

	// GetENIipLimit return IP address limit per ENI based on EC2 instance type
	GetENIipLimit() (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
}

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

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

DescribeENI returns the IPv4 addresses of interface and the attachment id return: private IP address, attachment id, error

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

func (cache *EC2InstanceMetadataCache) GetENILimit() (int, error)

GetENILimit returns the number of ENIs can be attached to an instance

func (*EC2InstanceMetadataCache) GetENIipLimit

func (cache *EC2InstanceMetadataCache) GetENIipLimit() (int, error)

GetENIipLimit return IP address limit per ENI based on EC2 instance type

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

func (cache *EC2InstanceMetadataCache) GetVPCIPv4CIDR() string

GetVPCIPv4CIDR returns VPC CIDR

func (*EC2InstanceMetadataCache) GetVPCIPv4CIDRs added in v1.3.0

func (cache *EC2InstanceMetadataCache) GetVPCIPv4CIDRs() []*string

GetVPCIPv4CIDRs returns VPC CIDRs

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
	LocalIPv4s []string
}

ENIMetadata contains ENI information retrieved from EC2 meta data service

Directories

Path Synopsis
Package mock_awsutils is a generated GoMock package.
Package mock_awsutils is a generated GoMock package.

Jump to

Keyboard shortcuts

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