alicloud

package
v26.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

* Copyright (C) 2017-2019 Alibaba Group Holding Limited

Index

Constants

View Source
const (
	TagResourceImage    = TagResourceType("image")
	TagResourceInstance = TagResourceType("instance")
	TagResourceSnapshot = TagResourceType("snapshot")
	TagResourceDisk     = TagResourceType("disk")
)
View Source
const (
	Creating = InstanceStatus("Creating") // For backward compatibility
	Pending  = InstanceStatus("Pending")
	Running  = InstanceStatus("Running")
	Starting = InstanceStatus("Starting")

	Stopped  = InstanceStatus("Stopped")
	Stopping = InstanceStatus("Stopping")
	Deleted  = InstanceStatus("Deleted")
)

Constants of InstanceStatus

View Source
const (
	EipStatusAssociating   = EipStatus("Associating")
	EipStatusUnassociating = EipStatus("Unassociating")
	EipStatusInUse         = EipStatus("InUse")
	EipStatusAvailable     = EipStatus("Available")
)
View Source
const (
	DiskStatusInUse     = DiskStatus("In_use")
	DiskStatusAvailable = DiskStatus("Available")
	DiskStatusAttaching = DiskStatus("Attaching")
	DiskStatusDetaching = DiskStatus("Detaching")
	DiskStatusCreating  = DiskStatus("Creating")
	DiskStatusReIniting = DiskStatus("ReIniting")
	DiskStatusAll       = DiskStatus("All") //Default
)
View Source
const (
	DiskCategoryAll             = DiskCategory("all") //Default
	DiskCategoryCloud           = DiskCategory("cloud")
	DiskCategoryEphemeral       = DiskCategory("ephemeral")
	DiskCategoryEphemeralSSD    = DiskCategory("ephemeral_ssd")
	DiskCategoryCloudEfficiency = DiskCategory("cloud_efficiency")
	DiskCategoryCloudSSD        = DiskCategory("cloud_ssd")
)
View Source
const (
	NoSpot             = SpotStrategyType("NoSpot")
	SpotWithPriceLimit = SpotStrategyType("SpotWithPriceLimit")
	SpotAsPriceGo      = SpotStrategyType("SpotAsPriceGo")
)

Constants of SpotStrategyType

View Source
const (
	RAW = ImageFormatType("RAW")
	VHD = ImageFormatType("VHD")
)
View Source
const (
	UseForceStop = true

	WaitTimeout  = time.Duration(600) * time.Second
	WaitInterval = time.Duration(5) * time.Second

	DefaultEipWaitSeconds = 120
	DefaultSlbWeight      = 100
	BoshCPI               = "Bosh-Alicloud-Cpi"
	BoshCPIVersion        = "1.0"
)
View Source
const (
	ChangeDiskStatusTimeout       = time.Duration(300) * time.Second
	ChangeDiskStatusSleepInterval = time.Duration(5) * time.Second
)
View Source
const (
	// common
	NotFound       = "NotFound"
	WaitForTimeout = "WaitForTimeout"
	// ecs
	InstanceNotFound        = "Instance.Notfound"
	RamInstanceNotFound     = "Forbidden.InstanceNotFound"
	MessageInstanceNotFound = "instance is not found"
	//stemcell
	ImageIsImporting = "ImageIsImporting"
)
View Source
const (
	ChangeInstanceStatusTimeout       = time.Duration(600) * time.Second
	ChangeInstanceStatusSleepInterval = time.Duration(5) * time.Second
)
View Source
const (
	AlicloudImageServiceTag          = "AlicloudImageService"
	AlicloudDefaultImageName         = "bosh-stemcell"
	AlicloudDefaultImageArchitecture = "x86_64"
	AlicloudDefaultImageOSType       = "linux"
	WaitForImageReadyTimeout         = 3600
	DefaultWaitForImageReadyTimeout  = 1800
	DefaultWaitForInterval           = 10
)
View Source
const (
	AlicloudOssServiceTag = "AlicloudOssService"
)

Variables

