aliyun

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LogFieldAPI              = "api"
	LogFieldRequestID        = "requestID"
	LogFieldInstanceID       = "instanceID"
	LogFieldSecondaryIPCount = "secondaryIPCount"
	LogFieldENIID            = "eni"
	LogFieldEIPID            = "eip"
	LogFieldPrivateIP        = "privateIP"
	LogFieldVSwitchID        = "vSwitchID"
)

log fields

Variables

This section is empty.

Functions

func NewAliyunImpl added in v1.1.0

func NewAliyunImpl(openAPI *OpenAPI, needENITypeAttr bool, ipFamily *types.IPFamily) ipam.API

NewAliyunImpl return new API implement object

func UpdateFromAPI added in v1.1.0

func UpdateFromAPI(client *ecs.Client, instanceType string) error

UpdateFromAPI updates limits for instance https://www.alibabacloud.com/help/doc-detail/25620.htm

Types

type Client added in v1.2.0

type Client interface {
	ECS() *ecs.Client
	VPC() *vpc.Client
}

func NewClientSet added in v1.2.0

func NewClientSet(ak, sk, regionID, credentialPath, secretNamespace, secretName string) (Client, error)

type ClientMgr

type ClientMgr struct {

	// protect things below
	sync.RWMutex
	// contains filtered or unexported fields
}

ClientMgr manager of aliyun openapi clientset

func NewClientMgr

func NewClientMgr(key, secret, credentialPath, regionID, secretNamespace, secretName string) (*ClientMgr, error)

NewClientMgr return new aliyun client manager

func (*ClientMgr) ECS added in v1.1.0

func (c *ClientMgr) ECS() *ecs.Client

func (*ClientMgr) VPC added in v1.1.0

func (c *ClientMgr) VPC() *vpc.Client

type ENIInfoGetter

type ENIInfoGetter interface {
	GetENIByMac(mac string) (*types.ENI, error)
	GetENIPrivateAddressesByMAC(mac string) ([]net.IP, error)
	GetENIPrivateIPv6AddressesByMAC(mac string) ([]net.IP, error)
	GetENIs(containsMainENI bool) ([]*types.ENI, error)
	GetSecondaryENIMACs() ([]string, error)
}

ENIInfoGetter interface to get eni information

type ENIMetadata

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

func NewENIMetadata added in v1.1.0

func NewENIMetadata(ipFamily *types.IPFamily) *ENIMetadata

func (*ENIMetadata) GetENIByMac added in v1.1.0

func (e *ENIMetadata) GetENIByMac(mac string) (*types.ENI, error)

func (*ENIMetadata) GetENIPrivateAddressesByMAC added in v1.1.0

func (e *ENIMetadata) GetENIPrivateAddressesByMAC(mac string) ([]net.IP, error)

func (*ENIMetadata) GetENIPrivateIPv6AddressesByMAC added in v1.1.0

func (e *ENIMetadata) GetENIPrivateIPv6AddressesByMAC(mac string) ([]net.IP, error)

func (*ENIMetadata) GetENIs added in v1.1.0

func (e *ENIMetadata) GetENIs(containsMainENI bool) ([]*types.ENI, error)

func (*ENIMetadata) GetSecondaryENIMACs added in v1.1.0

func (e *ENIMetadata) GetSecondaryENIMACs() ([]string, error)

GetSecondaryENIMACs return secondary ENI macs

type ENIStatus added in v1.1.0

type ENIStatus string

ENIStatus status for eni

const (
	ENIStatusInUse     ENIStatus = "InUse"
	ENIStatusAvailable ENIStatus = "Available"
)

status for ENIStatus

type ENIType added in v1.1.0

type ENIType string

ENIType eni type

const (
	ENITypePrimary   ENIType = "Primary"
	ENITypeSecondary ENIType = "Secondary"
	ENITypeTrunk     ENIType = "Trunk"
	ENITypeMember    ENIType = "Member"
)

status for ENIType

type Impl added in v1.1.0

type Impl struct {
	*OpenAPI
	// contains filtered or unexported fields
}

func (*Impl) AllocateENI added in v1.1.0

func (e *Impl) AllocateENI(ctx context.Context, vSwitch string, securityGroups []string, instanceID string, trunk bool, ipCount int, eniTags map[string]string) (*types.ENI, error)

