cloud

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BCCEndpointEnv = "BCC_ENDPOINT"
	BBCEndpointEnv = "BBC_ENDPOINT"
)

Variables

View Source
var (
	BCCEndpoints = map[string]string{
		"bj":  "bcc.bj.baidubce.com",
		"gz":  "bcc.gz.baidubce.com",
		"su":  "bcc.su.baidubce.com",
		"hkg": "bcc.hkg.baidubce.com",
		"fwh": "bcc.fwh.baidubce.com",
		"bd":  "bcc.bd.baidubce.com",
	}

	BBCEndpoints = map[string]string{
		"bj":  "bbc.bj.baidubce.com",
		"gz":  "bbc.gz.baidubce.com",
		"su":  "bbc.su.baidubce.com",
		"hkg": "bbc.hkg.baidubce.com",
		"fwh": "bbc.fwh.baidubce.com",
		"bd":  "bbc.bd.baidubce.com",
	}
)

Functions

func BceServiceErrorToHTTPCode

func BceServiceErrorToHTTPCode(err error) int

func IsErrorBBCENIPrivateIPExceedLimit

func IsErrorBBCENIPrivateIPExceedLimit(err error) bool

func IsErrorBBCENIPrivateIPNotFound

func IsErrorBBCENIPrivateIPNotFound(err error) bool

func IsErrorENINotFound

func IsErrorENINotFound(err error) bool

func IsErrorENIPrivateIPNotFound

func IsErrorENIPrivateIPNotFound(err error) bool

IsErrorENIPrivateIPNotFound 判定删除辅助 IP 的 err 是否是因为 IP 不属于弹性网卡

func IsErrorPrivateIPInUse

func IsErrorPrivateIPInUse(err error) bool

func IsErrorQuotaLimitExceeded

func IsErrorQuotaLimitExceeded(err error) bool

func IsErrorRateLimit

func IsErrorRateLimit(err error) bool

func IsErrorReasonNoSuchObject

func IsErrorReasonNoSuchObject(err error) bool

func IsErrorRouteRuleRepeated

func IsErrorRouteRuleRepeated(err error) bool

func IsErrorSubnetHasNoMoreIP

func IsErrorSubnetHasNoMoreIP(err error) bool

func IsErrorVmMemoryCanNotAttachMoreIpException

func IsErrorVmMemoryCanNotAttachMoreIpException(err error) bool

Types

type Auth

type Auth interface {
	GetSigner(ctx context.Context) auth.Signer
	GetCredentials(ctx context.Context) *auth.BceCredentials
	GetSignOptions(ctx context.Context) *auth.SignOptions
}

func NewAccessKeyPairAuth

func NewAccessKeyPairAuth(ak, sk, token string) (Auth, error)

func NewCCEGatewayAuth

func NewCCEGatewayAuth(region, clusterID string, kubeClient kubernetes.Interface) (Auth, error)

type AuthMode

type AuthMode string
const (
	AuthModeAccessKey  AuthMode = "key"
	AuthModeCCEGateway AuthMode = "gateway"
)

type Client

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

func (*Client) AddPrivateIP

func (c *Client) AddPrivateIP(ctx context.Context, privateIP string, eniID string) (string, error)

func (*Client) AttachENI

func (c *Client) AttachENI(ctx context.Context, args *eni.EniInstance) error

func (*Client) BBCBatchAddIP

func (c *Client) BBCBatchAddIP(ctx context.Context, args *bbc.BatchAddIpArgs) (*bbc.BatchAddIpResponse, error)

func (*Client) BBCBatchAddIPCrossSubnet

func (c *Client) BBCBatchAddIPCrossSubnet(ctx context.Context, args *bbc.BatchAddIpCrossSubnetArgs) (*bbc.BatchAddIpResponse, error)

func (*Client) BBCBatchDelIP

func (c *Client) BBCBatchDelIP(ctx context.Context, args *bbc.BatchDelIpArgs) error

func (*Client) BatchAddHpcEniPrivateIP added in v1.5.4

