action

package
v28.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: Apache-2.0 Imports: 21 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

* 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

* 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 (
	AlicloudImageNamePrefix    = "stemcell"
	MinImageDiskSize           = 5 //in GB
	OSS_BUCKET_NAME_MAX_LENGTH = 64
	PART_SIZE                  = 5 * 1024 * 1024 // 5MB
)
View Source
const (
	PrePaid  = InstanceChargeType("PrePaid")
	PostPaid = InstanceChargeType("PostPaid")
)
View Source
const (
	DefaultDiskCategory     = alicloud.DiskCategoryCloudEfficiency
	DefaultSystemDiskSizeGB = 40
	AmendSmallDiskSize      = true
)
View Source
const (
	NetworkTypeManual  = "manual"
	NetworkTypeDynamic = "dynamic"
	NetworkTypeVip     = "vip"
)

Variables

This section is empty.

Functions

func ConvertToGB

func ConvertToGB(size float64) int

Types

type AttachDiskMethod

type AttachDiskMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func (AttachDiskMethod) AttachDisk

func (a AttachDiskMethod) AttachDisk(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) error

type CalculateVMCloudPropertiesMethod

type CalculateVMCloudPropertiesMethod struct {
	CallContext
}

func NewCalculateVMCloudPropertiesMethod

func NewCalculateVMCloudPropertiesMethod(cc CallContext) CalculateVMCloudPropertiesMethod

func (CalculateVMCloudPropertiesMethod) CalculateVMCloudProperties

func (a CalculateVMCloudPropertiesMethod) CalculateVMCloudProperties(resources apiv1.VMResources) (apiv1.VMCloudProps, error)

type CallContext

type CallContext struct {
	Input         string
	Logger        boshlog.Logger
	Config        alicloud.Config
	ConfigConcern bool
}

func NewCallContext

func NewCallContext(input []byte, logger boshlog.Logger, config alicloud.Config) CallContext

func (CallContext) Errorf

func (c CallContext) Errorf(msg string, args ...interface{}) error

func (CallContext) WrapError

func (c CallContext) WrapError(err error, msg string) error

func (CallContext) WrapErrorf

func (c CallContext) WrapErrorf(err error, msg string, args ...interface{}) error

type Caller

type Caller struct {
	Config alicloud.Config
	Logger boshlog.Logger
	Services
}

func NewCaller

func NewCaller(config alicloud.Config, logger boshlog.Logger) Caller

func NewCallerWithServices

func NewCallerWithServices(config alicloud.Config, logger boshlog.Logger, services Services) Caller

func (Caller) Call

func (c Caller) Call(method string, args ...interface{}) (string, error)

func (Caller) CallGeneric

func (c Caller) CallGeneric(method string, args ...interface{}) (interface{}, error)

func (Caller) Run

func (c Caller) Run(input []byte) CpiResponse

type CpiError

type CpiError struct {
	Type      string `json:"type,omitempty"`
	Message   string `json:"message"`
	OkToRetry bool   `json:"ok_to_retry"`
}

func (CpiError) ToError

func (e CpiError) ToError() error

type CpiResponse

type CpiResponse struct {
	Result interface{} `json:"result"`
	Error  interface{} `json:"error"`
	Log    string      `json:"log"`
}

func WrapErrorResponse

func WrapErrorResponse(err error, format string, args ...interface{}) CpiResponse

func (CpiResponse) GetError

func (r CpiResponse) GetError() error

func (CpiResponse) GetResult

func (r CpiResponse) GetResult() interface{}

func (CpiResponse) GetResultString

func (r CpiResponse) GetResultString() string

type CreateDiskMethod

type CreateDiskMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewCreateDiskMethod

func NewCreateDiskMethod(cc CallContext, disks alicloud.DiskManager, instances alicloud.InstanceManager) CreateDiskMethod

func (CreateDiskMethod) CreateDisk

func (a CreateDiskMethod) CreateDisk(size int, props apiv1.DiskCloudProps, vmCid *apiv1.VMCID) (apiv1.DiskCID, error)

type CreateStemcellMethod

type CreateStemcellMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewCreateStemcellMethod

func NewCreateStemcellMethod(cc CallContext, stemcells alicloud.StemcellManager, osses alicloud.OssManager) CreateStemcellMethod

