aliyun

package
v0.0.0-...-d5b31fc Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 16 Imported by: 0

README

See More:

AliYun OpenAPI Docs

https://help.aliyun.com/document_detail/25692.html?spm=5176.doc25692.6.950.gbUX1z
https://help.aliyun.com/document_detail/25506.html?spm=5176.doc25692.6.805.2yxrNh
https://help.aliyun.com/document_detail/25484.html?spm=5176.doc25692.3.3.MqmNVN
https://help.aliyun.com/document_detail/25491.html?spm=5176.doc25484.6.791.6mMhxN

AliYun FAQ Errors

https://help.aliyun.com/document_detail/53438.html

Refs

https://github.com/aliyun/aliyun-oss-go-sdk
https://github.com/denverdino/aliyungo
https://github.com/ChangjunZhao/aliyun-api-golang/tree/master/ecs

Documentation

Overview

Package aliyun ... this file rewrap existing methods to implement the cloudsvr.Handler interface

Package aliyun ...

Most borrowed from:

github.com/ChangjunZhao/aliyun-api-golang/ecs

Index

Constants

This section is empty.

Variables

View Source
var (
	// OsImage is exported to make pass golint
	OsImage = "centos_7_03_64_40G_alibase_20170710.vhd"
	// NodeName is exported to make pass golint
	NodeName = "inf-agent-aliyun-node"
	// NodeLabels is exported to make pass golint
	NodeLabels = map[string]string{cloudsvr.CLOUDFLAGKEY: CloudType}
)
View Source
var (
	// CloudType is exported
	CloudType = "aliyun"
)
View Source
var (
	// DefaultAPIEndPoint is exported
	DefaultAPIEndPoint = "https://ecs.aliyuncs.com/"
)

Functions

This section is empty.

Types

type AccountType

type AccountType struct {
	AliyunID string
}

AccountType is exported

type AllocatePublicIPAddressResponse

type AllocatePublicIPAddressResponse struct {
	EcsBaseResponse
	IPAddress string `json:"IpAddress"`
}

AllocatePublicIPAddressResponse is exported

type AuthorizeSecurityGroupRequest

type AuthorizeSecurityGroupRequest struct {
	SecurityGroupID         string // must
	RegionID                string // must
	IPProtocol              string // must tcp/udp/icmp/gre/all
	PortRange               string // must 1-100 / -1/-1
	Policy                  string // accept, drop
	NicType                 string // internet(default), intranet
	Priority                string // [1-100]
	SourceCidrIP            string // 0.0.0.0/0 (default)
	SourceGroupID           string
	SourceGroupOwnerAccount string
	DestCidrIP              string
	DestGroupID             string
	DestGroupOwnerAccount   string
}

AuthorizeSecurityGroupRequest is exported

func (*AuthorizeSecurityGroupRequest) AddToParameters

func (r *AuthorizeSecurityGroupRequest) AddToParameters(params *orderparam.Params)

AddToParameters is exported

func (*AuthorizeSecurityGroupRequest) Validate

func (r *AuthorizeSecurityGroupRequest) Validate() error

Validate is exported

type AutoSnapshotExecutionStatusType

type AutoSnapshotExecutionStatusType struct {
	SystemDiskExecutionStatus string
	DataDiskExecutionStatus   string
}

AutoSnapshotExecutionStatusType is exported

type AutoSnapshotPolicyType

type AutoSnapshotPolicyType struct {
	SystemDiskPolicyEnabled           string
	SystemDiskPolicyTimePeriod        int
	SystemDiskPolicyRetentionDays     int
	SystemDiskPolicyRetentionLastWeek string
	DataDiskPolicyEnabled             string
	DataDiskPolicyTimePeriod          int
	DataDiskPolicyRetentionDays       int
	DataDiskPolicyRetentionLastWeek   string
}

AutoSnapshotPolicyType is exported

type AvailableDiskCategoriesType

type AvailableDiskCategoriesType struct {
	DiskCategories []string `json:"DiskCategories"` // cloud, ephemeral, ephemeral_ssd
}