func (c *Client) BatchAddHpcEniPrivateIP(ctx context.Context, args *hpc.EniBatchPrivateIPArgs) (*hpc.BatchAddPrivateIPResult, error)

func (*Client) BatchAddPrivateIP

func (c *Client) BatchAddPrivateIP(ctx context.Context, privateIPs []string, count int, eniID string) ([]string, error)

func (*Client) BatchAddPrivateIpCrossSubnet

func (c *Client) BatchAddPrivateIpCrossSubnet(ctx context.Context, eniID, subnetID string, privateIPs []string, count int) ([]string, error)

func (*Client) BatchDeleteHpcEniPrivateIP added in v1.5.4

func (c *Client) BatchDeleteHpcEniPrivateIP(ctx context.Context, args *hpc.EniBatchDeleteIPArgs) error

func (*Client) BatchDeletePrivateIP

func (c *Client) BatchDeletePrivateIP(ctx context.Context, privateIPs []string, eniID string) error

func (*Client) CreateENI

func (c *Client) CreateENI(ctx context.Context, args *eni.CreateEniArgs) (string, error)

func (*Client) CreateRouteRule

func (c *Client) CreateRouteRule(ctx context.Context, args *vpc.CreateRouteRuleArgs) (string, error)

func (*Client) DeleteENI

func (c *Client) DeleteENI(ctx context.Context, eniID string) error

func (*Client) DeletePrivateIP

func (c *Client) DeletePrivateIP(ctx context.Context, privateIP string, eniID string) error

func (*Client) DeleteRouteRule

func (c *Client) DeleteRouteRule(ctx context.Context, routeID string) error

func (*Client) DescribeSubnet

func (c *Client) DescribeSubnet(ctx context.Context, subnetID string) (*vpc.Subnet, error)

func (*Client) DetachENI

func (c *Client) DetachENI(ctx context.Context, args *eni.EniInstance) error

func (*Client) GetBBCInstanceDetail

func (c *Client) GetBBCInstanceDetail(ctx context.Context, instanceID string) (*bbc.InstanceModel, error)

func (*Client) GetBBCInstanceENI

func (c *Client) GetBBCInstanceENI(ctx context.Context, instanceID string) (*bbc.GetInstanceEniResult, error)

func (*Client) GetBCCInstanceDetail

func (c *Client) GetBCCInstanceDetail(ctx context.Context, instanceID string) (*bccapi.InstanceModel, error)

func (*Client) GetHPCEniID added in v1.5.4

func (c *Client) GetHPCEniID(ctx context.Context, instanceID string) (*hpc.EniList, error)

func (*Client) ListENIs

func (c *Client) ListENIs(_ context.Context, args eni.ListEniArgs) ([]eni.Eni, error)

func (*Client) ListERIs added in v1.6.12

func (c *Client) ListERIs(_ context.Context, args eni.ListEniArgs) ([]eni.Eni, error)

func (*Client) ListRouteTable

func (c *Client) ListRouteTable(ctx context.Context, vpcID, routeTableID string) ([]vpc.RouteRule, error)

func (*Client) ListSecurityGroup

func (c *Client) ListSecurityGroup(ctx context.Context, vpcID, instanceID string) ([]bccapi.SecurityGroupModel, error)

func (*Client) ListSubnets

func (c *Client) ListSubnets(ctx context.Context, args *vpc.ListSubnetArgs) ([]vpc.Subnet, error)

func (*Client) StatENI

func (c *Client) StatENI(ctx context.Context, eniID string) (*eni.Eni, error)

type ErrorReason