View Source
var CreateInstanceCatcher_IdempotentProcessing = Catcher{"IdempotentProcessing", 15, 5}
View Source
var CreateInstanceCatcher_IpUsed = Catcher{"InvalidPrivateIpAddress.Duplicated", 30, 10}
View Source
var CreateInstanceCatcher_IpUsed2 = Catcher{"InvalidIPAddress.AlreadyUsed", 30, 10}
View Source
var CreateInstanceCatcher_TokenProcessing = Catcher{"LastTokenProcessing", 15, 5}
View Source
var DeleteDiskCatcher = Catcher{"IncorrectDiskStatus.Initializing", 10, 15}
View Source
var DeleteInstanceCatcher = Catcher{"IncorrectInstanceStatus.Initializing", 20, 15}
View Source
var EcsInstanceNotFound = []string{"Instance.Notfound", "InvalidInstanceId.NotFound"}
View Source
var IncorrectInstanceStatusCatcher = Catcher{"IncorrectInstanceStatus", 30, 10}
View Source
var InstanceInvalidOperationConflictCatcher = Catcher{"InvalidOperation.Conflict", 20, 10}
View Source
var InternalErrorCatcher = Catcher{"InternalError", 60, 5}
View Source
var NetworkInterfaceInvalidOperationInvalidEniStateCacher = Catcher{"InvalidOperation.InvalidEniState", 60, 5}
View Source
var OperationConflictCatcher = Catcher{"OperationConflict", 60, 5}
View Source
var ResourceNotFound = []string{"InvalidResourceId.NotFound"}
View Source
var ServiceBusyCatcher = Catcher{"ServiceUnavailable", 60, 5}

Functions

func AmendDiskPath

func AmendDiskPath(path string, category DiskCategory) string

func DescribeDisks

func DescribeDisks(client *ecs.Client, diskId string) (disk *ecs.Disk, err error)

func GetNotFoundErrorFromString

func GetNotFoundErrorFromString(str string) error

func GetNotFoundMessage

func GetNotFoundMessage(product, id string) string

func GetTimeErrorFromString

func GetTimeErrorFromString(str string) error

func GetTimeoutMessage

func GetTimeoutMessage(product, status string) string

func IsExceptedErrors

func IsExceptedErrors(err error, expectCodes []string) bool

func NotFoundError

func NotFoundError(err error) bool

Types

type AgentConfig

type AgentConfig struct {
	Ntp       []string        `json:"ntp"`
	Mbus      string          `json:"mbus"`
	Blobstore BlobstoreConfig `json:"blobstore"`
}

type BackendServerType

type BackendServerType struct {
	ServerId string
	Weight   int
}

type BlobstoreConfig

type BlobstoreConfig struct {
	Provider string                 `json:"provider"`
	Options  map[string]interface{} `json:"options"`
}

func (BlobstoreConfig) AsRegistrySettings

func (a BlobstoreConfig) AsRegistrySettings() registry.BlobstoreSettings

type Catcher

type Catcher struct {
	Reason           string
	RetryCount       int
	RetryWaitSeconds int
}

type CloudConfig

type CloudConfig struct {
	Plugin     string `json:"plugin"`
	Properties Config `json:"properties"`
}

type CloudConfigJson

type CloudConfigJson struct {
	Root CloudConfig `json:"cloud"`
}

type Config

type Config struct {
	OpenApi  OpenApi        `json:"alicloud"`
	Registry RegistryConfig `json:"registry"`
	Agent    AgentConfig    `json:"agent"`
}

func NewConfigFromBytes

func NewConfigFromBytes(bytes []byte) (Config, error)

func NewConfigFromFile

func NewConfigFromFile(configFile string, fs boshsys.FileSystem) (Config, error)

func (Config) GetCrossRegions

func (c Config) GetCrossRegions() (regions []string, err error)

func (Config) GetHttpRegistryClient

func (c Config) GetHttpRegistryClient(logger boshlog.Logger) registry.Client

func (Config) GetInstanceRegion

func (c Config) GetInstanceRegion(instanceId string) (region string, err error)

func (Config) GetRegistryClient

func (c Config) GetRegistryClient(logger boshlog.Logger) registry.Client

func (Config) NewEcsClient

func (c Config) NewEcsClient(region string) (*ecs.Client, error)

func (Config) NewOssClient

func (c Config) NewOssClient(region string) (*oss.Client, error)

func (Config) NewSlbClient

func (c Config) NewSlbClient(region string) (*slb.Client, error)

func (Config) Validate

func (c Config) Validate() error

type DiskCategory

type DiskCategory string

type DiskManager