AvailableDiskCategoriesType is exported

type AvailableInstanceTypes

type AvailableInstanceTypes struct {
	InstanceTypes []string `json:"InstanceTypes"`
}

AvailableInstanceTypes is exported

type AvailableResourceCreationType

type AvailableResourceCreationType struct {
	ResourceTypes []string `json:"ResourceTypes"` // Instance, Disk, VSwitch
}

AvailableResourceCreationType is exported

type AvailableResources

type AvailableResources struct {
	// contains all of supported DiskCategory / NetworkCategory / InstanceType / SystemDiskCategory
	// but the returned data is not exactly, so we do NOT actually using this
	ResourcesInfo []interface{} `json:"ResourcesInfo"`
}

AvailableResources is exported

type AvailableVolumeCategories

type AvailableVolumeCategories struct {
	VolumeCategories []string `json:"VolumeCategories"`
}

AvailableVolumeCategories is exported

type ClusterType

type ClusterType struct {
	ClusterID string `json:"ClusterId"`
}

ClusterType is exported

type Config

type Config struct {
	EndPoint  string `json:"endpoint,omitempty"`
	AccessID  string `json:"access_id"`
	AccessKey string `json:"access_key"`
}

Config is exported

func (*Config) Valid

func (cfg *Config) Valid() error

Valid is exported

type CreateInstanceRequest

type CreateInstanceRequest struct {
	RegionID                string // must
	ZoneID                  string
	ImageID                 string // must
	InstanceType            string // must: https://help.aliyun.com/document_detail/25378.html?spm=5176.doc25499.2.10.dzAw7Z
	SecurityGroupID         string // must
	Password                string // not required, if setup, must call Api via https
	InstanceName            string
	Description             string
	InternetChargeType      string
	InternetMaxBandwidthIn  string
	InternetMaxBandwidthOut string
	HostName                string
	IoOptimized             string
	SystemDiskCategory      string
	SystemDiskDiskName      string
	SystemDiskDescription   string
	VSwitchID               string
	PrivateIPAddress        string
	InstanceChargeType      string            // PrePaid, PostPaid(default, require RMB 100+)
	Period                  int               // required if InstanceChargeType == PrePaid
	Labels                  map[string]string // max 5
}

CreateInstanceRequest is exported See More: https://help.aliyun.com/document_detail/25499.html?spm=5176.doc25506.6.798.eeuP5g

func (*CreateInstanceRequest) AddToParameters

func (r *CreateInstanceRequest) AddToParameters(params *orderparam.Params)

AddToParameters should be called after Validate verify checking

func (*CreateInstanceRequest) Validate

func (r *CreateInstanceRequest) Validate() error

Validate is exported

type CreateInstanceResponse

type CreateInstanceResponse struct {
	EcsBaseResponse
	InstanceID string `json:"InstanceId"`
}

CreateInstanceResponse is exported

type CreateSecurityGroupRequest

type CreateSecurityGroupRequest struct {
	RegionID          string // must
	SecurityGroupName string
	Description       string
	VpcID             string
}

CreateSecurityGroupRequest is exported See More: https://help.aliyun.com/document_detail/25553.html?spm=5176.doc25499.6.857.CzabIR

func (*CreateSecurityGroupRequest) AddToParameters

func (r *CreateSecurityGroupRequest) AddToParameters(params *orderparam.Params)

AddToParameters should be called after Validate verify checking

func (*CreateSecurityGroupRequest) Validate

func (r *CreateSecurityGroupRequest) Validate() error

Validate is exported

type CreateSecurityGroupResponse

type CreateSecurityGroupResponse struct {
	EcsBaseResponse
	SecurityGroupID string `json:"SecurityGroupId"`
}

CreateSecurityGroupResponse is exported

type DescribeInstanceTypesResponse

type DescribeInstanceTypesResponse struct {
	EcsBaseResponse
	InstanceTypes InstanceTypes `json:"InstanceTypes"`
}