type ErrorReason string
const (
	ErrorReasonUnknown                             ErrorReason = "Unknown"
	ErrorReasonENIPrivateIPNotFound                ErrorReason = "ENIPrivateIPNotFound"
	ErrorReasonENINotFound                         ErrorReason = "ENINotFound"
	ErrorReasonSubnetHasNoMoreIP                   ErrorReason = "SubnetHasNoMoreIP"
	ErrorReasonRateLimit                           ErrorReason = "RateLimit"
	ErrorReasonPrivateIPInUse                      ErrorReason = "PrivateIPInUse"
	ErrorReasonVmMemoryCanNotAttachMoreIpException ErrorReason = "VmMemoryCanNotAttachMoreIpException"
	ErrorReasonBBCENIPrivateIPNotFound             ErrorReason = "BBCENIPrivateIPNotFound"
	ErrorReasonBBCENIPrivateIPExceedLimit          ErrorReason = "BBCENIPrivateIPExceedLimit"
	ErrorReasonRouteRuleRepeated                   ErrorReason = "RouteRuleRepeated"
	ErrorReasonQuotaLimitExceeded                  ErrorReason = "QuotaLimitExceeded"
	ErrorReasonNoSuchObject                        ErrorReason = "NoSuchObject"
)

func ReasonForError

func ReasonForError(err error) ErrorReason

type Interface

type Interface interface {
	ListENIs(ctx context.Context, args eni.ListEniArgs) ([]eni.Eni, error)
	ListERIs(ctx context.Context, args eni.ListEniArgs) ([]eni.Eni, error)
	AddPrivateIP(ctx context.Context, privateIP string, eniID string) (string, error)
	DeletePrivateIP(ctx context.Context, privateIP string, eniID string) error

	// BatchAddPrivateIpCrossSubnet
	// Assign IP addresses to Eni across subnets.
	// Note that this feature needs to initiate a work order in advance to
	// enable the cross subnet IP allocation function
	BatchAddPrivateIpCrossSubnet(ctx context.Context, eniID, subnetID string, privateIPs []string, count int) ([]string, error)
	BatchAddPrivateIP(ctx context.Context, privateIPs []string, count int, eniID string) ([]string, error)
	BatchDeletePrivateIP(ctx context.Context, privateIPs []string, eniID string) error
	CreateENI(ctx context.Context, args *eni.CreateEniArgs) (string, error)
	DeleteENI(ctx context.Context, eniID string) error
	AttachENI(ctx context.Context, args *eni.EniInstance) error
	DetachENI(ctx context.Context, args *eni.EniInstance) error
	StatENI(ctx context.Context, eniID string) (*eni.Eni, error)

	ListRouteTable(ctx context.Context, vpcID, routeTableID string) ([]vpc.RouteRule, error)
	CreateRouteRule(ctx context.Context, args *vpc.CreateRouteRuleArgs) (string, error)
	DeleteRouteRule(ctx context.Context, routeID string) error

	DescribeSubnet(ctx context.Context, subnetID string) (*vpc.Subnet, error)
	ListSubnets(ctx context.Context, args *vpc.ListSubnetArgs) ([]vpc.Subnet, error)

	ListSecurityGroup(ctx context.Context, vpcID, instanceID string) ([]bccapi.SecurityGroupModel, error)

	GetBCCInstanceDetail(ctx context.Context, instanceID string) (*bccapi.InstanceModel, error)

	GetBBCInstanceDetail(ctx context.Context, instanceID string) (*bbc.InstanceModel, error)
	GetBBCInstanceENI(ctx context.Context, instanceID string) (*bbc.GetInstanceEniResult, error)
	BBCBatchAddIP(ctx context.Context, args *bbc.BatchAddIpArgs) (*bbc.BatchAddIpResponse, error)
	BBCBatchDelIP(ctx context.Context, args *bbc.BatchDelIpArgs) error
	BBCBatchAddIPCrossSubnet(ctx context.Context, args *bbc.BatchAddIpCrossSubnetArgs) (*bbc.BatchAddIpResponse, error)

	GetHPCEniID(ctx context.Context, instanceID string) (*hpc.EniList, error)
	BatchDeleteHpcEniPrivateIP(ctx context.Context, args *hpc.EniBatchDeleteIPArgs) error
	BatchAddHpcEniPrivateIP(ctx context.Context, args *hpc.EniBatchPrivateIPArgs) (*hpc.BatchAddPrivateIPResult, error)
}

func New

func New(
	region string,
	clusterID string,
	accessKeyID string,
	secretAccessKey string,
	kubeClient kubernetes.Interface,
	debug bool,
) (Interface, error)

Directories

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

Jump to

Keyboard shortcuts

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