ecs

package
v0.0.0-...-3a645fe Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: Apache-2.0 Imports: 26 Imported by: 4

Documentation

Overview

The alicloud contains a packer.Builder implementation that builds ecs images for alicloud.

Index

Constants

View Source
const (
	ALICLOUD_DEFAULT_SHORT_TIMEOUT = 180
	ALICLOUD_DEFAULT_TIMEOUT       = 1800
	ALICLOUD_DEFAULT_LONG_TIMEOUT  = 3600
)
View Source
const (
	InstanceStatusRunning  = "Running"
	InstanceStatusStarting = "Starting"
	InstanceStatusStopped  = "Stopped"
	InstanceStatusStopping = "Stopping"
)
View Source
const (
	ImageStatusWaiting      = "Waiting"
	ImageStatusCreating     = "Creating"
	ImageStatusCreateFailed = "CreateFailed"
	ImageStatusAvailable    = "Available"
)
View Source
const (
	SnapshotStatusAll          = "all"
	SnapshotStatusProgressing  = "progressing"
	SnapshotStatusAccomplished = "accomplished"
	SnapshotStatusFailed       = "failed"
)
View Source
const (
	DiskStatusInUse     = "In_use"
	DiskStatusAvailable = "Available"
	DiskStatusAttaching = "Attaching"
	DiskStatusDetaching = "Detaching"
	DiskStatusCreating  = "Creating"
	DiskStatusReIniting = "ReIniting"
)
View Source
const (
	VpcStatusPending   = "Pending"
	VpcStatusAvailable = "Available"
)
View Source
const (
	VSwitchStatusPending   = "Pending"
	VSwitchStatusAvailable = "Available"
)
View Source
const (
	EipStatusAssociating   = "Associating"
	EipStatusUnassociating = "Unassociating"
	EipStatusInUse         = "InUse"
	EipStatusAvailable     = "Available"
)
View Source
const (
	ImageOwnerSystem      = "system"
	ImageOwnerSelf        = "self"
	ImageOwnerOthers      = "others"
	ImageOwnerMarketplace = "marketplace"
)
View Source
const (
	IOOptimizedNone      = "none"
	IOOptimizedOptimized = "optimized"
)
View Source
const (
	InstanceNetworkClassic = "classic"
	InstanceNetworkVpc     = "vpc"
)
View Source
const (
	DiskTypeSystem = "system"
	DiskTypeData   = "data"
)
View Source
const (
	TagResourceImage    = "image"
	TagResourceInstance = "instance"
	TagResourceSnapshot = "snapshot"
	TagResourceDisk     = "disk"
)
View Source
const (
	IpProtocolAll  = "all"
	IpProtocolTCP  = "tcp"
	IpProtocolUDP  = "udp"
	IpProtocolICMP = "icmp"
	IpProtocolGRE  = "gre"
)
View Source
const (
	NicTypeInternet = "internet"
	NicTypeIntranet = "intranet"
)
View Source
const (
	DefaultPortRange = "-1/-1"
	DefaultCidrIp    = "0.0.0.0/0"
	DefaultCidrBlock = "172.16.0.0/24"
)
View Source
const (
	EvalRetryErrorType    = EvalErrorType(true)
	EvalNotRetryErrorType = EvalErrorType(false)
)
View Source
const BuilderId = "alibaba.alicloud"

The unique ID for this builder

View Source
const DefaultRequestReadTimeout = 10 * time.Second
View Source
const Packer = "HashiCorp-Packer"

Variables

View Source
var (
	WaitForExpectSuccess = WaitForExpectEvalResult{
							// contains filtered or unexported fields
	}

	WaitForExpectToRetry = WaitForExpectEvalResult{
							// contains filtered or unexported fields
	}

	WaitForExpectFailToStop = WaitForExpectEvalResult{
							// contains filtered or unexported fields
	}
)

Functions

func ContainsInArray

func ContainsInArray(arr []string, value string) bool

func SSHHost

func SSHHost(e alicloudSSHHelper, private bool) func(multistep.StateBag) (string, error)