func (CreateStemcellMethod) CreateFromTarball

func (a CreateStemcellMethod) CreateFromTarball(imagePath string, props StemcellProps) (string, error)

func (CreateStemcellMethod) CreateFromURL

func (a CreateStemcellMethod) CreateFromURL(props StemcellProps) (string, error)

func (CreateStemcellMethod) CreateStemcell

func (a CreateStemcellMethod) CreateStemcell(imagePath string, cloudProps apiv1.StemcellCloudProps) (apiv1.StemcellCID, error)

create stemcell policy:

  1. stemcell metadate set in cloudProps
  2. we provide three ways to create stemcell 2.1 region-imageId format, return Stemcell directly 2.2 source URL, put the raw image on OSS, then create image by the oss url 2.3 local tarball, upload the tarball on OSS, the create image by the oss url

type CreateVMMethod

type CreateVMMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewCreateVMMethod

func NewCreateVMMethod(
	cc CallContext,
	stemcells alicloud.StemcellManager,
	instances alicloud.InstanceManager,
	disks alicloud.DiskManager,
	networks alicloud.NetworkManager,
	registry registry.Client) CreateVMMethod

func (CreateVMMethod) CreateVM

func (a CreateVMMethod) CreateVM(
	agentID apiv1.AgentID, stemcellCID apiv1.StemcellCID,
	cloudProps apiv1.VMCloudProps, networkArgs apiv1.Networks,
	associatedDiskCIDs []apiv1.DiskCID, env apiv1.VMEnv) (apiv1.VMCID, error)

func (CreateVMMethod) UpdateAgentSettings

func (a CreateVMMethod) UpdateAgentSettings(instId string, agentSettings registry.AgentSettings) error

type DeleteDiskMethod

type DeleteDiskMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewDeleteDiskMethod

func NewDeleteDiskMethod(cc CallContext, disks alicloud.DiskManager, instances alicloud.InstanceManager) DeleteDiskMethod

func (DeleteDiskMethod) DeleteDisk

func (a DeleteDiskMethod) DeleteDisk(diskCID apiv1.DiskCID) error

type DeleteSnapshotMethod

type DeleteSnapshotMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewDeleteSnapshotMethod

func NewDeleteSnapshotMethod(cc CallContext, disks alicloud.DiskManager) DeleteSnapshotMethod

func (DeleteSnapshotMethod) DeleteSnapshot

func (a DeleteSnapshotMethod) DeleteSnapshot(snapshotCID apiv1.SnapshotCID) error

type DeleteStemcellMethod

type DeleteStemcellMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewDeleteStemcellMethod

func NewDeleteStemcellMethod(cc CallContext, stemcells alicloud.StemcellManager) DeleteStemcellMethod

func (DeleteStemcellMethod) DeleteStemcell

func (a DeleteStemcellMethod) DeleteStemcell(cid apiv1.StemcellCID) error

type DeleteVMMethod

type DeleteVMMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewDeleteVMMethod

func NewDeleteVMMethod(cc CallContext, instances alicloud.InstanceManager) DeleteVMMethod

func (DeleteVMMethod) DeleteVM

func (a DeleteVMMethod) DeleteVM(cid apiv1.VMCID) error

type DetachDiskMethod

type DetachDiskMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewDetachDiskMethod

func NewDetachDiskMethod(cc CallContext, disks alicloud.DiskManager, rc registry.Client) DetachDiskMethod

func (DetachDiskMethod) DetachDisk

func (a DetachDiskMethod) DetachDisk(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) error

type DiskInfo

type DiskInfo struct {
	SizeRaw            interface{} `json:"size"`
	Category           string      `json:"category"`
	Encrypted          *bool       `json:"encrypted,omitempty"`
	DeleteWithInstance *bool       `json:"delete_with_instance,omitempty"`
	// contains filtered or unexported fields
}

func NewDiskInfo

func NewDiskInfo() DiskInfo

func NewDiskInfoWithSize

func NewDiskInfoWithSize(size int, props apiv1.DiskCloudProps) (DiskInfo, error)

func (DiskInfo) GetCategory

func (a DiskInfo) GetCategory() alicloud.DiskCategory

func (DiskInfo) GetPath