DescribeInstanceTypesResponse is exported

type DescribeInstancesResponse

type DescribeInstancesResponse struct {
	EcsBaseResponse
	TotalCount int       `json:"TotalCount"`
	PageNumber int       `json:"PageNumber"`
	PageSize   int       `json:"PageSize"`
	Instances  Instances `json:"Instances"`
}

DescribeInstancesResponse is exported

type DescribeRegionZonesResponse

type DescribeRegionZonesResponse struct {
	EcsBaseResponse
	Zones Zones `json:"Zones"`
}

DescribeRegionZonesResponse is exported

NOTE: no use because the returned data is not exactly

type DescribeRegionsResponse

type DescribeRegionsResponse struct {
	EcsBaseResponse
	Response Regions `json:"Regions"`
}

DescribeRegionsResponse is exported

type DiskDeviceMapping

type DiskDeviceMapping struct {
	SnapshotID string
	Size       string
	Device     string
}

DiskDeviceMapping is exported

type DiskItemType

type DiskItemType struct {
	DiskID             string
	RegionID           string
	ZoneID             string
	DiskName           string
	Description        string
	Type               string
	Category           string
	Size               int
	ImageID            string
	SourceSnapshotID   string
	ProductCode        string
	Portable           string
	Status             string
	OperationLocks     OperationLocksType
	InstanceID         string
	Device             string
	DeleteWithInstance string
	DeleteAutoSnapshot string
	EnableAutoSnapshot string
	CreationTime       string
	AttachedTime       string
	DetachedTime       string
}

DiskItemType is exported

type DiskMonitorDataType

type DiskMonitorDataType struct {
	DiskID    string
	IOPSRead  int
	IOPSWrite int
	IOPSTotal int
	BPSRead   int
	BPSWrite  int
	BPSTotal  int
	TimeStamp string
}

DiskMonitorDataType is exported

type DiskSetType

type DiskSetType struct {
	Disk DiskItemType
}

DiskSetType is exported

type EcsBaseResponse

type EcsBaseResponse struct {
	RequestID string `json:"RequestId"`
}

EcsBaseResponse is exported

type EcsErrorResponse

type EcsErrorResponse struct {
	EcsBaseResponse
	HostID  string `json:"HostId"`
	Code    string `json:"Code"`
	Message string `json:"Message"`
}

EcsErrorResponse is exported

type EipAddressAssociateType

type EipAddressAssociateType struct {
	AllocationID       string `json:"AllocationId"`
	IPAddress          string `json:"IpAddress"`
	Bandwidth          int    `json:"Bandwidth"`
	InternetChargeType string `json:"InternetChargeType"`
}

EipAddressAssociateType is exported

type EipAddressSetType

type EipAddressSetType struct {
	RegionID           string
	IPAddress          string
	AllocationID       string
	Status             string
	InstanceID         string
	Bandwidth          int
	InternetChargeType string
	OperationLocks     OperationLocksType
	AllocationTime     string
}

EipAddressSetType is exported

type EipMonitorDataType

type EipMonitorDataType struct {
	EipRX        int
	EipTX        int
	EipFlow      int
	EipBandwidth int
	EipPackets   int
	TimeStamp    string
}

EipMonitorDataType is exported

type IPAddressSetType

type IPAddressSetType struct {
	IPAddress []string `json:"IpAddress"`
}

IPAddressSetType is exported

type IPRangeSetType

type IPRangeSetType struct {
	IPAddress string // CIDR
	NicType   string // internet, intranet
}

IPRangeSetType is exported

type ImageType

type ImageType struct {
	ImageID            string
	ImageVersion       string
	Architecture       string
	ImageName          string
	Description        string
	Size               int
	ImageOwnerAlias    string
	OSName             string
	DiskDeviceMappings DiskDeviceMapping
	ProductCode        string
	IsSubscribed       string
	Progress           string
	Status             string
	CreationTime       string
}

ImageType is exported