SSHHost returns a function that can be given to the SSH communicator

Types

type AlicloudAccessConfig

type AlicloudAccessConfig struct {
	AlicloudAccessKey      string `mapstructure:"access_key"`
	AlicloudSecretKey      string `mapstructure:"secret_key"`
	AlicloudRegion         string `mapstructure:"region"`
	AlicloudSkipValidation bool   `mapstructure:"skip_region_validation"`
	SecurityToken          string `mapstructure:"security_token"`
	// contains filtered or unexported fields
}

Config of alicloud

func (*AlicloudAccessConfig) Client

func (c *AlicloudAccessConfig) Client() (*ClientWrapper, error)

Client for AlicloudClient

func (*AlicloudAccessConfig) Config

func (c *AlicloudAccessConfig) Config() error

func (*AlicloudAccessConfig) Prepare

func (c *AlicloudAccessConfig) Prepare(ctx *interpolate.Context) []error

func (*AlicloudAccessConfig) ValidateRegion

func (c *AlicloudAccessConfig) ValidateRegion(region string) error

type AlicloudDiskDevice

type AlicloudDiskDevice struct {
	DiskName           string `mapstructure:"disk_name"`
	DiskCategory       string `mapstructure:"disk_category"`
	DiskSize           int    `mapstructure:"disk_size"`
	SnapshotId         string `mapstructure:"disk_snapshot_id"`
	Description        string `mapstructure:"disk_description"`
	DeleteWithInstance bool   `mapstructure:"disk_delete_with_instance"`
	Device             string `mapstructure:"disk_device"`
	Encrypted          *bool  `mapstructure:"disk_encrypted"`
}

type AlicloudDiskDevices

type AlicloudDiskDevices struct {
	ECSSystemDiskMapping  AlicloudDiskDevice   `mapstructure:"system_disk_mapping"`
	ECSImagesDiskMappings []AlicloudDiskDevice `mapstructure:"image_disk_mappings"`
}

type AlicloudImageConfig

type AlicloudImageConfig struct {
	AlicloudImageName                 string            `mapstructure:"image_name"`
	AlicloudImageVersion              string            `mapstructure:"image_version"`
	AlicloudImageDescription          string            `mapstructure:"image_description"`
	AlicloudImageShareAccounts        []string          `mapstructure:"image_share_account"`
	AlicloudImageUNShareAccounts      []string          `mapstructure:"image_unshare_account"`
	AlicloudImageDestinationRegions   []string          `mapstructure:"image_copy_regions"`
	AlicloudImageDestinationNames     []string          `mapstructure:"image_copy_names"`
	ImageEncrypted                    *bool             `mapstructure:"image_encrypted"`
	AlicloudImageForceDelete          bool              `mapstructure:"image_force_delete"`
	AlicloudImageForceDeleteSnapshots bool              `mapstructure:"image_force_delete_snapshots"`
	AlicloudImageForceDeleteInstances bool              `mapstructure:"image_force_delete_instances"`
	AlicloudImageIgnoreDataDisks      bool              `mapstructure:"image_ignore_data_disks"`
	AlicloudImageSkipRegionValidation bool              `mapstructure:"skip_region_validation"`
	AlicloudImageTags                 map[string]string `mapstructure:"tags"`
	AlicloudDiskDevices               `mapstructure:",squash"`
}

func (*AlicloudImageConfig) Prepare

func (c *AlicloudImageConfig) Prepare(ctx *interpolate.Context) []error

type Artifact

type Artifact struct {
	// A map of regions to alicloud image IDs.
	AlicloudImages map[string]string

	// BuilderId is the unique ID for the builder that created this alicloud image
	BuilderIdValue string

	// Alcloud connection for performing API stuff.
	Client *ClientWrapper
}

func (*Artifact) BuilderId

func (a *Artifact) BuilderId() string

func (*Artifact) Destroy

func (a *Artifact) Destroy() error

func (*Artifact) Files

func (*Artifact) Files() []string

func (*Artifact) Id

func (a *Artifact) Id() string