AllocateENI for instance

func (*Impl) AllocateEipAddress added in v1.1.0

func (e *Impl) AllocateEipAddress(ctx context.Context, bandwidth int, chargeType types.InternetChargeType, eipID, eniID string, eniIP net.IP, allowRob bool) (*types.EIP, error)

func (*Impl) AssignNIPsForENI added in v1.1.0

func (e *Impl) AssignNIPsForENI(ctx context.Context, eniID, mac string, count int) (ipSet []types.IPSet, err error)

func (*Impl) CheckEniSecurityGroup added in v1.1.0

func (e *Impl) CheckEniSecurityGroup(ctx context.Context, sg []string) error

CheckEniSecurityGroup will sync eni's security with ecs's security group

func (*Impl) FreeENI added in v1.1.0

func (e *Impl) FreeENI(ctx context.Context, eniID, instanceID string) error

func (*Impl) GetAttachedENIs added in v1.1.0

func (e *Impl) GetAttachedENIs(ctx context.Context, containsMainENI bool) ([]*types.ENI, error)

GetAttachedENIs of instanceId containsMainENI is contains the main interface(eth0) of instance

func (*Impl) GetAttachedSecurityGroups added in v1.1.0

func (e *Impl) GetAttachedSecurityGroups(ctx context.Context, instanceID string) ([]string, error)

func (*Impl) GetENIByMac added in v1.1.0

func (e *Impl) GetENIByMac(ctx context.Context, mac string) (*types.ENI, error)

func (*Impl) GetENIIPs added in v1.1.0

func (e *Impl) GetENIIPs(ctx context.Context, mac string) ([]net.IP, []net.IP, error)

func (*Impl) GetInstanceAttributesType added in v1.1.0

func (e *Impl) GetInstanceAttributesType(ctx context.Context, instanceID string) (*ecs.Instance, error)

func (*Impl) GetSecondaryENIMACs added in v1.1.0

func (e *Impl) GetSecondaryENIMACs(ctx context.Context) ([]string, error)

func (*Impl) QueryEniIDByIP added in v1.1.0

func (e *Impl) QueryEniIDByIP(ctx context.Context, vpcID string, address net.IP) (string, error)

func (*Impl) ReleaseEipAddress added in v1.1.0

func (e *Impl) ReleaseEipAddress(ctx context.Context, eipID, eniID string, eniIP net.IP) error

func (*Impl) UnAssignIPsForENI added in v1.1.0

func (e *Impl) UnAssignIPsForENI(ctx context.Context, eniID, mac string, ipv4s []net.IP, ipv6s []net.IP) error

func (*Impl) UnassociateEipAddress added in v1.1.0

func (e *Impl) UnassociateEipAddress(ctx context.Context, eipID, eniID, eniIP string) error

UnassociateEipAddress un associate eip 1. if eni is deleted eip auto unassociated 2. if eip is deleted , return code is InvalidAllocationId.NotFound 3. if eip is not bind ,return code is IncorrectEipStatus

func (*Impl) WaitForEIP added in v1.1.0

func (e *Impl) WaitForEIP(eipID string, status string, backoff wait.Backoff) (*vpc.EipAddress, error)

WaitForEIP wait status of eni, ignore status if is empty

type Instance added in v1.1.0

type Instance struct {
	RegionID   string
	ZoneID     string
	VPCID      string
	VSwitchID  string
	PrimaryMAC string

	InstanceID   string
	InstanceType string
}

func GetInstanceMeta added in v1.1.0

func GetInstanceMeta() *Instance

type Limits added in v1.1.0

type Limits struct {
	// Adapters specifies the maximum number of interfaces that can be
	// attached to the instance
	Adapters int

	// IPv4PerAdapter is the maximum number of ipv4 addresses per adapter/interface
	IPv4PerAdapter int

	// IPv6PerAdapter is the maximum number of ipv6 addresses per adapter/interface
	IPv6PerAdapter int

	// MemberAdapterLimit is the number interfaces that type is member
	MemberAdapterLimit int

	// MaxMemberAdapterLimit is the limit to use member
	MaxMemberAdapterLimit int
}

Limits specifies the IPAM relevant instance limits