type InstanceAttributesType

type InstanceAttributesType struct {
	InstanceID              string                  `json:"InstanceId"`
	InstanceName            string                  `json:"InstanceName"`
	Description             string                  `json:"Description"`
	ImageID                 string                  `json:"ImageId"`
	RegionID                string                  `json:"RegionId"`
	ZoneID                  string                  `json:"ZoneId"`
	InstanceType            string                  `json:"InstanceType"`
	HostName                string                  `json:"HostName"`
	Status                  string                  `json:"Status"`
	SecurityGroupIDs        SecurityGroupIDSetType  `json:"SecurityGroupIds"`
	InnerIPAddress          IPAddressSetType        `json:"InnerIpAddress"`
	PublicIPAddress         IPAddressSetType        `json:"PublicIpAddress"`
	InternetMaxBandwidthIn  int                     `json:"InternetMaxBandwidthIn"`
	InternetMaxBandwidthOut int                     `json:"InternetMaxBandwidthOut"`
	InternetChargeType      string                  `json:"InternetChargeType"`
	CreationTime            string                  `json:"CreationTime"`
	VpcAttributes           VpcAttributesType       `json:"VpcAttributes"`
	EipAddress              EipAddressAssociateType `json:"EipAddress"`
	InstanceNetworkType     string                  `json:"InstanceNetworkType"`
	OperationLocks          OperationLocksType      `json:"OperationLocks"`
	Tags                    Tags                    `json:"Tags"` // extended
}

InstanceAttributesType is exported

type InstanceMonitorDataType

type InstanceMonitorDataType struct {
	InstanceID        string
	CPU               int
	IntranetRX        int
	IntranetTX        int
	IntranetBandwidth int
	InternetRX        int
	InternetTX        int
	InternetBandwidth int
	IOPSRead          int
	IOPSWrite         int
	BPSRead           int
	BPSWrite          int
	TimeStamp         string
}

InstanceMonitorDataType is exported

type InstanceTypeItemType

type InstanceTypeItemType struct {
	InstanceTypeID       string  `json:"InstanceTypeId"`
	CPUCoreCount         int     `json:"CpuCoreCount"`
	MemorySize           float64 `json:"MemorySize"`
	GPUSpec              string  `json:"GPUSpec"`
	GPUAmount            int     `json:"GPUAmount"`
	InstanceTypeFamily   string  `json:"InstanceTypeFamily"`
	LocalStorageCategory string  `json:"LocalStorageCategory"`
}

InstanceTypeItemType is exported

type InstanceTypes

type InstanceTypes struct {
	InstanceType []InstanceTypeItemType `json:"InstanceType"`
}

InstanceTypes is exported

type Instances

type Instances struct {
	Instance []InstanceAttributesType `json:"Instance"`
}

Instances is exported

type OperationLocksType

type OperationLocksType struct {
	LockReason []string `json:"LockReason"` // financial, security
}

OperationLocksType is exported

type RegionType

type RegionType struct {
	RegionID  string `json:"RegionId"`
	LocalName string `json:"LocalName"`
}

RegionType is exported

type Regions

type Regions struct {
	Regions []RegionType `json:"Region"`
}

Regions is exported

type RouteEntrySetType

type RouteEntrySetType struct {
	RouteTableID         string
	DestinationCidrBlock string
	Type                 string
	NextHopID            string
	Status               string
}

RouteEntrySetType is exported

type RouteTableSetType

type RouteTableSetType struct {
	VRouterID      string
	RouteTableID   string
	RouteEntrys    []RouteEntrySetType
	RouteTableType string
	CreationTime   string
}

RouteTableSetType is exported

type SDK

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

SDK is an implement of CloudSvr

func Setup

func Setup(cfg *Config) (*SDK, error)

Setup is exported

func (*SDK) APIEndPoint

func (sdk *SDK) APIEndPoint() string

APIEndPoint is exported

func (*SDK) AccessID

func (sdk *SDK) AccessID() string

AccessID is exported

