amazon-pricing 0.1.59 → 0.1.60

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmEwYzAwNTg2ZDFkYThhYzIyMjBhMzRkMjQxNjA5NTdjYmQzMGFiYw==
4
+ YjA5OTU4ZjcwZmQ3MGRiZGEwYTM2YWNhOGE0ZWNhOGU1MzZjMDc2NQ==
5
5
  data.tar.gz: !binary |-
6
- MjBlNDYzMjc3NThjYWJlZGMwZjUxOTM4NzI0YzU5NDc0N2M4YTMzZg==
6
+ N2YxYTc2ZTM4OGIxNjU5OTA5YWU4YzJiYjA1NDYwNjUwY2ZhZTU3MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWU5OTViOWI1OGViZWEzM2RlYjMwYTExMjBlNzlmMWIxMjhkYTVhOTUwN2Q5
10
- NTJiNTZjOTdkYzRjYjgxM2IyNDIxMGVlOWMzZWNkNTBiOGE4YzY4NWI5YzZi
11
- MWE2ZDNkMmFkODg4OTkxNzJjODdjMjQzYzU5OWU5MjEwZGVjMTM=
9
+ MGNkYzk4YTBkNTM3N2RkOTY1ODBhMjVjOGNlYzFmNmQ0MDdiYzUyMDZkYjkw
10
+ ZDMyNzBlN2NmMmYwZmE1MGVkOTAzMDIzMWIzY2I2MjFiMTNjZGM3M2I5YzQ3
11
+ ZGYyYmIyOTdiNjI5NzVmZTY4MjBmY2JjOGY5Y2ZmMDc0OTJjM2I=
12
12
  data.tar.gz: !binary |-
