ec2

package
v0.0.0-...-a204096 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2016 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EC2StatusPending      = "pending"
	EC2StatusRunning      = "running"
	EC2StatusShuttingdown = "shutting-down"
	EC2StatusTerminated   = "terminated"
	EC2StatusStopped      = "stopped"
)

Valid values for EC2 instance states: pending | running | shutting-down | terminated | stopping | stopped see http://goo.gl/3OrCGn

View Source
const (
	OnDemandProviderName = "ec2"
	SpotProviderName     = "ec2-spot"
	NameTimeFormat       = "20060102150405"
	SpawnHostExpireDays  = 90
	MciHostExpireDays    = 30
)
View Source
const (
	SpotStatusOpen     = "open"
	SpotStatusActive   = "active"
	SpotStatusClosed   = "closed"
	SpotStatusCanceled = "cancelled"
	SpotStatusFailed   = "failed"

	EC2ErrorSpotRequestNotFound = "InvalidSpotInstanceRequestID.NotFound"
)

Variables

View Source
var (
	// bson fields for the EC2ProviderSettings struct
	AMIKey           = bsonutil.MustHaveTag(EC2ProviderSettings{}, "AMI")
	InstanceTypeKey  = bsonutil.MustHaveTag(EC2ProviderSettings{}, "InstanceType")
	SecurityGroupKey = bsonutil.MustHaveTag(EC2ProviderSettings{}, "SecurityGroup")
	KeyNameKey       = bsonutil.MustHaveTag(EC2ProviderSettings{}, "KeyName")
	MountPointsKey   = bsonutil.MustHaveTag(EC2ProviderSettings{}, "MountPoints")
)
View Source
var (
	// bson fields for the MountPoint struct
	VirtualNameKey = bsonutil.MustHaveTag(MountPoint{}, "VirtualName")
	DeviceNameKey  = bsonutil.MustHaveTag(MountPoint{}, "DeviceName")
	SizeKey        = bsonutil.MustHaveTag(MountPoint{}, "Size")
)
View Source
var (
	// bson fields for the EC2SpotSettings struct
	BidPriceKey = bsonutil.MustHaveTag(EC2SpotSettings{}, "BidPrice")
)

Functions

This section is empty.

Types

type EC2Manager

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

EC2Manager implements the CloudManager interface for Amazon EC2

func (*EC2Manager) CanSpawn

func (cloudManager *EC2Manager) CanSpawn() (bool, error)

func (*EC2Manager) Configure

func (cloudManager *EC2Manager) Configure(settings *evergreen.Settings) error

Configure loads necessary credentials or other settings from the global config object.

func (*EC2Manager) CostForDuration

func (cloudManager *EC2Manager) CostForDuration(h *host.Host, start, end time.Time) (float64, error)

CostForDuration returns the cost of running a host between the given start and end times

func (*EC2Manager) GetDNSName

func (cloudManager *EC2Manager) GetDNSName(host *host.Host) (string, error)

func (*EC2Manager) GetInstanceStatus

func (cloudManager *EC2Manager) GetInstanceStatus(host *host.Host) (cloud.CloudStatus, error)

func (*EC2Manager) GetSSHOptions

func (cloudManager *EC2Manager) GetSSHOptions(h *host.Host, keyPath string) ([]string, error)

func (*EC2Manager) GetSettings

func (*EC2Manager) GetSettings() cloud.ProviderSettings

func (*EC2Manager) IsSSHReachable

func (cloudManager *EC2Manager) IsSSHReachable(host *host.Host, keyPath string) (bool, error)

func (*EC2Manager) IsUp

func (cloudManager *EC2Manager) IsUp(host *host.Host) (bool, error)

func (*EC2Manager) OnUp

func (cloudManager *EC2Manager) OnUp(host *host.Host) error

func (*EC2Manager) SpawnInstance

func (cloudManager *EC2Manager) SpawnInstance(d *distro.Distro, hostOpts cloud.HostOptions) (*host.Host, error)

func (*EC2Manager) StopInstance

func (cloudManager *EC2Manager) StopInstance(host *host.Host) error

func (*EC2Manager) TerminateInstance

func (cloudManager *EC2Manager) TerminateInstance(host *host.Host) error

func (*EC2Manager) TimeTilNextPayment

func (cloudManager *EC2Manager) TimeTilNextPayment(host *host.Host) time.Duration

determine how long until a payment is due for the host

type EC2ProviderSettings

type EC2ProviderSettings struct {
	AMI          string       `mapstructure:"ami" json:"ami,omitempty" bson:"ami,omitempty"`
	InstanceType string       `mapstructure:"instance_type" json:"instance_type,omitempty" bson:"instance_type,omitempty"`
	KeyName      string       `mapstructure:"key_name" json:"key_name,omitempty" bson:"key_name,omitempty"`
	MountPoints  []MountPoint `mapstructure:"mount_points" json:"mount_points,omitempty" bson:"mount_points,omitempty"`

	// this is the security group name in EC2 classic and the security group ID in VPC (eg. sg-xxxx)
	SecurityGroup string `mapstructure:"security_group" json:"security_group,omitempty" bson:"security_group,omitempty"`
	// only set in VPC (eg. subnet-xxxx)
	SubnetId string `mapstructure:"subnet_id" json:"subnet_id,omitempty" bson:"subnet_id,omitempty"`
	// this is set to true if the security group is part of a vpc
	IsVpc bool `mapstructure:"is_vpc" json:"is_vpc,omitempty" bson:"is_vpc,omitempty"`
}

func (*EC2ProviderSettings) Validate