func (a DiskInfo) GetPath() string

func (DiskInfo) GetSizeGB

func (a DiskInfo) GetSizeGB() int

func (DiskInfo) Validate

func (a DiskInfo) Validate(isSystem bool) (DiskInfo, error)

type Disks

type Disks struct {
	SystemDisk      DiskInfo
	EphemeralDisk   DiskInfo
	PersistentDisks []PersistentDisk
}

func NewDisksWithProps

func NewDisksWithProps(systemDisk DiskInfo, ephemeralDisk DiskInfo) (Disks, error)

func (Disks) AsRegistrySettings

func (a Disks) AsRegistrySettings() registry.DisksSettings

func (Disks) AssociatePersistentDisk

func (a Disks) AssociatePersistentDisk(cid string, path string)

func (Disks) FillCreateInstanceArgs

func (a Disks) FillCreateInstanceArgs(golbalEncrypt *bool, args *ecs.CreateInstanceRequest)

type Factory

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

func NewFactory

func NewFactory(cc CallContext, services Services) Factory

func (Factory) New

func (f Factory) New(_ apiv1.CallContext) (apiv1.CPI, error)

type GetDisksMethod

type GetDisksMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewGetDisksMethod

func NewGetDisksMethod(cc CallContext, disks alicloud.DiskManager) GetDisksMethod

func (GetDisksMethod) GetDisks

func (a GetDisksMethod) GetDisks(cid apiv1.VMCID) ([]apiv1.DiskCID, error)

type HasDiskMethod

type HasDiskMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewHasDiskMethod

func NewHasDiskMethod(cc CallContext, disks alicloud.DiskManager) HasDiskMethod

func (HasDiskMethod) HasDisk

func (a HasDiskMethod) HasDisk(diskCID apiv1.DiskCID) (bool, error)

func (HasDiskMethod) ResizeDisk

func (a HasDiskMethod) ResizeDisk(diskCID apiv1.DiskCID, size int) error

type HasVMMethod

type HasVMMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewHasVMMethod

func NewHasVMMethod(cc CallContext, instances alicloud.InstanceManager) HasVMMethod

func (HasVMMethod) HasVM

func (a HasVMMethod) HasVM(cid apiv1.VMCID) (bool, error)

type InfoMethod

type InfoMethod struct{}

func NewInfoMethod

func NewInfoMethod() InfoMethod

func (InfoMethod) Info

func (a InfoMethod) Info() (apiv1.Info, error)

type InstanceChargeType

type InstanceChargeType string

type InstanceProps

type InstanceProps struct {
	EphemeralDisk DiskInfo `json:"ephemeral_disk"`
	SystemDisk    DiskInfo `json:"system_disk"`

	Region           string                    `json:"region"`
	AvailabilityZone string                    `json:"availability_zone"`
	InstanceName     string                    `json:"instance_name"`
	InstanceType     string                    `json:"instance_type"`
	Slbs             []string                  `json:"slbs"`
	SlbWeight        json.Number               `json:"slb_weight"`
	Password         string                    `json:"password"`
	KeyPairName      string                    `json:"key_pair_name"`
	SecurityGroupIds []string                  `json:"security_group_ids"`
	ChargeType       string                    `json:"charge_type"`
	ChargePeriod     json.Number               `json:"charge_period"`
	ChargePeriodUnit string                    `json:"charge_period_unit"`
	AutoRenew        string                    `json:"auto_renew"`
	AutoRenewPeriod  json.Number               `json:"auto_renew_period"`
	SpotStrategy     alicloud.SpotStrategyType `json:"spot_strategy"`
	SpotPriceLimit   float64                   `json:"spot_price_limit"`
	RamRoleName      string                    `json:"ram_role_name"`
	StemcellId       string                    `json:"stemcell_id"`
}

Instance properties: ref to docs/bosh/alicloud-cpi.md spot https://help.aliyun.com/knowledge_detail/48269.html ram profile https://help.aliyun.com/document_detail/54579.html?spm=5176.doc25481.6.797.UVS7aB

func NewInstanceProps

func NewInstanceProps() InstanceProps

type MetaData

type MetaData map[string]interface{}

type MetaInput

type MetaInput interface {
	MarshalJSON() ([]byte, error)
}