func (*SDK) AccessKey

func (sdk *SDK) AccessKey() string

AccessKey is exported

func (*SDK) AssignEcsPublicIP

func (sdk *SDK) AssignEcsPublicIP(id string) (string, error)

AssignEcsPublicIP assign a public ip to specified ecs instance note that Ecs must be `Running` or `Stopped` status

func (*SDK) AuthorizeSecurityGroup

func (sdk *SDK) AuthorizeSecurityGroup(req *AuthorizeSecurityGroupRequest) error

AuthorizeSecurityGroup create an authorization rule within specified security group

func (*SDK) InspectEcs

func (sdk *SDK) InspectEcs(regionID, instanceID string) (InstanceAttributesType, error)

InspectEcs show details of a given ecs instance

func (*SDK) InspectNode

func (sdk *SDK) InspectNode(id, regionOrZone string) (interface{}, error)

InspectNode show details of one given ecs instance

func (*SDK) ListCloudRegions

func (sdk *SDK) ListCloudRegions() ([]*cloudsvr.CloudRegion, error)

ListCloudRegions implement cloudsvr.Handler

func (*SDK) ListCloudTypes

func (sdk *SDK) ListCloudTypes(region string) ([]*cloudsvr.CloudNodeType, error)

ListCloudTypes implement cloudsvr.Handler

func (*SDK) ListEcses

func (sdk *SDK) ListEcses(regionID string) ([]InstanceAttributesType, error)

ListEcses show all of ecs instances for a specified region (regionID parameter set) or all of regions (regionID parameter empty)

func (*SDK) ListInstanceTypes

func (sdk *SDK) ListInstanceTypes(minCPU, maxCPU, minMem, maxMem int) ([]InstanceTypeItemType, error)

ListInstanceTypes show all of instance types aliyun supported support cpu / memory minimal/maximize filter parameters

func (*SDK) ListNodes

func (sdk *SDK) ListNodes() ([]*cloudsvr.CloudNode, error)

ListNodes list all aliyun ecs instances with labels key: CLOUDFLAGKEY the nodes listed does NOT have any auth fields `User` `Password` note: aliyun's api is much slower, use concurrency to speed up

func (*SDK) ListRegionZones

func (sdk *SDK) ListRegionZones(regionID string) ([]ZoneType, error)

ListRegionZones show all of zones under a specified region. but the returned zone availble resources can't be used because the data is not exactly note: Deprecated

func (*SDK) ListRegions

func (sdk *SDK) ListRegions() ([]RegionType, error)

ListRegions show all of regions aliyun supported

func (*SDK) NewEcs

func (sdk *SDK) NewEcs(req *CreateInstanceRequest) (string, error)

NewEcs create a new ecs instance with given settings note that Ecs is `Stopped` status after this call

func (*SDK) NewNode

func (sdk *SDK) NewNode(prefer *cloudsvr.PreferAttrs) (*cloudsvr.CloudNode, *cloudsvr.PreferAttrs, error)

NewNode create aliyun ecs instance, try to use prefered attributes firstly

func (*SDK) NewSecurityGroup

func (sdk *SDK) NewSecurityGroup(req *CreateSecurityGroupRequest) (string, error)

NewSecurityGroup create a new security group with empty authorizations

func (*SDK) Ping

func (sdk *SDK) Ping() error

Ping verify the cloudsvr settings could be working fine

func (*SDK) RemoveEcs

func (sdk *SDK) RemoveEcs(regionID, instanceID string) error

RemoveEcs remove the specified ecs instance

func (*SDK) RemoveNode

func (sdk *SDK) RemoveNode(node *cloudsvr.CloudNode) error

RemoveNode remove aliyun ecs instance, ignore IncorrectInstanceStatus error and retry until succeed or timeout 1. stop ecs 2. wait ecs stopped 3. remove ecs (ignore ...)

func (*SDK) RemoveSecurityGroup

func (sdk *SDK) RemoveSecurityGroup(regionID, securityGroupID string) error