type DiskManager interface {
	GetDisks(instCid string) ([]ecs.Disk, error)
	GetDisk(diskCid string) (*ecs.Disk, error)

	CreateDisk(region string, args *ecs.CreateDiskRequest) (string, error)
	DeleteDisk(diskCid string) error

	AttachDisk(instCid, diskCid string) error
	DetachDisk(instCid, diskCid string) error

	ResizeDisk(diskCid string, sizeGB int) error
	ModifyDiskAttribute(diskCid, name, description string) error

	CreateSnapshot(diskCid string, snapshotName string) (string, error)
	DeleteSnapshot(snapshotCid string) error

	WaitForDiskStatus(diskCid string, toStatus DiskStatus) (string, error)
	ChangeDiskStatus(cid string, toStatus DiskStatus, checkFunc func(*ecs.Disk) (bool, error)) error
}

func NewDiskManager

func NewDiskManager(config Config, logger boshlog.Logger) DiskManager

type DiskManagerImpl

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

func (DiskManagerImpl) AttachDisk

func (a DiskManagerImpl) AttachDisk(instCid string, diskCid string) error

func (DiskManagerImpl) ChangeDiskStatus

func (a DiskManagerImpl) ChangeDiskStatus(cid string, toStatus DiskStatus, checkFunc func(*ecs.Disk) (bool, error)) error

func (DiskManagerImpl) CreateDisk

func (a DiskManagerImpl) CreateDisk(region string, args *ecs.CreateDiskRequest) (cid string, err error)

func (DiskManagerImpl) CreateSnapshot

func (a DiskManagerImpl) CreateSnapshot(diskCid, snapshotName string) (snapshotId string, err error)

func (DiskManagerImpl) DeleteDisk

func (a DiskManagerImpl) DeleteDisk(diskCid string) error

func (DiskManagerImpl) DeleteSnapshot

func (a DiskManagerImpl) DeleteSnapshot(snapshotCid string) error

func (DiskManagerImpl) DetachDisk

func (a DiskManagerImpl) DetachDisk(instCid, diskCid string) error

func (DiskManagerImpl) GetDisk

func (a DiskManagerImpl) GetDisk(diskCid string) (disk *ecs.Disk, err error)

func (DiskManagerImpl) GetDisks

func (a DiskManagerImpl) GetDisks(instCid string) (disks []ecs.Disk, err error)

func (DiskManagerImpl) ModifyDiskAttribute

func (a DiskManagerImpl) ModifyDiskAttribute(diskCid, name, description string) error

func (DiskManagerImpl) ResizeDisk

func (a DiskManagerImpl) ResizeDisk(diskCid string, size int) error

func (DiskManagerImpl) WaitForDiskStatus

func (a DiskManagerImpl) WaitForDiskStatus(diskCid string, toStatus DiskStatus) (string, error)

type DiskStatus

type DiskStatus string

type EipStatus

type EipStatus string

type ImageFormatType

type ImageFormatType string

type InnerType

type InnerType string

type InstanceManager

type InstanceManager interface {
	GetInstance(cid string) (*ecs.Instance, error)

	CreateInstance(region string, args *ecs.CreateInstanceRequest) (string, error)
	ModifyInstanceAttribute(cid string, name string, description string) error
	AddTags(cid string, tags map[string]string) error

	DeleteInstance(cid string) error

	StartInstance(cid string) error
	StopInstance(cid string) error
	RebootInstance(cid string) error

	GetInstanceStatus(cid string) (InstanceStatus, error)

	// WaitForInstanceStatus(cid string, toStatus ecs.InstanceStatus) (ecs.InstanceStatus, error)
	ChangeInstanceStatus(cid string, toStatus InstanceStatus, checkFunc func(status InstanceStatus) (bool, error)) error

	// Cleanup the left network interfaces
	GetAttachedNetworkInterfaceIds(cid string) []string
	CleanupInstanceNetworkInterfaces(cid string, eniIds []string) error
}

func NewInstanceManager

func NewInstanceManager(config Config, logger boshlog.Logger) InstanceManager

type InstanceManagerImpl

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

func (InstanceManagerImpl) AddTags

func (a InstanceManagerImpl) AddTags(cid string, tags map[string]string) error

func (InstanceManagerImpl) ChangeInstanceStatus

func (a InstanceManagerImpl) ChangeInstanceStatus(cid string, toStatus InstanceStatus, checkFunc func(status InstanceStatus) (bool, error)) error

func (InstanceManagerImpl) CleanupInstanceNetworkInterfaces

func (a InstanceManagerImpl) CleanupInstanceNetworkInterfaces(cid string, eniIds []string) error