13
- Y2U4ZTZiZmJhZGMyOTU2ZjQ1MWU2ZDA1ZTIzMmI0NGZiNDhiOTUyNTk4Nzdi
14
- MWIwMTAzMjE4ZDI0N2I2MTBkNmMwYjFlZGVmMjg4ODZjM2YwYTFhMWQ1NTY0
15
- OTQ0NDk2ODYzNjllMzIzZDEyYzY0OWRlOTJiZjdhMGVkZTI5YTY=
13
+ YWFkYjI5N2I3YjM4OTYyMDM5ZjFkMzY2YTEwZjFlYWQzNTgwZDU2MzE2ZTIy
14
+ YjY4ZTRkZjQ3MTdjYzQ0NDIwNjU5NjU2ODViNzY4MWMwNWJhZDBhMTQ5MDNi
15
+ MzllOTEzYzhlYmY4YmY4YzAyNTgzZjZiM2MwMmIzZGE1ZDI5NjQ=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- amazon-pricing (0.1.59)
4
+ amazon-pricing (0.1.60)
5
5
  mechanize (~> 2.7.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,9 +2,9 @@ Amazon Web Services Pricing Ruby Gem
2
2
  ====================================
3
3
 
4
4
  [![](https://api.tddium.com:443/cloudhealthtech/amazon-pricing/badges/48071.png?badge_token=26071a8988b20f68cb9723defd7012fc33a180bc)](https://api.tddium.com:443/cloudhealthtech/amazon-pricing/suites/48071)
5
- [![Gem Version](https://badge.fury.io/rb/amazon-pricing.png)](http://badge.fury.io/rb/amazon-pricing)
6
- [![Code Climate](https://codeclimate.com/github/CloudHealth/amazon-pricing.png)](https://codeclimate.com/github/CloudHealth/amazon-pricing)
7
- [![Coverage Status](https://coveralls.io/repos/CloudHealth/amazon-pricing/badge.png?branch=master)](https://coveralls.io/r/CloudHealth/amazon-pricing?branch=master)
5
+ [![Gem Version](https://badge.fury.io/rb/amazon-pricing.svg)](http://badge.fury.io/rb/amazon-pricing)
6
+ [![Code Climate](https://codeclimate.com/github/CloudHealth/amazon-pricing/badges/gpa.svg)](https://codeclimate.com/github/CloudHealth/amazon-pricing)
7
+ [![Coverage Status](https://coveralls.io/repos/CloudHealth/amazon-pricing/badge.svg?branch=master)](https://coveralls.io/r/CloudHealth/amazon-pricing?branch=master)
8
8
 
9
9
  About amazon-pricing
10
10
  --------------------
@@ -107,7 +107,7 @@ module AwsPricing
107
107
  @@Compute_Units_Lookup[api_name] = size["ECU"].to_i
108
108
  @@Virtual_Cores_Lookup[api_name] = size["vCPU"].to_i
109
109
  rescue UnknownTypeError
110
- $stderr.puts "WARNING: encountered #{$!.message}"
110
+ $stderr.puts "[populate_lookups] WARNING: encountered #{$!.message}"
111
111
  end
112
112
  end
113
113
  end
@@ -175,6 +175,7 @@ module AwsPricing
175
175
  'g2.2xlarge' => 'Cluster GPU Double Extra Large',
176
176
  'c3.large' => 'High-Compute Large', 'c3.xlarge' => 'High-Compute Extra Large', 'c3.2xlarge' => 'High-Compute Double Extra Large', 'c3.4xlarge' => 'High-Compute Quadruple Extra Large', 'c3.8xlarge' => 'High-Compute Eight Extra Large',
177
177
  'i2.xlarge' => 'High I/O Extra Large', 'i2.2xlarge' => 'High I/O Double Extra Large', 'i2.4xlarge' => 'High I/O Quadruple Extra Large', 'i2.8xlarge' => 'High I/O Eight Extra Large',
178
+ 'd2.xlarge' => 'Dense Storage Extra Large', 'd2.2xlarge' => 'Dense Storage Double Extra Large', 'd2.4xlarge' => 'Dense Storage Quadruple Extra Large', 'd2.8xlarge' => 'Dense Storage Eight Extra Large',
178
179
  'r3.large' => 'Memory Optimized Large', 'r3.xlarge' => 'Memory Optimized Extra Large', 'r3.2xlarge' => 'Memory Optimized Double Extra Large', 'r3.4xlarge' => 'Memory Optimized Quadruple Extra Large', 'r3.8xlarge' => 'Memory Optimized Eight Extra Large',
179
180
  't2.micro' => 'Burstable Performance Instance Micro', 't2.small' => 'Burstable Performance Instance Small', 't2.medium' => 'Burstable Performance Instance Medium',
180
181
  'c4.large' => 'Compute Optimized Large', 'c4.xlarge' => 'Compute Optimized Extra Large', 'c4.2xlarge' => 'Compute Optimized Double Extra Large', 'c4.4xlarge' => 'Compute Optimized Quadruple Extra Large', 'c4.8xlarge' => 'Compute Optimized Eight Extra Large',
@@ -196,6 +197,7 @@ module AwsPricing
196
197
  'db.t1.micro' => 160,
197
198
  'c3.large' => 32, 'c3.xlarge' => 80, 'c3.2xlarge' => 160, 'c3.4xlarge' => 320, 'c3.8xlarge' => 640,
198
199
  'i2.large' => 360, 'i2.xlarge' => 720, 'i2.2xlarge' => 1440, 'i2.4xlarge' => 2880, 'i2.8xlarge' => 5760,
200
+ 'd2.xlarge' => 6000, 'd2.2xlarge' => 12000, 'd2.4xlarge' => 24000, 'd2.8xlarge' => 48000,
199
201
  'r3.large' => 32, 'r3.xlarge' => 80, 'r3.2xlarge' => 160, 'r3.4xlarge' => 320, 'r3.8xlarge' => 640,
200
202
  't2.micro' => 0, 't2.small' => 0, 't2.medium' => 0,
201
203
  'c4.large' => 0, 'c4.xlarge' => 0, 'c4.2xlarge' => 0, 'c4.4xlarge' => 0, 'c4.8xlarge' => 0,
@@ -217,6 +219,7 @@ module AwsPricing
217
219
  'db.t1.micro' => 64,
218
220
  'c3.large' => 64, 'c3.xlarge' => 64, 'c3.2xlarge' => 64, 'c3.4xlarge' => 64, 'c3.8xlarge' => 64,
219
221
  'i2.large' => 64, 'i2.xlarge' => 64, 'i2.2xlarge' => 64, 'i2.4xlarge' => 64, 'i2.8xlarge' => 64,
222
+ 'd2.xlarge' => 64, 'd2.2xlarge' => 64, 'd2.4xlarge' => 64, 'd2.8xlarge' => 64,
220
223
  'r3.large' => 64, 'r3.xlarge' => 64, 'r3.2xlarge' => 64, 'r3.4xlarge' => 64, 'r3.8xlarge' => 64,
221
224
  't2.micro' => 64, 't2.small' => 64, 't2.medium' => 64,
222
225
  'c4.large' => 64, 'c4.xlarge' => 64, 'c4.2xlarge' => 64, 'c4.4xlarge' => 64, 'c4.8xlarge' => 64,
@@ -239,11 +242,14 @@ module AwsPricing
239
242
  'db.t1.micro' => :ebs,
240
243
  'c3.large' => :ssd, 'c3.xlarge' => :ssd, 'c3.2xlarge' => :ssd, 'c3.4xlarge' => :ssd, 'c3.8xlarge' => :ssd,
241
244
  'i2.large' => :ssd, 'i2.xlarge' => :ssd, 'i2.2xlarge' => :ssd, 'i2.4xlarge' => :ssd, 'i2.8xlarge' => :ssd,
245
+ 'd2.xlarge' => :ephemeral, 'd2.2xlarge' => :ephemeral, 'd2.4xlarge' => :ephemeral, 'd2.8xlarge' => :ephemeral,
242
246
  'r3.large' => :ssd, 'r3.xlarge' => :ssd, 'r3.2xlarge' => :ssd, 'r3.4xlarge' => :ssd, 'r3.8xlarge' => :ssd,
243
247
  't2.micro' => :ebs, 't2.small' => :ebs, 't2.medium' => :ebs,
244
248
  'c4.large' => :ebs, 'c4.xlarge' => :ebs, 'c4.2xlarge' => :ebs, 'c4.4xlarge' => :ebs, 'c4.8xlarge' => :ebs,
245
249
  }
246
- # Sigh... AWS does not always provide memory info (e.g. t2, r3)
250
+
251
+ # NOTE: These are populated by "populate_lookups"
252
+ # But... AWS does not always provide memory info (e.g. t2, r3), so those are hardcoded below
247
253
  @@Memory_Lookup = {
248
254
  'r3.large' => 15250, 'r3.xlarge' => 30500, 'r3.2xlarge' => 61000, 'r3.4xlarge' => 122000, 'r3.8xlarge' => 244000,
249
255
  't2.micro' => 1000, 't2.small' => 2000, 't2.medium' => 4000,
@@ -54,34 +54,6 @@ module AwsPricing
54
54
  url = "#{EC2_BASE_URL}previous-generation/ri-v2/#{target}-shared.min.js"
55
55
  fetch_ec2_instance_pricing_ri_v2(url, operating_system)
56
56
  end
57
-
58
- end
59
-
60
- # Retrieves the EC2 on-demand instance pricing.
61
- # type_of_instance = :ondemand, :light, :medium, :heavy
62
- def fetch_ec2_instance_pricing(url, type_of_instance, operating_system)
63
- res = PriceList.fetch_url(url)
64
- res['config']['regions'].each do |reg|
65
- region_name = reg['region']
66
- region = get_region(region_name)
67
- # e.g. type = {"type"=>"hiCPUODI", "sizes"=>[{"size"=>"med", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"N/A"}}]}, {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}]}
68
- reg['instanceTypes'].each do |type|
69
- # e.g. size = {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}
70
- # Amazon now can return array or hash here (hash = only 1 item)
71
- items = type['sizes']
72
- items = [type] if items.nil?
73
- items.each do |size|
74
- begin
75
- api_name, name = Ec2InstanceType.get_name(type["type"], size["size"], type_of_instance != :ondemand)
76
-
77
- instance_type = region.add_or_update_ec2_instance_type(api_name, name)
78
- instance_type.update_pricing(operating_system, type_of_instance, size)
79
- rescue UnknownTypeError
80
- $stderr.puts "WARNING: encountered #{$!.message}"
81
- end
82
- end
83
- end
84
- end
85
57
  end
86
58
 
87
59
  # Retrieves the EC2 on-demand instance pricing.
@@ -92,7 +64,7 @@ module AwsPricing
92
64
  region_name = reg['region']
93
65
  region = get_region(region_name)
94
66
  if region.nil?
95
- $stderr.puts "WARNING: unable to find region #{region_name}"
67
+ $stderr.puts "[fetch_ec2_instance_pricing] WARNING: unable to find region #{region_name}"
96
68
  next
97
69
  end
98
70
  # e.g. type = {"type"=>"hiCPUODI", "sizes"=>[{"size"=>"med", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"N/A"}}]}, {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}]}
@@ -107,7 +79,7 @@ module AwsPricing
107
79
  instance_type = region.add_or_update_ec2_instance_type(api_name, name)
108
80
  instance_type.update_pricing(operating_system, type_of_instance, size)
109
81
  rescue UnknownTypeError
110
- $stderr.puts "WARNING: encountered #{$!.message}"
82
+ $stderr.puts "[fetch_ec2_instance_pricing] WARNING: encountered #{$!.message}"
111
83
  end
112
84
  end
113
85
  end
@@ -121,14 +93,14 @@ module AwsPricing
121
93
  region_name = reg['region']
122
94
  region = get_region(region_name)
123
95
  if region.nil?
124
- $stderr.puts "WARNING: unable to find region #{region_name}"
96
+ $stderr.puts "[fetch_ec2_instance_pricing_ri_v2] WARNING: unable to find region #{region_name}"
125
97
  next
126
98
  end
127
99
  reg['instanceTypes'].each do |type|
128
100
  api_name = type["type"]
129
101
  instance_type = region.get_instance_type(api_name)
130
102
  if instance_type.nil?
131
- $stderr.puts "WARNING: new reserved instances not found for #{api_name} in #{region_name}"
103
+ $stderr.puts "[fetch_ec2_instance_pricing_ri_v2] WARNING: new reserved instances not found for #{api_name} in #{region_name}"
132
104
  next
133
105
  end
134
106
 
@@ -0,0 +1,161 @@
1
+ module AwsPricing
2
+ module Helper
3
+ module InstanceType
4
+
5
+ @@INSTANCE_TYPES_BY_CLASSIFICATION = {
6
+ 'GeneralPurpose' => {
7
+ 'CurrentGen' => {
8
+ 'M3' => ['m3.medium', 'm3.large', 'm3.xlarge', 'm3.2xlarge']
9
+ },
10
+ 'PreviousGen' => {
11
+ 'M1' => ['m1.small', 'm1.medium', 'm1.large', 'm1.xlarge']
12
+ }
13
+ },
14
+ 'BurstableInstances' => {
15
+ 'CurrentGen' => {
16
+ 'T2' => ['t2.micro', 't2.small', 't2.medium']
17
+ }
18
+ },
19
+ 'ComputeOptimized' => {
20
+ 'CurrentGen' => {
21
+ 'C3' => ['c3.large', 'c3.xlarge', 'c3.2xlarge', 'c3.4xlarge', 'c3.8xlarge'],
22
+ 'C4' => ['c4.large', 'c4.xlarge', 'c4.2xlarge', 'c4.4xlarge', 'c4.8xlarge']
23
+ },
24
+ 'PreviousGen' => {
25
+ 'C1' => ['c1.medium', 'c1.xlarge'],
26
+ 'C2' => ['cc2.8xlarge']
27
+ }
28
+ },
29
+ 'MemoryOptimized' => {
30
+ 'CurrentGen' => {
31
+ 'R3' => ['r3.large', 'r3.xlarge', 'r3.2xlarge', 'r3.4xlarge', 'r3.8xlarge']
32
+ },
33
+ 'PreviousGen' => {
34
+ 'M2' => ['m2.xlarge', 'm2.2xlarge', 'm2.4xlarge'],
35
+ 'CR1' => ['cr1.8xlarge']
36
+ }
37
+ },
38
+ 'StorageOptimized' => {
39
+ 'CurrentGen' => {
40
+ 'HS1' => ['hs1.8xlarge'],
41
+ 'I2' => ['i2.xlarge', 'i2.2xlarge', 'i2.4xlarge', 'i2.8xlarge'],
42
+ 'D2' => ['d2.xlarge', 'd2.2xlarge', 'd2.4xlarge', 'd2.8xlarge']
43
+ },
44
+ 'PreviousGen' => {
45
+ 'HI1' => ['hi1.4xlarge']
46
+ }
47
+ },
48
+ 'GPUInstances' => {
49
+ 'CurrentGen' => {
50
+ 'G2' => ['g2.2xlarge']
51
+ },
52
+ 'PreviousGen' => {
53
+ 'CG1' => ['cg1.4xlarge']
54
+ }
55
+ },
56
+ 'MicroInstances' => {
57
+ 'PreviousGen' => {
58
+ 'T1' => ['t1.micro']
59
+ }
60
+ }
61
+ }
62
+
63
+ # Important: Members of a family must be kept in 'size' order (small, medium, large, etc.)
64
+ # AWS Docs: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
65
+ def instance_types
66
+ @@INSTANCE_TYPES_BY_CLASSIFICATION
67
+ end
68
+
69
+ def general_purpose_instances
70
+ instance_types['GeneralPurpose']
71
+ end
72
+
73
+ def burstable_instances
74
+ instance_types['BurstableInstances']
75
+ end
76
+
77
+ def compute_optimized_instances
78
+ instance_types['ComputeOptimized']
79
+ end
80
+
81
+ def memory_optimized_instances
82
+ instance_types['MemoryOptimized']
83
+ end
84
+
85
+ def storage_optimized_instances
86
+ instance_types['StorageOptimized']
87
+ end
88
+
89
+ def gpu_instances
90
+ instance_types['GPUInstances']
91
+ end
92
+
93
+ def micro_instances
94
+ instance_types['MicroInstances']
95
+ end
96
+
97
+ def previous_generation_instances
98
+ [
99
+ general_purpose_instances['PreviousGen'],
100
+ compute_optimized_instances['PreviousGen'],
101
+ compute_optimized_instances['PreviousGen'],
102
+ memory_optimized_instances['PreviousGen'],
103
+ memory_optimized_instances['PreviousGen'],
104
+ storage_optimized_instances['PreviousGen'],
105
+ gpu_instances['PreviousGen'],
106
+ micro_instances['PreviousGen']
107
+ ].inject({}) do |instances, family|
108
+ instances.merge(family)
109
+ end
110
+ end
111
+
112
+ def current_generation_instances
113
+ [
114
+ general_purpose_instances['CurrentGen'],
115
+ burstable_instances['CurrentGen'],
116
+ compute_optimized_instances['CurrentGen'],
117
+ compute_optimized_instances['CurrentGen'],
118
+ memory_optimized_instances['CurrentGen'],
119
+ memory_optimized_instances['CurrentGen'],
120
+ storage_optimized_instances['CurrentGen'],
121
+ gpu_instances['CurrentGen']
122
+ ].inject({}) do |instances, family|
123
+ instances.merge(family)
124
+ end
125
+ end
126
+
127
+ def all_instances
128
+ @all_instances ||= begin
129
+ [previous_generation_instances, current_generation_instances].inject({}) do |instances, family|
130
+ instances.merge(family)
131
+ end
132
+ end
133
+ end
134
+
135
+ def family(api_name)
136
+ all_instances.select { |family, instances| instances.include?(api_name) }.keys.first
137
+ end
138
+
139
+ def family_members(api_name)
140
+ all_instances.select { |family, instances| instances.include?(api_name) }.values.first
141
+ end
142
+
143
+ def size_to_nf
144
+ {
145
+ 'micro' => 0.5,
146
+ 'small' => 1,
147
+ 'medium' => 2,
148
+ 'large' => 4,
149
+ 'xlarge' => 8,
150
+ '2xlarge' => 16,
151
+ '4xlarge' => 32,
152
+ '8xlarge' => 64
153
+ }
154
+ end
155
+
156
+ def api_name_to_nf(name)
157
+ size_to_nf[name.split('.').last]
158
+ end
159
+ end
160
+ end
161
+ end
@@ -142,7 +142,7 @@ module AwsPricing
142
142
  instance_type = region.add_or_update_rds_instance_type(api_name, name)
143
143
  instance_type.update_pricing(db_type, type_of_rds_instance, tier, is_multi_az, is_byol)
144
144
  rescue UnknownTypeError
145
- $stderr.puts "WARNING: encountered #{$!.message}"
145
+ $stderr.puts "[fetch_on_demand_rds_instance_pricing] WARNING: encountered #{$!.message}"
146
146
  end
147
147
  end
148
148
  end
@@ -163,7 +163,7 @@ module AwsPricing
163
163
  instance_type = region.add_or_update_rds_instance_type(api_name, name)
164
164
  instance_type.update_pricing(db_type, type_of_rds_instance, tier, is_multi_az, is_byol)
165
165
  rescue UnknownTypeError
166
- $stderr.puts "WARNING: encountered #{$!.message}"
166
+ $stderr.puts "[fetch_reserved_rds_instance_pricing] WARNING: encountered #{$!.message}"
167
167
  end
168
168
  end
169
169
  end
@@ -8,5 +8,5 @@
8
8
  # Home:: http://github.com/CloudHealth/amazon-pricing
9
9
  #++
10
10
  module AwsPricing
11
- VERSION = '0.1.59'
11
+ VERSION = '0.1.60'
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-pricing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.59
4
+ version: 0.1.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Kinsella
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -58,6 +58,7 @@ files:
58
58
  - lib/amazon-pricing/definitions/region.rb
59
59
  - lib/amazon-pricing/dynamo-db-price-list.rb
60
60
  - lib/amazon-pricing/ec2-price-list.rb
61
+ - lib/amazon-pricing/helpers/instance-type.rb
61
62
  - lib/amazon-pricing/rds-price-list.rb
62
63
  - lib/amazon-pricing/version.rb
63
64
  - spec/lib/amazon-pricing/definitions/database-type_spec.rb
@@ -96,3 +97,4 @@ signing_key:
96
97
  specification_version: 4
97
98
  summary: Amazon Web Services Pricing Ruby gem
98
99
  test_files: []
100
+ has_rdoc: