Skip to content

Commit

Permalink
Add a method to filter unsupported instance types
Browse files Browse the repository at this point in the history
  • Loading branch information
reedobrien committed Feb 9, 2017
1 parent 5c089f6 commit da2b12a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 149 deletions.
145 changes: 1 addition & 144 deletions provider/ec2/internal/ec2instancetypes/generated.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Canonical Ltd.
// Copyright 2017 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package ec2instancetypes
Expand Down Expand Up @@ -795,19 +795,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{

"ap-northeast-2": {

// SKU: 3MBNRY22Y6A2W6WY
// Instance family: General purpose
// Storage: 1 x 4 SSD
{
Name: "m3.medium",
Arches: amd64,
CpuCores: 1,
CpuPower: instances.CpuPower(350),
Mem: 3840,
VirtType: &hvm,
Cost: 91,
},

// SKU: 3UWMR4BVSMJ3PTQ5
// Instance family: Storage optimized
// Storage: 1 x 800 SSD
Expand All @@ -821,19 +808,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{
Cost: 1000,
},

// SKU: 45D7HY2M47KUYJXR
// Instance family: Compute optimized
// Storage: 2 x 320 SSD
{
Name: "c3.8xlarge",
Arches: amd64,
CpuCores: 32,
CpuPower: instances.CpuPower(12543),
Mem: 61440,
VirtType: &hvm,
Cost: 1839,
},

// SKU: 5CB9VHZSJWQTZN3W
// Instance family: Compute optimized
// Storage: EBS only
Expand Down Expand Up @@ -873,19 +847,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{
Cost: 19341,
},

// SKU: 6K25ZNG5NAXQC5AB
// Instance family: GPU instance
// Storage: 1 x 60 SSD
{
Name: "g2.2xlarge",
Arches: amd64,
CpuCores: 8,
CpuPower: instances.CpuPower(2911),
Mem: 15360,
VirtType: &hvm,
Cost: 898,
},

// SKU: 6NSPY3BTJRX47KWG
// Instance family: General purpose
// Storage: EBS only
Expand Down Expand Up @@ -925,32 +886,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{
Cost: 200,
},

// SKU: 7GTTQXNXREPMU7WY
// Instance family: General purpose
// Storage: 2 x 40 SSD
{
Name: "m3.xlarge",
Arches: amd64,
CpuCores: 4,
CpuPower: instances.CpuPower(1400),
Mem: 15360,
VirtType: &hvm,
Cost: 366,
},

// SKU: 7MQ7AMJWV8BPWH88
// Instance family: Compute optimized
// Storage: 2 x 160 SSD
{
Name: "c3.4xlarge",
Arches: amd64,
CpuCores: 16,
CpuPower: instances.CpuPower(6271),
Mem: 30720,
VirtType: &hvm,
Cost: 919,
},

// SKU: 7VFMGFAWZ9QPBHST
// Instance family: General purpose
// Storage: EBS only
Expand All @@ -977,19 +912,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{
Cost: 844,
},

// SKU: 98ZFCFAZXXRGF7CG
// Instance family: GPU instance
// Storage: 2 x 120 SSD
{
Name: "g2.8xlarge",
Arches: amd64,
CpuCores: 32,
CpuPower: instances.CpuPower(11647),
Mem: 61440,
VirtType: &hvm,
Cost: 3592,
},

// SKU: 9DY7H84NVAJTABAD
// Instance family: General purpose
// Storage: EBS only
Expand Down Expand Up @@ -1068,32 +990,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{
Cost: 128,
},

// SKU: CFXCUT5A22XNZ43Y
// Instance family: Compute optimized
// Storage: 2 x 16 SSD
{
Name: "c3.large",
Arches: both,
CpuCores: 2,
CpuPower: instances.CpuPower(783),
Mem: 3840,
VirtType: &hvm,
Cost: 115,
},

// SKU: DTEVN35HD43BM5ST
// Instance family: General purpose
// Storage: 2 x 80 SSD
{
Name: "m3.2xlarge",
Arches: amd64,
CpuCores: 8,
CpuPower: instances.CpuPower(2800),
Mem: 30720,
VirtType: &hvm,
Cost: 732,
},

// SKU: EGXGRBT8ERK49SBP
// Instance family: General purpose
// Storage: EBS only
Expand Down Expand Up @@ -1159,19 +1055,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{
Cost: 1688,
},

// SKU: K79C7JVTDAKRA842
// Instance family: General purpose
// Storage: 1 x 32 SSD
{
Name: "m3.large",
Arches: amd64,
CpuCores: 2,
CpuPower: instances.CpuPower(700),
Mem: 7680,
VirtType: &hvm,
Cost: 183,
},

// SKU: KF2B96YA25ZRC292
// Instance family: Memory optimized
// Storage: 1 x 1,920
Expand Down Expand Up @@ -1289,32 +1172,6 @@ var allInstanceTypes = map[string][]instances.InstanceType{
Cost: 32,
},

// SKU: R7GFV82WRF8QTZYP
// Instance family: Compute optimized
// Storage: 2 x 40 SSD
{
Name: "c3.xlarge",
Arches: amd64,
CpuCores: 4,
CpuPower: instances.CpuPower(1567),
Mem: 7680,
VirtType: &hvm,
Cost: 230,
},

// SKU: RM2KHQ9S45BW6B7M
// Instance family: Compute optimized
// Storage: 2 x 80 SSD
{
Name: "c3.2xlarge",
Arches: amd64,
CpuCores: 8,
CpuPower: instances.CpuPower(3135),
Mem: 15360,
VirtType: &hvm,
Cost: 460,
},

// SKU: WFBUYA3WPRPDVNEH
// Instance family: Storage optimized
// Storage: 12 x 2000 HDD
Expand Down
29 changes: 24 additions & 5 deletions provider/ec2/internal/ec2instancetypes/process_cost_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Main() (int, error) {
defer fout.Close()
}

tmpl, err := template.New("instanceTypes").Parse(`
tmpl := template.Must(template.New("instanceTypes").Parse(`
// Copyright {{.Year}} Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
Expand Down Expand Up @@ -117,10 +117,7 @@ var allInstanceTypes = map[string][]instances.InstanceType{
{{end}}{{end}}
},
{{end}}
}`)
if err != nil {
panic(err)
}
}`))

fmt.Fprintln(os.Stderr, "Processing", infilename)
instanceTypes, meta, err := process(fin)
Expand Down Expand Up @@ -247,13 +244,35 @@ func process(in io.Reader) (map[string][]instanceType, metadata, error) {
if !ok {
return nil, metadata{}, errors.Errorf("unknown location %q", productInfo.Location)
}
if !supported(region, instanceType.Name) {
continue
}

regionInstanceTypes := instanceTypes[region]
regionInstanceTypes = append(regionInstanceTypes, instanceType)
instanceTypes[region] = regionInstanceTypes
}
return instanceTypes, meta, nil
}

// It appears that instances sometimes show up in the offer list which aren't
// available in actual regions. e.g. m3.medium is in the offer list for
// ap-northeast-2, but attempting to launch one returns an unsupported error.
// See: https://bugs.launchpad.net/juju/+bug/1663047
func supported(region, instanceType string) bool {
switch region {
case "ap-northeast-2":
switch instanceType[:2] {
case "c3", "g2", "m3":
return false
default:
return true
}
default:
return true
}
}

func calculateCPUPower(info productInfo) (uint64, error) {
// T-class instances have burstable CPU. This is not captured
// in the pricing information, so we have to hard-code it. We
Expand Down

0 comments on commit da2b12a

Please sign in to comment.