RemoveSecurityGroup remove specified recurity group under given region

func (*SDK) StartEcs

func (sdk *SDK) StartEcs(id string) error

StartEcs start the specified ecs instance note that Ecs must be `Stopped` status, after this call, Ecs entering `Starting` status

func (*SDK) StopEcs

func (sdk *SDK) StopEcs(id string) error

StopEcs stop the specified ecs instance note that Ecs must be `Running` status, after this call, Ecs entering `Stopping` status

func (*SDK) Type

func (sdk *SDK) Type() string

Type implement Handler

func (*SDK) Verify

func (sdk *SDK) Verify() error

Verify verifies configs about aliyun endpoint & access id & access key

func (*SDK) WaitEcs

func (sdk *SDK) WaitEcs(regionID, instanceID, expectStatus string, maxWait time.Duration) error

WaitEcs wait ecs instance status reached to expected status until maxWait timeout

type SecurityGroupIDSetType

type SecurityGroupIDSetType struct {
	SecurityGroupID []string `json:"SecurityGroupId"`
}

SecurityGroupIDSetType is exported

type ShareGroupType

type ShareGroupType struct {
	Group string
}

ShareGroupType is exported

type SnapshotType

type SnapshotType struct {
	SnapshotID     string `json:"SnapshotId"`
	SnapshotName   string `json:"SnapshotName"`
	Description    string `json:"Description"`
	Progress       string `json:"Progress"`
	SourceDiskID   string `json:"SourceDiskId"`
	SourceDiskSize int    `json:"SourceDiskSize"`
	SourceDiskType string `json:"SourceDiskType"`
	ProductCode    string `json:"ProductCode"`
	CreationTime   string `json:"CreationTime"`
}

SnapshotType is exported

type TagType

type TagType struct {
	TagKey   string `json:"TagKey"`
	TagValue string `json:"TagValue"`
}

TagType is exported

type Tags

type Tags struct {
	Tag []TagType `json:"tag"`
}

Tags is exported

type VRouterSetType

type VRouterSetType struct {
	VRouterID     string
	RegionID      string
	VpcID         string
	RouteTableIDs string
	VRouterName   string
	Description   string
	CreationTime  string
}

VRouterSetType is exported

type VSwitchSetType

type VSwitchSetType struct {
	VSwitchID               string
	VpcID                   string
	Status                  string
	CidrBlock               string
	ZoneID                  string
	AvailableIPAddressCount int
	Description             string
	VSwitchName             string
	CreationTime            string
}

VSwitchSetType is exported

type VpcAttributesType

type VpcAttributesType struct {
	VpcID            string           `json:"VpcId"`
	VSwitchID        string           `json:"VSwitchId"`
	PrivateIPAddress IPAddressSetType `json:"PrivateIpAddress"`
	NatIPAddress     string           `json:"NatIpAddress"`
}

VpcAttributesType is exported

type VpcSetType

type VpcSetType struct {
	VpcID        string
	RegionID     string
	Status       string
	VpcName      string
	VSwitchIDs   string
	CidrBlock    string
	VRouterID    string
	Description  string
	CreationTime string
}

VpcSetType is exported

type ZoneType

type ZoneType struct {
	ZoneID                    string                        `json:"ZoneId"`
	LocalName                 string                        `json:"LocalName"`
	AvailableResources        AvailableResources            `json:"AvailableResources"`
	AvailableInstanceTypes    AvailableInstanceTypes        `json:"AvailableInstanceTypes"`
	AvailableResourceCreation AvailableResourceCreationType `json:"AvailableResourceCreation"`
	AvailableDiskCategories   AvailableDiskCategoriesType   `json:"AvailableDiskCategories"`
	AvailableVolumeCategories AvailableVolumeCategories     `json:"AvailableVolumeCategories"`
}

ZoneType is exported

type Zones

type Zones struct {
	Zone []ZoneType `json:"Zone"`
}

Zones is exported

Jump to

Keyboard shortcuts

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