func (InstanceManagerImpl) CreateInstance

func (a InstanceManagerImpl) CreateInstance(region string, args *ecs.CreateInstanceRequest) (string, error)

func (InstanceManagerImpl) DeleteInstance

func (a InstanceManagerImpl) DeleteInstance(cid string) error

func (InstanceManagerImpl) GetAttachedNetworkInterfaceIds

func (a InstanceManagerImpl) GetAttachedNetworkInterfaceIds(cid string) []string

func (InstanceManagerImpl) GetInstance

func (a InstanceManagerImpl) GetInstance(cid string) (inst *ecs.Instance, err error)

func (InstanceManagerImpl) GetInstanceStatus

func (a InstanceManagerImpl) GetInstanceStatus(cid string) (InstanceStatus, error)

func (InstanceManagerImpl) GetInstanceUserData

func (a InstanceManagerImpl) GetInstanceUserData()

func (InstanceManagerImpl) ModifyInstanceAttribute

func (a InstanceManagerImpl) ModifyInstanceAttribute(cid, name, description string) error

func (InstanceManagerImpl) RebootInstance

func (a InstanceManagerImpl) RebootInstance(cid string) error

func (InstanceManagerImpl) StartInstance

func (a InstanceManagerImpl) StartInstance(cid string) error

func (InstanceManagerImpl) StopInstance

func (a InstanceManagerImpl) StopInstance(cid string) error

type InstanceStatus

type InstanceStatus string

type Invoker

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

func NewInvoker

func NewInvoker() Invoker

func (*Invoker) AddCatcher

func (a *Invoker) AddCatcher(catcher Catcher)

func (*Invoker) Run

func (a *Invoker) Run(f func() error) error

func (*Invoker) RunUntil

func (a *Invoker) RunUntil(timeout time.Duration, interval time.Duration, f func() (bool, error)) (bool, error)

type NetworkManager

type NetworkManager interface {
	DescribeEip(region, eip string) (ecs.EipAddressInDescribeEipAddresses, error)
	BindEip(region, instanceId, eip string) error
	WaitForEipStatus(region, eip string, toStatus EipStatus) error

	BindSLB(region, instanceId, slbId string, weight int) error
	DescribeSecurityGroupAttribute(region, groupId string) (ecs.DescribeSecurityGroupAttributeResponse, error)
	JoinSecurityGroup(region, instanceId, groupId string) error
}

func NewNetworkManager

func NewNetworkManager(config Config, logger boshlog.Logger) NetworkManager

type NetworkManagerImpl

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

func (NetworkManagerImpl) BindEip

func (a NetworkManagerImpl) BindEip(region, instanceId, eip string) error

func (NetworkManagerImpl) BindSLB

func (a NetworkManagerImpl) BindSLB(region, instanceId string, slbId string, weight int) error

TODO: add retry

func (NetworkManagerImpl) DescribeEip

func (a NetworkManagerImpl) DescribeEip(region, eip string) (eipAddress ecs.EipAddressInDescribeEipAddresses, err error)

func (NetworkManagerImpl) DescribeSecurityGroupAttribute

func (a NetworkManagerImpl) DescribeSecurityGroupAttribute(region, groupId string) (group ecs.DescribeSecurityGroupAttributeResponse, err error)

func (NetworkManagerImpl) JoinSecurityGroup

func (a NetworkManagerImpl) JoinSecurityGroup(region, instanceId, groupId string) error

func (NetworkManagerImpl) WaitForEipStatus

func (a NetworkManagerImpl) WaitForEipStatus(region, eip string, toStatus EipStatus) error

type OpenApi

type OpenApi struct {
	Region           string `json:"region"`
	AvailabilityZone string `json:"availability_zone"`
	AccessEndpoint   string `json:"access_endpoint"`
	AccessKeyId      string `json:"access_key_id"`
	AccessKeySecret  string `json:"access_key_secret"`
	SecurityToken    string `json:"security_token"`
	Encrypted        *bool  `json:"encrypted,omitempty"`
	EcsEndpoint      string `json:"ecs_endpoint"`
	SlbEndpoint      string `json:"slb_endpoint"`
	OssEndpoint      string `json:"oss_endpoint"`
	LocationEndpoint string `json:"location_endpoint"`
}

func (OpenApi) GetAvailabilityZone

func (a OpenApi) GetAvailabilityZone() string

func (OpenApi) GetRegion

