amazon-pricing 0.1.48 → 0.1.49
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -2
- data/lib/.DS_Store +0 -0
- data/lib/amazon-pricing.rb +5 -0
- data/lib/amazon-pricing/category-type.rb +80 -4
- data/lib/amazon-pricing/ec2-instance-type.rb +23 -0
- data/lib/amazon-pricing/instance-type.rb +16 -14
- data/lib/amazon-pricing/region.rb +1 -1
- data/lib/amazon-pricing/version.rb +1 -1
- data/lib/aws-price-list.rb +52 -23
- data/lib/ec2-price-list.rb +88 -5
- data/lib/gov-cloud-price-list.rb +8 -6
- data/lib/rds-price-list.rb +3 -3
- data/test/govcloud_test.rb +0 -10
- metadata +14 -6
- checksums.yaml +0 -15
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -62,7 +62,7 @@ task :default => [:test]
|
|
62
62
|
def print_ec2_table(pricing)
|
63
63
|
line = "Region,Instance Type,API Name,Memory (MB),Disk (GB),Compute Units,Virtual Cores,Disk Type,OD Linux PPH,OD Windows PPH,OD RHEL PPH,OD SLES PPH,OD MsWinSQL PPH,OD MsWinSQLWeb PPH,"
|
64
64
|
[:year1, :year3].each do |term|
|
65
|
-
[:light, :medium, :heavy].each do |res_type|
|
65
|
+
[:light, :medium, :heavy, :allupfront, :partialupfront, :noupfront].each do |res_type|
|
66
66
|
[:linux, :mswin, :rhel, :sles, :mswinSQL, :mswinSQLWeb].each do |os|
|
67
67
|
line += "#{term} #{res_type} #{os} Prepay,#{term} #{res_type} #{os} PPH,"
|
68
68
|
end
|
@@ -76,7 +76,7 @@ def print_ec2_table(pricing)
|
|
76
76
|
line += "#{t.price_per_hour(os, :ondemand)},"
|
77
77
|
end
|
78
78
|
[:year1, :year3].each do |term|
|
79
|
-
[:light, :medium, :heavy].each do |res_type|
|
79
|
+
[:light, :medium, :heavy, :allupfront, :partialupfront, :noupfront].each do |res_type|
|
80
80
|
[:linux, :mswin, :rhel, :sles, :mswinSQL, :mswinSQLWeb].each do |os|
|
81
81
|
line += "#{t.prepay(os, res_type, term)},#{t.price_per_hour(os, res_type, term)},"
|
82
82
|
end
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/amazon-pricing.rb
CHANGED
@@ -13,8 +13,10 @@ module AwsPricing
|
|
13
13
|
attr_accessor :instance_type, :name,
|
14
14
|
:ondemand_price_per_hour, :light_price_per_hour_1_year, :medium_price_per_hour_1_year, :heavy_price_per_hour_1_year,
|
15
15
|
:light_price_per_hour_3_year, :medium_price_per_hour_3_year, :heavy_price_per_hour_3_year,
|
16
|
-
:light_prepay_1_year, :light_prepay_3_year, :medium_prepay_1_year, :medium_prepay_3_year, :heavy_prepay_1_year, :heavy_prepay_3_year
|
17
|
-
|
16
|
+
:light_prepay_1_year, :light_prepay_3_year, :medium_prepay_1_year, :medium_prepay_3_year, :heavy_prepay_1_year, :heavy_prepay_3_year,
|
17
|
+
:allupfront_price_per_hour_1_year, :allupfront_prepay_1_year, :allupfront_price_per_hour_3_year, :allupfront_prepay_3_year,
|
18
|
+
:partialupfront_price_per_hour_1_year, :partialupfront_prepay_1_year, :partialupfront_price_per_hour_3_year, :partialupfront_prepay_3_year,
|
19
|
+
:noupfront_price_per_hour_1_year, :noupfront_prepay_1_year, :noupfront_price_per_hour_3_year, :noupfront_prepay_3_year
|
18
20
|
|
19
21
|
def initialize(instance_type=nil, name=nil)
|
20
22
|
@instance_type = instance_type
|
@@ -51,11 +53,29 @@ module AwsPricing
|
|
51
53
|
elsif term == :year3
|
52
54
|
@heavy_prepay_3_year
|
53
55
|
end
|
56
|
+
when :allupfront
|
57
|
+
if term == :year1
|
58
|
+
@allupfront_prepay_1_year
|
59
|
+
elsif term == :year3
|
60
|
+
@allupfront_prepay_3_year
|
61
|
+
end
|
62
|
+
when :partialupfront
|
63
|
+
if term == :year1
|
64
|
+
@partialupfront_prepay_1_year
|
65
|
+
elsif term == :year3
|
66
|
+
@partialupfront_prepay_3_year
|
67
|
+
end
|
68
|
+
when :noupfront
|
69
|
+
if term == :year1
|
70
|
+
@noupfront_prepay_1_year
|
71
|
+
elsif term == :year3
|
72
|
+
@noupfront_prepay_3_year
|
73
|
+
end
|
54
74
|
end
|
55
75
|
end
|
56
76
|
|
57
77
|
# type_of_instance = :ondemand, :light, :medium, :heavy
|
58
|
-
# term = :
|
78
|
+
# term = :year1, :year3, nil
|
59
79
|
def set_prepay(type_of_instance, term, price)
|
60
80
|
case type_of_instance
|
61
81
|
when :light
|
@@ -76,11 +96,31 @@ module AwsPricing
|
|
76
96
|
elsif term == :year3
|
77
97
|
@heavy_prepay_3_year = price
|
78
98
|
end
|
99
|
+
when :allupfront
|
100
|
+
if term == :year1
|
101
|
+
@allupfront_prepay_1_year = price
|
102
|
+
elsif term == :year3
|
103
|
+
@allupfront_prepay_3_year = price
|
104
|
+
end
|
105
|
+
when :partialupfront
|
106
|
+
if term == :year1
|
107
|
+
@partialupfront_prepay_1_year = price
|
108
|
+
elsif term == :year3
|
109
|
+
@partialupfront_prepay_3_year = price
|
110
|
+
end
|
111
|
+
when :noupfront
|
112
|
+
if term == :year1
|
113
|
+
@noupfront_prepay_1_year = price
|
114
|
+
elsif term == :year3
|
115
|
+
@noupfront_prepay_3_year = price
|
116
|
+
end
|
117
|
+
else
|
118
|
+
raise "Unable to set prepay for #{type_of_instance} : #{term} to #{price}"
|
79
119
|
end
|
80
120
|
end
|
81
121
|
|
82
122
|
# type_of_instance = :ondemand, :light, :medium, :heavy
|
83
|
-
# term = :
|
123
|
+
# term = :year1, :year3, nil
|
84
124
|
def price_per_hour(type_of_instance = :ondemand, term = nil)
|
85
125
|
case type_of_instance
|
86
126
|
when :ondemand
|
@@ -103,6 +143,24 @@ module AwsPricing
|
|
103
143
|
elsif term == :year3
|
104
144
|
@heavy_price_per_hour_3_year
|
105
145
|
end
|
146
|
+
when :allupfront
|
147
|
+
if term == :year1
|
148
|
+
@allupfront_price_per_hour_1_year
|
149
|
+
elsif term == :year3
|
150
|
+
@allupfront_price_per_hour_3_year
|
151
|
+
end
|
152
|
+
when :partialupfront
|
153
|
+
if term == :year1
|
154
|
+
@partialupfront_price_per_hour_1_year
|
155
|
+
elsif term == :year3
|
156
|
+
@partialupfront_price_per_hour_3_year
|
157
|
+
end
|
158
|
+
when :noupfront
|
159
|
+
if term == :year1
|
160
|
+
@noupfront_price_per_hour_1_year
|
161
|
+
elsif term == :year3
|
162
|
+
@noupfront_price_per_hour_3_year
|
163
|
+
end
|
106
164
|
end
|
107
165
|
end
|
108
166
|
|
@@ -130,6 +188,24 @@ module AwsPricing
|
|
130
188
|
elsif term == :year3
|
131
189
|
@heavy_price_per_hour_3_year = price_per_hour
|
132
190
|
end
|
191
|
+
when :allupfront
|
192
|
+
if term == :year1
|
193
|
+
@allupfront_price_per_hour_1_year = price_per_hour
|
194
|
+
elsif term == :year3
|
195
|
+
@allupfront_price_per_hour_3_year = price_per_hour
|
196
|
+
end
|
197
|
+
when :partialupfront
|
198
|
+
if term == :year1
|
199
|
+
@partialupfront_price_per_hour_1_year = price_per_hour
|
200
|
+
elsif term == :year3
|
201
|
+
@partialupfront_price_per_hour_3_year = price_per_hour
|
202
|
+
end
|
203
|
+
when :noupfront
|
204
|
+
if term == :year1
|
205
|
+
@noupfront_price_per_hour_1_year = price_per_hour
|
206
|
+
elsif term == :year3
|
207
|
+
@noupfront_price_per_hour_3_year = price_per_hour
|
208
|
+
end
|
133
209
|
end
|
134
210
|
end
|
135
211
|
|
@@ -17,6 +17,29 @@ module AwsPricing
|
|
17
17
|
os.available?(type_of_instance)
|
18
18
|
end
|
19
19
|
|
20
|
+
# operating_system = :linux, :mswin, :rhel, :sles, :mswinSQL, :mswinSQLWeb
|
21
|
+
# type_of_instance = :ondemand, :light, :medium, :heavy, :allupfront, partialupfront, :noupfront
|
22
|
+
# term = nil (on demand), yrTerm1, yrTerm3
|
23
|
+
def update_pricing_new(operating_system, type_of_instance, price, term = nil, is_prepay = false)
|
24
|
+
os = get_category_type(operating_system)
|
25
|
+
if os.nil?
|
26
|
+
os = OperatingSystem.new(self, operating_system)
|
27
|
+
@category_types[operating_system] = os
|
28
|
+
end
|
29
|
+
|
30
|
+
if type_of_instance == :ondemand
|
31
|
+
os.set_price_per_hour(type_of_instance, nil, price)
|
32
|
+
else
|
33
|
+
years = :year1 if term == "yrTerm1"
|
34
|
+
years = :year3 if term == "yrTerm3"
|
35
|
+
if is_prepay
|
36
|
+
os.set_prepay(type_of_instance, years, price)
|
37
|
+
else
|
38
|
+
os.set_price_per_hour(type_of_instance, years, price)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
20
43
|
# operating_system = :linux, :mswin, :rhel, :sles, :mswinSQL, :mswinSQLWeb
|
21
44
|
# type_of_instance = :ondemand, :light, :medium, :heavy
|
22
45
|
def update_pricing(operating_system, type_of_instance, json)
|
@@ -93,24 +93,26 @@ module AwsPricing
|
|
93
93
|
|
94
94
|
def self.populate_lookups
|
95
95
|
# We use Linux on-demand to populate the lookup tables with the basic lookup information
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
96
|
+
["http://a0.awsstatic.com/pricing/1/ec2/linux-od.min.js", "http://a0.awsstatic.com/pricing/1/ec2/previous-generation/linux-od.min.js"].each do |url|
|
97
|
+
res = AwsPricing::PriceList.fetch_url(url)
|
98
|
+
|
99
|
+
res['config']['regions'].each do |reg|
|
100
|
+
reg['instanceTypes'].each do |type|
|
101
|
+
items = type['sizes']
|
102
|
+
items = [type] if items.nil?
|
103
|
+
items.each do |size|
|
104
|
+
begin
|
105
|
+
api_name = size["size"]
|
106
|
+
@@Memory_Lookup[api_name] = size["memoryGiB"].to_f * 1000
|
107
|
+
@@Compute_Units_Lookup[api_name] = size["ECU"].to_i
|
108
|
+
@@Virtual_Cores_Lookup[api_name] = size["vCPU"].to_i
|
109
|
+
rescue UnknownTypeError
|
110
|
+
$stderr.puts "WARNING: encountered #{$!.message}"
|
111
|
+
end
|
109
112
|
end
|
110
113
|
end
|
111
114
|
end
|
112
115
|
end
|
113
|
-
|
114
116
|
end
|
115
117
|
|
116
118
|
protected
|
data/lib/aws-price-list.rb
CHANGED
@@ -16,8 +16,27 @@ module AwsPricing
|
|
16
16
|
class PriceList
|
17
17
|
attr_accessor :regions
|
18
18
|
|
19
|
+
def initialize(is_govcloud = false)
|
20
|
+
@_regions = {}
|
21
|
+
|
22
|
+
# Creating regions upfront since different json files all use different naming conventions. No more ad-hoc creation.
|
23
|
+
if is_govcloud
|
24
|
+
regions = ["us-gov-west-1"]
|
25
|
+
else
|
26
|
+
# AWS added some but not all of teh data for us-gov-west-1. Not sure why they have not completed it. If they do not deprecate the screen scraping.
|
27
|
+
regions = ["eu-west-1", "sa-east-1", "us-east-1", "ap-northeast-1", "us-west-2", "us-west-1", "ap-southeast-1", "ap-southeast-2", "eu-central-1"]
|
28
|
+
end
|
29
|
+
|
30
|
+
regions.each do |name|
|
31
|
+
@_regions[name] = Region.new(name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# EBS now reports regions correctly but all else still has the old format - so we need to handle both
|
36
|
+
# region mapping and non-mapping
|
19
37
|
def get_region(name)
|
20
|
-
|
38
|
+
#@_regions[@@Region_Lookup[name] || name]
|
39
|
+
@_regions[convert_region(name)]
|
21
40
|
end
|
22
41
|
|
23
42
|
def regions
|
@@ -66,34 +85,44 @@ module AwsPricing
|
|
66
85
|
|
67
86
|
attr_accessor :_regions
|
68
87
|
|
69
|
-
def add_region(region)
|
70
|
-
|
71
|
-
end
|
88
|
+
#def add_region(region)
|
89
|
+
# @_regions[region.name] = region
|
90
|
+
#end
|
72
91
|
|
73
|
-
def find_or_create_region(name)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
92
|
+
#def find_or_create_region(name)
|
93
|
+
# region = get_region(name)
|
94
|
+
# if region.nil?
|
95
|
+
# # We must use standard names
|
96
|
+
# region = Region.new(name)
|
97
|
+
# add_region(region)
|
98
|
+
# end
|
99
|
+
# region
|
100
|
+
#end
|
81
101
|
|
82
102
|
EC2_BASE_URL = "http://a0.awsstatic.com/pricing/1/ec2/"
|
83
103
|
EBS_BASE_URL = "http://a0.awsstatic.com/pricing/1/ebs/"
|
84
104
|
RDS_BASE_URL = "http://a0.awsstatic.com/pricing/1/rds/"
|
85
105
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
106
|
+
def convert_region(name)
|
107
|
+
case name
|
108
|
+
when "us-east"
|
109
|
+
"us-east-1"
|
110
|
+
when "us-west"
|
111
|
+
"us-west-1"
|
112
|
+
when "eu-ireland"
|
113
|
+
"eu-west-1"
|
114
|
+
when "apac-sin"
|
115
|
+
"ap-southeast-1"
|
116
|
+
when "apac-syd"
|
117
|
+
"ap-southeast-2"
|
118
|
+
when "apac-tokyo"
|
119
|
+
"ap-northeast-1"
|
120
|
+
when "eu-frankfurt"
|
121
|
+
"eu-central-1"
|
122
|
+
else
|
123
|
+
name
|
124
|
+
end
|
125
|
+
end
|
97
126
|
|
98
127
|
end
|
99
128
|
|
data/lib/ec2-price-list.rb
CHANGED
@@ -2,9 +2,10 @@ module AwsPricing
|
|
2
2
|
class Ec2PriceList < PriceList
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
|
5
|
+
super
|
6
6
|
InstanceType.populate_lookups
|
7
7
|
get_ec2_on_demand_instance_pricing
|
8
|
+
get_ec2_legacy_reserved_instance_pricing
|
8
9
|
get_ec2_reserved_instance_pricing
|
9
10
|
fetch_ec2_ebs_pricing
|
10
11
|
end
|
@@ -12,7 +13,7 @@ module AwsPricing
|
|
12
13
|
protected
|
13
14
|
|
14
15
|
@@OS_TYPES = [:linux, :mswin, :rhel, :sles, :mswinSQL, :mswinSQLWeb]
|
15
|
-
@@
|
16
|
+
@@LEGACY_RES_TYPES = [:light, :medium, :heavy]
|
16
17
|
|
17
18
|
def get_ec2_on_demand_instance_pricing
|
18
19
|
@@OS_TYPES.each do |os|
|
@@ -24,9 +25,9 @@ module AwsPricing
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
def
|
28
|
+
def get_ec2_legacy_reserved_instance_pricing
|
28
29
|
@@OS_TYPES.each do |os|
|
29
|
-
@@
|
30
|
+
@@LEGACY_RES_TYPES.each do |res_type|
|
30
31
|
fetch_ec2_instance_pricing(EC2_BASE_URL + "#{os}-ri-#{res_type}.min.js", res_type, os)
|
31
32
|
# Rinse & repeat for legacy instances (note: amazon changed URLs for legacy reserved instances)
|
32
33
|
os_rewrite = os
|
@@ -39,13 +40,22 @@ module AwsPricing
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
43
|
+
def get_ec2_reserved_instance_pricing
|
44
|
+
# I give up on finding a pattern so just iterating over known URLs
|
45
|
+
page_targets = {"linux-unix" => :linux, "red-hat-enterprise-linux" => :rhel, "suse-linux" => :sles, "windows" => :mswin, "windows-with-sql-server-standard" => :mswinSQL, "windows-with-sql-server-web" => :mswinSQLWeb}
|
46
|
+
page_targets.each_pair do |target, operating_system|
|
47
|
+
url = "#{EC2_BASE_URL}ri-v2/#{target}-shared.min.js"
|
48
|
+
fetch_ec2_instance_pricing_ri_v2(url, operating_system)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
42
52
|
# Retrieves the EC2 on-demand instance pricing.
|
43
53
|
# type_of_instance = :ondemand, :light, :medium, :heavy
|
44
54
|
def fetch_ec2_instance_pricing(url, type_of_instance, operating_system)
|
45
55
|
res = PriceList.fetch_url(url)
|
46
56
|
res['config']['regions'].each do |reg|
|
47
57
|
region_name = reg['region']
|
48
|
-
region =
|
58
|
+
region = get_region(region_name)
|
49
59
|
# e.g. type = {"type"=>"hiCPUODI", "sizes"=>[{"size"=>"med", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"N/A"}}]}, {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}]}
|
50
60
|
reg['instanceTypes'].each do |type|
|
51
61
|
# e.g. size = {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}
|
@@ -66,6 +76,79 @@ module AwsPricing
|
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
79
|
+
# Retrieves the EC2 on-demand instance pricing.
|
80
|
+
# type_of_instance = :ondemand, :light, :medium, :heavy
|
81
|
+
def fetch_ec2_instance_pricing(url, type_of_instance, operating_system)
|
82
|
+
res = PriceList.fetch_url(url)
|
83
|
+
res['config']['regions'].each do |reg|
|
84
|
+
region_name = reg['region']
|
85
|
+
region = get_region(region_name)
|
86
|
+
if region.nil?
|
87
|
+
$stderr.puts "WARNING: unable to find region #{region_name}"
|
88
|
+
next
|
89
|
+
end
|
90
|
+
# e.g. type = {"type"=>"hiCPUODI", "sizes"=>[{"size"=>"med", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"N/A"}}]}, {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}]}
|
91
|
+
reg['instanceTypes'].each do |type|
|
92
|
+
# e.g. size = {"size"=>"xl", "valueColumns"=>[{"name"=>"mswinSQL", "prices"=>{"USD"=>"2.427"}}]}
|
93
|
+
# Amazon now can return array or hash here (hash = only 1 item)
|
94
|
+
items = type['sizes']
|
95
|
+
items = [type] if items.nil?
|
96
|
+
items.each do |size|
|
97
|
+
begin
|
98
|
+
api_name, name = Ec2InstanceType.get_name(type["type"], size["size"], type_of_instance != :ondemand)
|
99
|
+
instance_type = region.add_or_update_ec2_instance_type(api_name, name)
|
100
|
+
instance_type.update_pricing(operating_system, type_of_instance, size)
|
101
|
+
rescue UnknownTypeError
|
102
|
+
$stderr.puts "WARNING: encountered #{$!.message}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# With v2 of RIs they have an entirely new format that needs to be parsed
|
110
|
+
def fetch_ec2_instance_pricing_ri_v2(url, operating_system)
|
111
|
+
res = PriceList.fetch_url(url)
|
112
|
+
res['config']['regions'].each do |reg|
|
113
|
+
region_name = reg['region']
|
114
|
+
region = get_region(region_name)
|
115
|
+
if region.nil?
|
116
|
+
$stderr.puts "WARNING: unable to find region #{region_name}"
|
117
|
+
next
|
118
|
+
end
|
119
|
+
reg['instanceTypes'].each do |type|
|
120
|
+
api_name = type["type"]
|
121
|
+
instance_type = region.get_instance_type(api_name)
|
122
|
+
if instance_type.nil?
|
123
|
+
$stderr.puts "WARNING: new reserved instances not found for #{api_name} in #{region_name}"
|
124
|
+
next
|
125
|
+
end
|
126
|
+
|
127
|
+
type["terms"].each do |term|
|
128
|
+
term["purchaseOptions"].each do |option|
|
129
|
+
case option["purchaseOption"]
|
130
|
+
when "noUpfront"
|
131
|
+
reservation_type = :noupfront
|
132
|
+
when "allUpfront"
|
133
|
+
reservation_type = :allupfront
|
134
|
+
when "partialUpfront"
|
135
|
+
reservation_type = :partialupfront
|
136
|
+
end
|
137
|
+
|
138
|
+
duration = term["term"]
|
139
|
+
prices = option["valueColumns"]
|
140
|
+
upfront = prices.select{|i| i["name"] == "upfront"}.first
|
141
|
+
instance_type.update_pricing_new(operating_system, reservation_type, upfront["prices"]["USD"].to_f, duration, true) unless upfront.nil?
|
142
|
+
hourly = prices.select{|i| i["name"] == "monthlyStar"}.first
|
143
|
+
instance_type.update_pricing_new(operating_system, reservation_type, hourly["prices"]["USD"].to_f, duration, false)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
|
69
152
|
def fetch_ec2_ebs_pricing
|
70
153
|
res = PriceList.fetch_url(EBS_BASE_URL + "pricing-ebs.min.js")
|
71
154
|
res["config"]["regions"].each do |ebs_types|
|
data/lib/gov-cloud-price-list.rb
CHANGED
@@ -5,8 +5,7 @@ module AwsPricing
|
|
5
5
|
GOV_CLOUD_EBS_URL = "http://aws.amazon.com/govcloud-us/pricing/ebs/"
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
|
9
|
-
@_regions["us-gov-west-1"] = Region.new("us-gov-west-1")
|
8
|
+
super(true)
|
10
9
|
InstanceType.populate_lookups
|
11
10
|
get_ec2_instance_pricing
|
12
11
|
fetch_ec2_ebs_pricing
|
@@ -24,13 +23,16 @@ module AwsPricing
|
|
24
23
|
end
|
25
24
|
|
26
25
|
for i in 4..9
|
27
|
-
|
26
|
+
# GovCloud no longer supports reservation types
|
27
|
+
#create_reserved_instances(tables[i], :light)
|
28
28
|
end
|
29
29
|
for i in 9..22
|
30
|
-
|
30
|
+
# GovCloud no longer supports reservation types
|
31
|
+
#create_reserved_instances(tables[i], :medium)
|
31
32
|
end
|
32
33
|
for i in 23..33
|
33
|
-
|
34
|
+
# GovCloud no longer supports reservation types
|
35
|
+
#create_reserved_instances(tables[i], :heavy)
|
34
36
|
end
|
35
37
|
|
36
38
|
end
|
@@ -106,7 +108,7 @@ module AwsPricing
|
|
106
108
|
:sles
|
107
109
|
when "Windows"
|
108
110
|
:mswin
|
109
|
-
when "Windows SQL Server Web", "Windows SQL Server Web Edition", "Windows SQL Server\n Web Edition"
|
111
|
+
when "Windows SQL Server Web", "Windows SQL Server Web Edition", "Windows SQL Server\n Web Edition", "Server Web"
|
110
112
|
:mswinSQL
|
111
113
|
when "Windows SQL Server Standard", "Windows SQL Server Standard Edition", "Windows SQL Server\n Standard Edition"
|
112
114
|
:mswinSQLWeb
|
data/lib/rds-price-list.rb
CHANGED
@@ -2,7 +2,7 @@ module AwsPricing
|
|
2
2
|
class RdsPriceList < PriceList
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
|
5
|
+
super
|
6
6
|
InstanceType.populate_lookups
|
7
7
|
get_rds_on_demand_instance_pricing
|
8
8
|
get_rds_reserved_instance_pricing
|
@@ -110,7 +110,7 @@ module AwsPricing
|
|
110
110
|
res = PriceList.fetch_url(url)
|
111
111
|
res['config']['regions'].each do |reg|
|
112
112
|
region_name = reg['region']
|
113
|
-
region =
|
113
|
+
region = get_region(region_name)
|
114
114
|
reg['types'].each do |type|
|
115
115
|
type['tiers'].each do |tier|
|
116
116
|
begin
|
@@ -137,7 +137,7 @@ module AwsPricing
|
|
137
137
|
res = PriceList.fetch_url(url)
|
138
138
|
res['config']['regions'].each do |reg|
|
139
139
|
region_name = reg['region']
|
140
|
-
region =
|
140
|
+
region = get_region(region_name)
|
141
141
|
reg['instanceTypes'].each do |type|
|
142
142
|
type['tiers'].each do |tier|
|
143
143
|
begin
|
data/test/govcloud_test.rb
CHANGED
@@ -47,14 +47,4 @@ class TestGovCloud < Test::Unit::TestCase
|
|
47
47
|
assert region.ebs_price.s3_snaps_per_gb == 0.125
|
48
48
|
end
|
49
49
|
|
50
|
-
# Defect found in which ordering of price per hour and upfront get reversed
|
51
|
-
def test_ri_pricing
|
52
|
-
region = @@ec2_pricing.get_region('us-gov-west-1')
|
53
|
-
instance = region.get_ec2_instance_type('m3.large')
|
54
|
-
os = instance.get_operating_system(:linux)
|
55
|
-
assert os.ondemand_price_per_hour == 0.168
|
56
|
-
assert os.light_prepay_1_year == 300.0
|
57
|
-
assert os.light_price_per_hour_1_year == 0.167
|
58
|
-
end
|
59
|
-
|
60
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
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.49
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Joe Kinsella
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: A Ruby library for retrieving pricing for Amazon Web Services
|
14
15
|
email:
|
@@ -30,6 +31,7 @@ files:
|
|
30
31
|
- archive/ec2-2014-05-22.csv
|
31
32
|
- archive/rds-2014-03-18.csv
|
32
33
|
- archive/rds-2014-05-22.csv
|
34
|
+
- lib/.DS_Store
|
33
35
|
- lib/amazon-pricing.rb
|
34
36
|
- lib/amazon-pricing/category-type.rb
|
35
37
|
- lib/amazon-pricing/database-type.rb
|
@@ -55,7 +57,6 @@ files:
|
|
55
57
|
homepage: http://github.com/CloudHealth/amazon-pricing
|
56
58
|
licenses:
|
57
59
|
- MIT
|
58
|
-
metadata: {}
|
59
60
|
post_install_message:
|
60
61
|
rdoc_options:
|
61
62
|
- --title
|
@@ -66,20 +67,28 @@ rdoc_options:
|
|
66
67
|
require_paths:
|
67
68
|
- lib
|
68
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
69
71
|
requirements:
|
70
72
|
- - ! '>='
|
71
73
|
- !ruby/object:Gem::Version
|
72
74
|
version: '0'
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
hash: -2678167569791819720
|
73
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
74
80
|
requirements:
|
75
81
|
- - ! '>='
|
76
82
|
- !ruby/object:Gem::Version
|
77
83
|
version: '0'
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
hash: -2678167569791819720
|
78
87
|
requirements: []
|
79
88
|
rubyforge_project: amazon-pricing
|
80
|
-
rubygems_version:
|
89
|
+
rubygems_version: 1.8.25
|
81
90
|
signing_key:
|
82
|
-
specification_version:
|
91
|
+
specification_version: 3
|
83
92
|
summary: Amazon Web Services Pricing Ruby gem
|
84
93
|
test_files:
|
85
94
|
- spec/instance_type_spec.rb
|
@@ -90,4 +99,3 @@ test_files:
|
|
90
99
|
- test/ec2_instance_types_test.rb
|
91
100
|
- test/govcloud_test.rb
|
92
101
|
- test/helper.rb
|
93
|
-
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
M2Y3Y2NjMmVjZWNkZGUxYWY2NDU4ZWQ2YWM4NGQyOWY1YzE2ZjExZQ==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NjExZWM5NDg0YTFmZmFlZGZlMjQyMTMxMGY0ZGMzYjI0NmY0OGIwNA==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZDY0YzQ2OGYzZWNjN2QwZWNlNzNiODJmZmJjNzkwNjc2YTA2YmUzZDU4Nzk2
|
10
|
-
ZDNmMWYzZGE0MjUwMGE0MTM3NGIzNzI0ZDU5NDM1YTBmOTFkY2FjNzgyMzE1
|
11
|
-
ZWVjOGZmNDVkMTRjM2UxNjE5MjExY2JkNDAyYjA3NmY1YzFkOTg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OTdiNTUyOGVjNDFmMDFiNjliODBjYWNlZTc0NTgzZjJkMDBhMDg4NzM3NmY1
|
14
|
-
ZTY5ZjdhNjk2Yjc2MGM3YzI5NjE1YjEzODg1NTIxZWRmNjI4YzE0NWFhNWM3
|
15
|
-
OGU4Mzk4OWM1YmFmZmQxZjdiMDE2MWQ5YjFkNWFkNmMzYmRjYmE=
|