amazon-pricing 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/amazon-pricing.rb +21 -14
- data/lib/amazon-pricing/ec2-instance-type.rb +1 -1
- data/lib/amazon-pricing/instance-type.rb +7 -10
- data/lib/amazon-pricing/region.rb +2 -2
- data/lib/amazon-pricing/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/amazon-pricing.rb
CHANGED
@@ -38,7 +38,11 @@ module AwsPricing
|
|
38
38
|
def fetch_url(url)
|
39
39
|
uri = URI.parse(url)
|
40
40
|
page = Net::HTTP.get_response(uri)
|
41
|
-
|
41
|
+
# Now that AWS switched from json to jsonp, remove first/last lines
|
42
|
+
body = page.body.gsub("callback(", "").reverse.sub(")", "").reverse
|
43
|
+
|
44
|
+
#body = page.body.split("\n")[1..-2].join("\n")
|
45
|
+
JSON.parse(body)
|
42
46
|
end
|
43
47
|
|
44
48
|
protected
|
@@ -58,8 +62,8 @@ module AwsPricing
|
|
58
62
|
region
|
59
63
|
end
|
60
64
|
|
61
|
-
EC2_BASE_URL = "http://aws.
|
62
|
-
RDS_BASE_URL = "http://aws.
|
65
|
+
EC2_BASE_URL = "http://aws-assets-pricing-prod.s3.amazonaws.com/pricing/ec2/"
|
66
|
+
RDS_BASE_URL = "http://aws-assets-pricing-prod.s3.amazonaws.com/pricing/rds/"
|
63
67
|
|
64
68
|
# Lookup allows us to map to AWS API region names
|
65
69
|
@@Region_Lookup = {
|
@@ -92,14 +96,14 @@ module AwsPricing
|
|
92
96
|
|
93
97
|
def get_ec2_on_demand_instance_pricing
|
94
98
|
@@OS_TYPES.each do |os|
|
95
|
-
fetch_ec2_instance_pricing(EC2_BASE_URL + "
|
99
|
+
fetch_ec2_instance_pricing(EC2_BASE_URL + "#{os}-od.js", :ondemand, os)
|
96
100
|
end
|
97
101
|
end
|
98
102
|
|
99
103
|
def get_ec2_reserved_instance_pricing
|
100
104
|
@@OS_TYPES.each do |os|
|
101
105
|
@@RES_TYPES.each do |res_type|
|
102
|
-
fetch_ec2_instance_pricing(EC2_BASE_URL + "
|
106
|
+
fetch_ec2_instance_pricing(EC2_BASE_URL + "#{os}-ri-#{res_type}.js", res_type, os)
|
103
107
|
end
|
104
108
|
end
|
105
109
|
end
|
@@ -114,7 +118,10 @@ module AwsPricing
|
|
114
118
|
# e.g. type = {"type"=>"hiCPUODI", "sizes"=>[{"size"=>"med", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"N/A"}}]}, {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}]}
|
115
119
|
reg['instanceTypes'].each do |type|
|
116
120
|
# e.g. size = {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}
|
117
|
-
|
121
|
+
# Amazon now can return array or hash here (hash = only 1 item)
|
122
|
+
items = type['sizes']
|
123
|
+
items = [type] if items.nil?
|
124
|
+
items.each do |size|
|
118
125
|
begin
|
119
126
|
api_name, name = Ec2InstanceType.get_name(type["type"], size["size"], type_of_instance != :ondemand)
|
120
127
|
|
@@ -128,7 +135,7 @@ module AwsPricing
|
|
128
135
|
end
|
129
136
|
|
130
137
|
def fetch_ec2_ebs_pricing
|
131
|
-
res = fetch_url(EC2_BASE_URL + "pricing-ebs.
|
138
|
+
res = fetch_url(EC2_BASE_URL + "pricing-ebs.js")
|
132
139
|
res["config"]["regions"].each do |ebs_types|
|
133
140
|
region = get_region(ebs_types["region"])
|
134
141
|
region.ebs_price = EbsPrice.new(region, ebs_types)
|
@@ -183,9 +190,9 @@ module AwsPricing
|
|
183
190
|
is_byol = is_byol? dp_type
|
184
191
|
|
185
192
|
if [:mysql, :postgresql, :oracle].include? db
|
186
|
-
fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{dp_type}-deployments.
|
193
|
+
fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{dp_type}-deployments.js",:ondemand, db_type, is_byol)
|
187
194
|
elsif db == :sqlserver
|
188
|
-
fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/sqlserver-#{dp_type}-ondemand.
|
195
|
+
fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/sqlserver-#{dp_type}-ondemand.js",:ondemand, db_type, is_byol)
|
189
196
|
end
|
190
197
|
end
|
191
198
|
}
|
@@ -197,9 +204,9 @@ module AwsPricing
|
|
197
204
|
if [:mysql, :postgresql].include? db
|
198
205
|
@@RES_TYPES.each do |res_type|
|
199
206
|
if db == :postgresql and res_type == :heavy
|
200
|
-
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{res_type}-utilization-reserved-instances.
|
207
|
+
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{res_type}-utilization-reserved-instances.js", res_type, db, false)
|
201
208
|
elsif db == :mysql
|
202
|
-
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{res_type}-utilization-reserved-instances.
|
209
|
+
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{res_type}-utilization-reserved-instances.js", res_type, db, false)
|
203
210
|
end
|
204
211
|
end
|
205
212
|
else
|
@@ -208,9 +215,9 @@ module AwsPricing
|
|
208
215
|
db_instance.each do |dp_type|
|
209
216
|
is_byol = is_byol? dp_type
|
210
217
|
if db == :oracle
|
211
|
-
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{dp_type}-#{res_type}-utilization-reserved-instances.
|
218
|
+
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{dp_type}-#{res_type}-utilization-reserved-instances.js", res_type, db_type, is_byol)
|
212
219
|
elsif db == :sqlserver
|
213
|
-
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/sqlserver-#{dp_type}-#{res_type}-ri.
|
220
|
+
fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/sqlserver-#{dp_type}-#{res_type}-ri.js", res_type, db_type, is_byol)
|
214
221
|
end
|
215
222
|
end
|
216
223
|
end
|
@@ -229,7 +236,7 @@ module AwsPricing
|
|
229
236
|
begin
|
230
237
|
#
|
231
238
|
# this is special case URL, it is oracle - multiAZ type of deployment but it doesn't have mutliAZ attributes in json.
|
232
|
-
if url == "http://aws.amazon.com/rds/pricing/oracle/pricing-li-multiAZ-deployments.
|
239
|
+
if url == "http://aws.amazon.com/rds/pricing/oracle/pricing-li-multiAZ-deployments.js"
|
233
240
|
is_multi_az = true
|
234
241
|
else
|
235
242
|
is_multi_az = is_multi_az? type["name"]
|
@@ -65,7 +65,7 @@ module AwsPricing
|
|
65
65
|
@@Name_Lookup = {
|
66
66
|
'm1.small' => 'Standard Small', 'm1.medium' => 'Standard Medium', 'm1.large' => 'Standard Large', 'm1.xlarge' => 'Standard Extra Large',
|
67
67
|
'm2.xlarge' => 'Hi-Memory Extra Large', 'm2.2xlarge' => 'Hi-Memory Double Extra Large', 'm2.4xlarge' => 'Hi-Memory Quadruple Extra Large',
|
68
|
-
'm3.xlarge' => 'M3 Extra Large Instance', 'm3.2xlarge' => 'M3 Double Extra Large Instance',
|
68
|
+
'm3.medium' => 'M3 Medium Instance', 'm3.large'=>'M3 Large Instance', 'm3.xlarge' => 'M3 Extra Large Instance', 'm3.2xlarge' => 'M3 Double Extra Large Instance',
|
69
69
|
'c1.medium' => 'High-CPU Medium', 'c1.xlarge' => 'High-CPU Extra Large',
|
70
70
|
'hi1.4xlarge' => 'High I/O Quadruple Extra Large',
|
71
71
|
'cg1.4xlarge' => 'Cluster GPU Quadruple Extra Large',
|
@@ -21,7 +21,7 @@ module AwsPricing
|
|
21
21
|
class InstanceType
|
22
22
|
attr_accessor :name, :api_name, :memory_in_mb, :platform, :compute_units, :virtual_cores, :disk_type, :disk_in_gb
|
23
23
|
|
24
|
-
def initialize(region, api_name, name)
|
24
|
+
def initialize(region, api_name, name, json)
|
25
25
|
@category_types = {}
|
26
26
|
|
27
27
|
@region = region
|
@@ -113,13 +113,12 @@ module AwsPricing
|
|
113
113
|
@@Memory_Lookup = {
|
114
114
|
'm1.small' => 1700, 'm1.medium' => 3750, 'm1.large' => 7500, 'm1.xlarge' => 15000,
|
115
115
|
'm2.xlarge' => 17100, 'm2.2xlarge' => 34200, 'm2.4xlarge' => 68400,
|
116
|
-
'm3.xlarge' => 15000, 'm3.2xlarge' => 30000,
|
116
|
+
'm3.medium' => 3750, 'm3.large' => 7500, 'm3.xlarge' => 15000, 'm3.2xlarge' => 30000,
|
117
117
|
'c1.medium' => 1700, 'c1.xlarge' => 7000,
|
118
118
|
'hi1.4xlarge' => 60500,
|
119
119
|
'cg1.4xlarge' => 22000,
|
120
120
|
'cc1.4xlarge' => 23000, 'cc2.8xlarge' => 60500,
|
121
121
|
't1.micro' => 1700,
|
122
|
-
'm3.xlarge' => 15000, 'm3.xlarge' => 30000,
|
123
122
|
'cr1.8xlarge' => 244000,
|
124
123
|
'hs1.8xlarge' => 117000,
|
125
124
|
'g2.2xlarge' => 15000,
|
@@ -132,13 +131,12 @@ module AwsPricing
|
|
132
131
|
@@Disk_Lookup = {
|
133
132
|
'm1.small' => 160, 'm1.medium' => 410, 'm1.large' =>850, 'm1.xlarge' => 1690,
|
134
133
|
'm2.xlarge' => 420, 'm2.2xlarge' => 850, 'm2.4xlarge' => 1690,
|
135
|
-
'm3.xlarge' =>
|
134
|
+
'm3.medium' => 4, 'm3.large' => 32, 'm3.xlarge' => 80, 'm3.2xlarge' => 160,
|
136
135
|
'c1.medium' => 350, 'c1.xlarge' => 1690,
|
137
136
|
'hi1.4xlarge' => 2048,
|
138
137
|
'cg1.4xlarge' => 1690,
|
139
138
|
'cc1.4xlarge' => 1690, 'cc2.8xlarge' => 3370,
|
140
139
|
't1.micro' => 160,
|
141
|
-
'm3.xlarge' => 0, 'm3.xlarge' => 0,
|
142
140
|
'cr1.8xlarge' => 240,
|
143
141
|
'hs1.8xlarge' => 48000,
|
144
142
|
'g2.2xlarge' => 60,
|
@@ -151,13 +149,12 @@ module AwsPricing
|
|
151
149
|
@@Platform_Lookup = {
|
152
150
|
'm1.small' => 32, 'm1.medium' => 32, 'm1.large' => 64, 'm1.xlarge' => 64,
|
153
151
|
'm2.xlarge' => 64, 'm2.2xlarge' => 64, 'm2.4xlarge' => 64,
|
154
|
-
'm3.xlarge' => 64, 'm3.2xlarge' => 64,
|
152
|
+
'm3.medium' => 64, 'm3.large' => 64, 'm3.xlarge' => 64, 'm3.2xlarge' => 64,
|
155
153
|
'c1.medium' => 32, 'c1.xlarge' => 64,
|
156
154
|
'hi1.4xlarge' => 64,
|
157
155
|
'cg1.4xlarge' => 64,
|
158
156
|
'cc1.4xlarge' => 64, 'cc2.8xlarge' => 64,
|
159
157
|
't1.micro' => 32,
|
160
|
-
'm3.xlarge' => 64, 'm3.xlarge' => 64,
|
161
158
|
'cr1.8xlarge' => 64,
|
162
159
|
'hs1.8xlarge' => 64,
|
163
160
|
'g2.2xlarge' => 64,
|
@@ -170,7 +167,7 @@ module AwsPricing
|
|
170
167
|
@@Compute_Units_Lookup = {
|
171
168
|
'm1.small' => 1, 'm1.medium' => 2, 'm1.large' => 4, 'm1.xlarge' => 8,
|
172
169
|
'm2.xlarge' => 6.5, 'm2.2xlarge' => 13, 'm2.4xlarge' => 26,
|
173
|
-
'm3.xlarge' => 13, 'm3.2xlarge' => 26,
|
170
|
+
'm3.medium' => 3, 'm3.large' => 6.5, 'm3.xlarge' => 13, 'm3.2xlarge' => 26,
|
174
171
|
'c1.medium' => 5, 'c1.xlarge' => 20,
|
175
172
|
'hi1.4xlarge' => 35,
|
176
173
|
'cg1.4xlarge' => 34,
|
@@ -190,7 +187,7 @@ module AwsPricing
|
|
190
187
|
@@Virtual_Cores_Lookup = {
|
191
188
|
'm1.small' => 1, 'm1.medium' => 1, 'm1.large' => 2, 'm1.xlarge' => 4,
|
192
189
|
'm2.xlarge' => 2, 'm2.2xlarge' => 4, 'm2.4xlarge' => 8,
|
193
|
-
'm3.xlarge' => 4, 'm3.2xlarge' => 8,
|
190
|
+
'm3.medium' => 1, 'm3.large' => 2, 'm3.xlarge' => 4, 'm3.2xlarge' => 8,
|
194
191
|
'c1.medium' => 2, 'c1.xlarge' => 8,
|
195
192
|
'hi1.4xlarge' => 16,
|
196
193
|
'cg1.4xlarge' => 8,
|
@@ -209,7 +206,7 @@ module AwsPricing
|
|
209
206
|
@@Disk_Type_Lookup = {
|
210
207
|
'm1.small' => :ephemeral, 'm1.medium' => :ephemeral, 'm1.large' => :ephemeral, 'm1.xlarge' => :ephemeral,
|
211
208
|
'm2.xlarge' => :ephemeral, 'm2.2xlarge' => :ephemeral, 'm2.4xlarge' => :ephemeral,
|
212
|
-
'm3.xlarge' => :
|
209
|
+
'm3.medium' => :ssd, 'm3.large' => :ssd, 'm3.xlarge' => :ssd, 'm3.2xlarge' => :ssd,
|
213
210
|
'c1.medium' => :ephemeral, 'c1.xlarge' => :ephemeral,
|
214
211
|
'hi1.4xlarge' => :ssd,
|
215
212
|
'cg1.4xlarge' => :ephemeral,
|
@@ -49,7 +49,7 @@ module AwsPricing
|
|
49
49
|
def add_or_update_ec2_instance_type(api_name, name, operating_system, type_of_instance, json)
|
50
50
|
current = get_ec2_instance_type(api_name)
|
51
51
|
if current.nil?
|
52
|
-
current = Ec2InstanceType.new(self, api_name, name)
|
52
|
+
current = Ec2InstanceType.new(self, api_name, name, json)
|
53
53
|
@ec2_instance_types[api_name] = current
|
54
54
|
end
|
55
55
|
current.update_pricing(operating_system, type_of_instance, json)
|
@@ -59,7 +59,7 @@ module AwsPricing
|
|
59
59
|
def add_or_update_rds_instance_type(api_name, name, db_type, type_of_instance, json, is_multi_az, is_byol)
|
60
60
|
current = get_rds_instance_type(api_name)
|
61
61
|
if current.nil?
|
62
|
-
current = RdsInstanceType.new(self, api_name, name)
|
62
|
+
current = RdsInstanceType.new(self, api_name, name, json)
|
63
63
|
@rds_instance_types[api_name] = current
|
64
64
|
end
|
65
65
|
current.update_pricing(db_type, type_of_instance, json, is_multi_az, is_byol)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-pricing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby library for retrieving pricing for Amazon Web Services
|
15
15
|
email:
|
@@ -64,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
segments:
|
66
66
|
- 0
|
67
|
-
hash:
|
67
|
+
hash: -574504011495470816
|
68
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
70
|
requirements:
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
segments:
|
75
75
|
- 0
|
76
|
-
hash:
|
76
|
+
hash: -574504011495470816
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project: amazon-pricing
|
79
79
|
rubygems_version: 1.8.25
|