func (*Artifact) State

func (a *Artifact) State(name string) interface{}

func (*Artifact) String

func (a *Artifact) String() string

type Builder

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

func (*Builder) Prepare

func (b *Builder) Prepare(raws ...interface{}) ([]string, error)

func (*Builder) Run

func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error)

type ClientWrapper

type ClientWrapper struct {
	*ecs.Client
}

func (*ClientWrapper) EvalCouldRetryResponse

func (c *ClientWrapper) EvalCouldRetryResponse(evalErrors []string, evalErrorType EvalErrorType) func(response responses.AcsResponse, err error) WaitForExpectEvalResult

func (*ClientWrapper) WaitForExpected

func (c *ClientWrapper) WaitForExpected(args *WaitForExpectArgs) (responses.AcsResponse, error)

func (*ClientWrapper) WaitForImageStatus

func (c *ClientWrapper) WaitForImageStatus(regionId string, imageId string, expectedStatus string, timeout time.Duration) (responses.AcsResponse, error)

func (*ClientWrapper) WaitForInstanceStatus

func (c *ClientWrapper) WaitForInstanceStatus(regionId string, instanceId string, expectedStatus string) (responses.AcsResponse, error)

func (*ClientWrapper) WaitForSnapshotStatus

func (c *ClientWrapper) WaitForSnapshotStatus(regionId string, snapshotId string, expectedStatus string, timeout time.Duration) (responses.AcsResponse, error)

type Config

type Config struct {
	common.PackerConfig  `mapstructure:",squash"`
	AlicloudAccessConfig `mapstructure:",squash"`
	AlicloudImageConfig  `mapstructure:",squash"`
	RunConfig            `mapstructure:",squash"`
	// contains filtered or unexported fields
}

type EvalErrorType

type EvalErrorType bool

type InstanceNetWork

type InstanceNetWork string

type RunConfig

type RunConfig struct {
	AssociatePublicIpAddress bool   `mapstructure:"associate_public_ip_address"`
	ZoneId                   string `mapstructure:"zone_id"`
	IOOptimized              *bool  `mapstructure:"io_optimized"`
	InstanceType             string `mapstructure:"instance_type"`
	Description              string `mapstructure:"description"`
	AlicloudSourceImage      string `mapstructure:"source_image"`
	ForceStopInstance        bool   `mapstructure:"force_stop_instance"`
	DisableStopInstance      bool   `mapstructure:"disable_stop_instance"`
	SecurityGroupId          string `mapstructure:"security_group_id"`
	SecurityGroupName        string `mapstructure:"security_group_name"`
	UserData                 string `mapstructure:"user_data"`
	UserDataFile             string `mapstructure:"user_data_file"`
	VpcId                    string `mapstructure:"vpc_id"`
	VpcName                  string `mapstructure:"vpc_name"`
	CidrBlock                string `mapstructure:"vpc_cidr_block"`
	VSwitchId                string `mapstructure:"vswitch_id"`
	VSwitchName              string `mapstructure:"vswitch_id"`
	InstanceName             string `mapstructure:"instance_name"`
	InternetChargeType       string `mapstructure:"internet_charge_type"`
	InternetMaxBandwidthOut  int    `mapstructure:"internet_max_bandwidth_out"`
	WaitSnapshotReadyTimeout int    `mapstructure:"wait_snapshot_ready_timeout"`

	// Communicator settings
	Comm         communicator.Config `mapstructure:",squash"`
	SSHPrivateIp bool                `mapstructure:"ssh_private_ip"`
}

func (*RunConfig) Prepare

func (c *RunConfig) Prepare(ctx *interpolate.Context) []error

type WaitForExpectArgs

type WaitForExpectArgs struct {
	RequestFunc   func() (responses.AcsResponse, error)
	EvalFunc      func(response responses.AcsResponse, err error) WaitForExpectEvalResult
	RetryInterval time.Duration
	RetryTimes    int
	RetryTimeout  time.Duration
}

type WaitForExpectEvalResult

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

Jump to

Keyboard shortcuts

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