func (self *EC2ProviderSettings) Validate() error

type EC2SpotManager

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

EC2SpotManager implements the CloudManager interface for Amazon EC2 Spot

func (*EC2SpotManager) CanSpawn

func (cloudManager *EC2SpotManager) CanSpawn() (bool, error)

func (*EC2SpotManager) Configure

func (cloudManager *EC2SpotManager) Configure(settings *evergreen.Settings) error

Configure loads necessary credentials or other settings from the global config object.

func (*EC2SpotManager) CostForDuration

func (cloudManager *EC2SpotManager) CostForDuration(h *host.Host, start, end time.Time) (float64, error)

CostForDuration computes the currency amount it costs to use the given host between a start and end time. The Spot prices estimation takes both spot prices and EBS prices into account. Here's a breakdown:

Spot prices are determined by a fluctuating price market. We set a bid price and get a host if the "market" price is lower than that. We are billed by what the current spot price is, and then charged the current spot price once our hour billing cycle is up, and so on. This calculator ONLY returns the cost of the time used between the start and end times, it does not account for unused host time.

EBS volumes are charged on a per-gigabyte-per-month rate for usage, rounded to the nearest hour. There is no EBS price API, so we scrape it from Amazon's UI. This could unexpectedly break in the future, but, so far, the JSON we are loading hasn't changed format in half a decade. EBS spending for a single task ends up being virtually nothing compared to the machine price, but those fractions of cents will add up over time.

CostForDuration returns the total cost and any errors that occur.

func (*EC2SpotManager) GetDNSName

func (cloudManager *EC2SpotManager) GetDNSName(host *host.Host) (string, error)

func (*EC2SpotManager) GetInstanceStatus

func (cloudManager *EC2SpotManager) GetInstanceStatus(host *host.Host) (cloud.CloudStatus, error)

GetInstanceStatus returns an mci-universal status code for the status of an ec2 spot-instance host. For unfulfilled spot requests, the behavior is as follows: Spot request open or active, but unfulfilled -> StatusPending Spot request closed or canceled -> StatusTerminated Spot request failed due to bidding/capacity -> StatusFailed

For a *fulfilled* spot request (the spot request has an instance ID) the status returned will be the status of the instance that fulfilled it, matching the behavior used in cloud/providers/ec2/ec2.go

func (*EC2SpotManager) GetSSHOptions

func (cloudManager *EC2SpotManager) GetSSHOptions(h *host.Host, keyPath string) ([]string, error)

func (*EC2SpotManager) GetSettings

func (*EC2SpotManager) GetSettings() cloud.ProviderSettings

func (*EC2SpotManager) IsSSHReachable

func (cloudManager *EC2SpotManager) IsSSHReachable(host *host.Host, keyPath string) (bool, error)

func (*EC2SpotManager) IsUp

func (cloudManager *EC2SpotManager) IsUp(host *host.Host) (bool, error)

func (*EC2SpotManager) OnUp

func (cloudManager *EC2SpotManager) OnUp(host *host.Host) error

func (*EC2SpotManager) SpawnInstance

func (cloudManager *EC2SpotManager) SpawnInstance(d *distro.Distro, hostOpts cloud.HostOptions) (*host.Host, error)

func (*EC2SpotManager) TerminateInstance

func (cloudManager *EC2SpotManager) TerminateInstance(host *host.Host) error

func (*EC2SpotManager) TimeTilNextPayment

func (cloudManager *EC2SpotManager) TimeTilNextPayment(host *host.Host) time.Duration

determine how long until a payment is due for the host

type EC2SpotSettings

type EC2SpotSettings struct {
	BidPrice float64 `mapstructure:"bid_price" json:"bid_price,omitempty" bson:"bid_price,omitempty"`

	AMI          string       `mapstructure:"ami" json:"ami,omitempty" bson:"ami,omitempty"`
	InstanceType string       `mapstructure:"instance_type" json:"instance_type,omitempty" bson:"instance_type,omitempty"`
	KeyName      string       `mapstructure:"key_name" json:"key_name,omitempty" bson:"key_name,omitempty"`
	MountPoints  []MountPoint `mapstructure:"mount_points" json:"mount_points,omitempty" bson:"mount_points,omitempty"`

	// this is the security group name in EC2 classic and the security group ID in VPC (eg. sg-xxxx)
	SecurityGroup string `mapstructure:"security_group" json:"security_group,omitempty" bson:"security_group,omitempty"`
	// only set in VPC (eg. subnet-xxxx)
	SubnetId string `mapstructure:"subnet_id" json:"subnet_id,omitempty" bson:"subnet_id,omitempty"`
	// this is set to true if the security group is part of a vpc
	IsVpc bool `mapstructure:"is_vpc" json:"is_vpc,omitempty" bson:"is_vpc,omitempty"`
}

func (*EC2SpotSettings) Validate

func (self *EC2SpotSettings) Validate() error

type MountPoint

type MountPoint struct {
	VirtualName string `mapstructure:"virtual_name" json:"virtual_name,omitempty" bson:"virtual_name,omitempty"`
	DeviceName  string `mapstructure:"device_name" json:"device_name,omitempty" bson:"device_name,omitempty"`
	Size        int    `mapstructure:"size" json:"size,omitempty" bson:"size,omitempty"`
}

type Terms

type Terms struct {
	OnDemand map[string]map[string]struct {
		PriceDimensions map[string]struct {
			PricePerUnit struct {
				USD string
			}
		}
	}
}

Terms is an internal type for loading price API results into.

Jump to

Keyboard shortcuts

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