func GetLimit added in v1.1.0

func GetLimit(instanceType string) (limit Limits, ok bool)

GetLimit returns the instance limits of a particular instance type.

func (*Limits) ENIOnlyPod added in v1.1.0

func (l *Limits) ENIOnlyPod() int

func (*Limits) MIPPod added in v1.1.0

func (l *Limits) MIPPod() int

func (*Limits) SupportIPv6 added in v1.1.0

func (l *Limits) SupportIPv6() bool

func (*Limits) TrunkPod added in v1.1.0

func (l *Limits) TrunkPod() int

type OpenAPI added in v1.1.0

type OpenAPI struct {
	ClientSet Client

	ReadOnlyRateLimiter flowcontrol.RateLimiter
	MutatingRateLimiter flowcontrol.RateLimiter
}

func New added in v1.2.0

func New(c Client, readOnly, mutating flowcontrol.RateLimiter) (*OpenAPI, error)

func NewAliyun added in v1.1.0

func NewAliyun(ak, sk, regionID, credentialPath, secretNamespace, secretName string) (*OpenAPI, error)

func (*OpenAPI) AssignIpv6Addresses added in v1.1.0

func (a *OpenAPI) AssignIpv6Addresses(ctx context.Context, eniID string, count int) ([]net.IP, error)

AssignIpv6Addresses assign ipv6 address

func (*OpenAPI) AssignPrivateIPAddress added in v1.1.0

func (a *OpenAPI) AssignPrivateIPAddress(ctx context.Context, eniID string, count int) ([]net.IP, error)

AssignPrivateIPAddress assign secondary ip

func (*OpenAPI) AttachNetworkInterface added in v1.1.0

func (a *OpenAPI) AttachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error

AttachNetworkInterface attach eni

func (*OpenAPI) CreateNetworkInterface added in v1.1.0

func (a *OpenAPI) CreateNetworkInterface(ctx context.Context, instanceType ENIType, vSwitch string, securityGroups []string, ipCount, ipv6Count int, eniTags map[string]string) (*ecs.CreateNetworkInterfaceResponse, error)

CreateNetworkInterface instanceType Secondary Trunk

func (*OpenAPI) DeleteNetworkInterface added in v1.1.0

func (a *OpenAPI) DeleteNetworkInterface(ctx context.Context, eniID string) error

DeleteNetworkInterface del eni by id

func (*OpenAPI) DescribeNetworkInterface added in v1.1.0

func (a *OpenAPI) DescribeNetworkInterface(ctx context.Context, vpcID string, eniID []string, instanceID string, instanceType ENIType, status ENIStatus) ([]ecs.NetworkInterfaceSet, error)

DescribeNetworkInterface list eni

func (*OpenAPI) DescribeVSwitchByID added in v1.1.0

func (a *OpenAPI) DescribeVSwitchByID(ctx context.Context, vSwitch string) (*vpc.VSwitch, error)

DescribeVSwitchByID get vsw by id

func (*OpenAPI) DetachNetworkInterface added in v1.1.0

func (a *OpenAPI) DetachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error

DetachNetworkInterface detach eni

func (*OpenAPI) UnAssignIpv6Addresses added in v1.1.0

func (a *OpenAPI) UnAssignIpv6Addresses(ctx context.Context, eniID string, ips []net.IP) error

UnAssignIpv6Addresses remove ip from eni return ok if 1. eni is released 2. ip is already released 3. release success

func (*OpenAPI) UnAssignPrivateIPAddresses added in v1.1.0

func (a *OpenAPI) UnAssignPrivateIPAddresses(ctx context.Context, eniID string, ips []net.IP) error

UnAssignPrivateIPAddresses remove ip from eni return ok if 1. eni is released 2. ip is already released 3. release success

func (*OpenAPI) WaitForNetworkInterface added in v1.1.0

func (a *OpenAPI) WaitForNetworkInterface(ctx context.Context, eniID string, status ENIStatus, backoff wait.Backoff, ignoreNotExist bool) (*ecs.NetworkInterfaceSet, error)

WaitForNetworkInterface wait status of eni

type VPCOps added in v1.1.1

type VPCOps interface {
	DescribeVSwitchByID(ctx context.Context, vSwitch string) (*vpc.VSwitch, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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