type NetworkProps

type NetworkProps struct {
	SecurityGroupId    string   `json:"security_group_id"`
	SecurityGroupIds   []string `json:"security_group_ids"`
	VSwitchId          string   `json:"vswitch_id"`
	InternetChargeType string   `json:"internet_charge_type,omitempty"`
}

type Networks

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

func NewNetworks

func NewNetworks(args apiv1.Networks) (Networks, error)

func (Networks) AsRegistrySettings

func (a Networks) AsRegistrySettings() registry.NetworksSettings

func (Networks) FillCreateInstanceArgs

func (a Networks) FillCreateInstanceArgs(args *ecs.CreateInstanceRequest) error

func (Networks) GetVips

func (a Networks) GetVips() []string

func (Networks) HasVip

func (a Networks) HasVip() bool

type PersistentDisk

type PersistentDisk struct {
	Cid      string
	VolumeId string
	Path     string
}

type RebootVMMethod

type RebootVMMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewRebootVMMethod

func NewRebootVMMethod(cc CallContext, instances alicloud.InstanceManager) RebootVMMethod

func (RebootVMMethod) RebootVM

func (a RebootVMMethod) RebootVM(cid apiv1.VMCID) error

type ResizeDiskMethod

type ResizeDiskMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewResizeDiskMethod

func NewResizeDiskMethod(cc CallContext, disks alicloud.DiskManager) ResizeDiskMethod

type Services

type Services struct {
	Stemcells alicloud.StemcellManager
	Osses     alicloud.OssManager
	Instances alicloud.InstanceManager
	Disks     alicloud.DiskManager
	Networks  alicloud.NetworkManager
	Registry  registry.Client
}

type SetDiskMetadataMethod

type SetDiskMetadataMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func (SetDiskMetadataMethod) SetDiskMetadata

func (a SetDiskMetadataMethod) SetDiskMetadata(diskCID apiv1.DiskCID, meta apiv1.DiskMeta) error

type SetVMMetadataMethod

type SetVMMetadataMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewSetVMMetadataMethod

func NewSetVMMetadataMethod(cc CallContext, instances alicloud.InstanceManager) SetVMMetadataMethod

func (SetVMMetadataMethod) SetVMMetadata

func (a SetVMMetadataMethod) SetVMMetadata(vmCID apiv1.VMCID, meta apiv1.VMMeta) error

type SnapshotDiskMethod

type SnapshotDiskMethod struct {
	CallContext
	// contains filtered or unexported fields
}

func NewSnapshotDiskMethod

func NewSnapshotDiskMethod(cc CallContext, disks alicloud.DiskManager) SnapshotDiskMethod

func (SnapshotDiskMethod) SnapshotDisk

func (a SnapshotDiskMethod) SnapshotDisk(diskCID apiv1.DiskCID, meta apiv1.DiskMeta) (apiv1.SnapshotCID, error)

type StemcellProps

type StemcellProps struct {
	Architecture    string      `json:"architecture"`
	ContainerFormat string      `json:"container_format"`
	Disk            interface{} `json:"disk"`
	DiskFormat      string      `json:"disk_format"`

	Hypervisor string `json:"hypervisor"`
	Name       string `json:"name"`
	OsDistro   string `json:"os_distro"`
	OsType     string `json:"os_type"`
	//RootDeviceName string 	`json:"root_device_name"`
	SourceUrl string `json:"source_url"`
	//SourceSha1    string `json:"raw_disk_sha1,omitempty"`
	OSSBucket   string `json:"oss_bucket"`
	OSSObject   string `json:"oss_object"`
	Description string `json:"description,omitempty"`
	//	Version string 			`json:"version"`		TODO  sometimes string, and sometimes int
	Images map[string]interface{} `json:"image_id"`
	// contains filtered or unexported fields
}

func (StemcellProps) FindStemcellId

func (a StemcellProps) FindStemcellId(region string) (string, error)

func (StemcellProps) GetDiskGB

func (a StemcellProps) GetDiskGB() int

Image size minimum is 5GB. Refer to https://www.alibabacloud.com/help/doc-detail/25542.htm

func (StemcellProps) Validate

func (a StemcellProps) Validate() (StemcellProps, error)

Jump to

Keyboard shortcuts

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