func (a OpenApi) GetRegion(region string) string

type OssManager

type OssManager interface {
	CreateBucket(name string, options ...oss.Option) error
	DeleteBucket(name string) error
	GetBucket(name string) (bucket *oss.Bucket, err error)
	UploadFile(bucket oss.Bucket, objectKey, filePath string, partSize int64, options ...oss.Option) error
	MultipartUploadFile(bucket oss.Bucket, objectKey, filePath string, partSize int64, options ...oss.Option) error
	DeleteObject(bucket oss.Bucket, name string) error
}

func NewOssManager

func NewOssManager(config Config, logger boshlog.Logger) OssManager

type OssManagerImpl

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

func (OssManagerImpl) CreateBucket

func (a OssManagerImpl) CreateBucket(name string, options ...oss.Option) error

func (OssManagerImpl) DeleteBucket

func (a OssManagerImpl) DeleteBucket(name string) error

func (OssManagerImpl) DeleteObject

func (a OssManagerImpl) DeleteObject(bucket oss.Bucket, name string) error

func (OssManagerImpl) GetBucket

func (a OssManagerImpl) GetBucket(name string) (bucket *oss.Bucket, err error)

func (OssManagerImpl) MultipartUploadFile

func (a OssManagerImpl) MultipartUploadFile(
	bucket oss.Bucket, objectKey, filePath string, partSize int64, options ...oss.Option) error

func (OssManagerImpl) UploadFile

func (a OssManagerImpl) UploadFile(
	bucket oss.Bucket, objectKey, filePath string, partSize int64, options ...oss.Option) error

type ProviderError

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

An Error represents a custom error for Terraform failure response

func (*ProviderError) Error

func (e *ProviderError) Error() string

func (*ProviderError) ErrorCode

func (err *ProviderError) ErrorCode() string

func (*ProviderError) Message

func (err *ProviderError) Message() string

type RegistryConfig

type RegistryConfig struct {
	User     string      `json:"user"`
	Password string      `json:"password"`
	Protocol string      `json:"protocol"`
	Host     string      `json:"host"`
	Port     json.Number `json:"port"`
}

func (RegistryConfig) GetEndpoint

func (a RegistryConfig) GetEndpoint() string

func (RegistryConfig) IsEmpty

func (a RegistryConfig) IsEmpty() bool

func (RegistryConfig) ToInstanceUserData

func (a RegistryConfig) ToInstanceUserData() string

type RegistryManager

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

func NewRegistryManager

func NewRegistryManager(c Config, logger boshlog.Logger) RegistryManager

func (RegistryManager) Delete

func (a RegistryManager) Delete(instanceID string) error

func (RegistryManager) Fetch

func (a RegistryManager) Fetch(instanceID string) (registry.AgentSettings, error)

func (RegistryManager) Update

func (a RegistryManager) Update(instanceID string, settings registry.AgentSettings) error

type SpotStrategyType

type SpotStrategyType string

type StemcellManager

type StemcellManager interface {
	FindStemcellById(id string) (*ecs.Image, error)
	DeleteStemcell(id string) error
	ImportImage(args *ecs.ImportImageRequest) (string, error)
	OpenLocalFile(path string) (*os.File, error)
	WaitForImageReady(id string) error
}

func NewStemcellManager

func NewStemcellManager(config Config, logger boshlog.Logger) StemcellManager

type StemcellManagerImpl

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

func (StemcellManagerImpl) DeleteStemcell

func (a StemcellManagerImpl) DeleteStemcell(id string) error

func (StemcellManagerImpl) FindStemcellById

func (a StemcellManagerImpl) FindStemcellById(id string) (*ecs.Image, error)

func (StemcellManagerImpl) ImportImage

func (a StemcellManagerImpl) ImportImage(args *ecs.ImportImageRequest) (string, error)

func (StemcellManagerImpl) OpenLocalFile

func (a StemcellManagerImpl) OpenLocalFile(path string) (*os.File, error)

func (StemcellManagerImpl) WaitForImage

func (a StemcellManagerImpl) WaitForImage(regionId, imageId string, timeout int) error

Wait Image ready

func (StemcellManagerImpl) WaitForImageReady

func (a StemcellManagerImpl) WaitForImageReady(id string) error

import image from oss may take >=15min we set timeout value to 30min, if needed turn it up

type TagResourceType

type TagResourceType string

Jump to

Keyboard shortcuts

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