amazon-pricing 0.1.62 → 0.1.63
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/amazon-pricing/definitions/rds-instance-type.rb +36 -1
- data/lib/amazon-pricing/rds-price-list.rb +71 -0
- data/lib/amazon-pricing/version.rb +2 -2
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -102,7 +102,7 @@ def print_rds_table(pricing, target_region = nil)
|
|
102
102
|
end
|
103
103
|
|
104
104
|
[:year1, :year3].each do |term|
|
105
|
-
[:light, :medium, :heavy].each do |res_type|
|
105
|
+
[:light, :medium, :heavy, :allupfront, :partialupfront, :noupfront].each do |res_type|
|
106
106
|
AwsPricing::DatabaseType.get_database_name.each do |db|
|
107
107
|
unless AwsPricing::DatabaseType.get_available_types(db).nil?
|
108
108
|
AwsPricing::DatabaseType.get_available_types(db).each do |deploy_type|
|
@@ -136,7 +136,7 @@ def print_rds_table(pricing, target_region = nil)
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
[:year1, :year3].each do |term|
|
139
|
-
[:light, :medium, :heavy].each do |res_type|
|
139
|
+
[:light, :medium, :heavy, :allupfront, :partialupfront, :noupfront].each do |res_type|
|
140
140
|
AwsPricing::DatabaseType.get_database_name.each do |db|
|
141
141
|
unless AwsPricing::DatabaseType.get_available_types(db).nil?
|
142
142
|
AwsPricing::DatabaseType.get_available_types(db).each do |deploy_type|
|
@@ -81,12 +81,47 @@ module AwsPricing
|
|
81
81
|
when "yearTerm1Hourly"
|
82
82
|
db.set_price_per_hour(type_of_instance, :year1, price)
|
83
83
|
when "yearTerm3Hourly"
|
84
|
-
db.set_price_per_hour(type_of_instance, :year3, price)
|
84
|
+
db.set_price_per_hour(type_of_instance, :year3, price)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
def update_pricing_new(database_type, type_of_instance, prices, term = nil, is_multi_az, is_byol)
|
91
|
+
db = get_category_type(database_type, is_multi_az, is_byol)
|
92
|
+
if db.nil?
|
93
|
+
db = DatabaseType.new(self, database_type)
|
94
|
+
|
95
|
+
if is_multi_az == true and is_byol == true
|
96
|
+
@category_types["#{database_type}_byol_multiaz"] = db
|
97
|
+
elsif is_multi_az == true and is_byol == false
|
98
|
+
@category_types["#{database_type}_multiaz"] = db
|
99
|
+
elsif is_multi_az == false and is_byol == true
|
100
|
+
@category_types["#{database_type}_byol"] = db
|
101
|
+
else
|
102
|
+
@category_types[database_type] = db
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
terms_to_years = {
|
108
|
+
"yrTerm1" => :year1,
|
109
|
+
"yrTerm3" => :year3
|
110
|
+
}
|
111
|
+
years = terms_to_years[term]
|
112
|
+
prices.each do |price|
|
113
|
+
p = price['prices']['USD']
|
114
|
+
case price['name']
|
115
|
+
when 'upfront'
|
116
|
+
db.set_prepay(type_of_instance, years, p.to_f) unless type_of_instance == :noupfront || p == "N/A"
|
117
|
+
when 'monthlyStar'
|
118
|
+
db.set_price_per_hour(type_of_instance, years, p.to_f * 12 / 365 / 24) unless type_of_instance == :allupfront || p == "N/A"
|
119
|
+
else
|
120
|
+
# Do nothing for other names
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
90
125
|
def update_pricing2(database_type, type_of_instance, is_multi_az, is_byol, ondemand_pph = nil, year1_prepay = nil, year3_prepay = nil, year1_pph = nil, year3_pph = nil)
|
91
126
|
db = get_category_type(database_type, is_multi_az, is_byol)
|
92
127
|
if db.nil?
|
@@ -5,6 +5,7 @@ module AwsPricing
|
|
5
5
|
super
|
6
6
|
InstanceType.populate_lookups
|
7
7
|
get_rds_on_demand_instance_pricing
|
8
|
+
get_rds_reserved_instance_pricing2
|
8
9
|
get_rds_reserved_instance_pricing
|
9
10
|
end
|
10
11
|
|
@@ -34,6 +35,22 @@ module AwsPricing
|
|
34
35
|
:sqlserver=> {:sqlserver_ex=>["li-ex"], :sqlserver_web=>["li-web"], :sqlserver_se=>["li-se","byol"], :sqlserver_ee=>["byol"]}
|
35
36
|
}
|
36
37
|
|
38
|
+
@@RESERVED_DB_DEPLOY_TYPE2 = {
|
39
|
+
:mysql => {:mysql=>["standard","multiAZ"]},
|
40
|
+
:postgresql => {:postgresql=>["standard","multiAZ"]},
|
41
|
+
:oracle => {:oracle_se1=>["license-included-standard", "license-included-multiAZ"],
|
42
|
+
:oracle_se=>["byol-standard", "byol-multiAZ"]},
|
43
|
+
:sqlserver=> {:sqlserver_se=>["byol-standard", "byol-multiAZ"]}
|
44
|
+
}
|
45
|
+
|
46
|
+
@@RESERVED_DB_WITH_SAME_PRICING2 = {
|
47
|
+
:mysql => [:mysql],
|
48
|
+
:postgresql => [:postgresql],
|
49
|
+
:oracle_se1 => [:oracle_se1],
|
50
|
+
:oracle_se => [:oracle_se, :oracle_se1, :oracle_ee],
|
51
|
+
:sqlserver_se => [:sqlserver_se, :sqlserver_ee]
|
52
|
+
}
|
53
|
+
|
37
54
|
def is_multi_az?(type)
|
38
55
|
return true if type.upcase.match("MULTI-AZ")
|
39
56
|
false
|
@@ -80,6 +97,60 @@ module AwsPricing
|
|
80
97
|
end
|
81
98
|
end
|
82
99
|
|
100
|
+
def get_rds_reserved_instance_pricing2
|
101
|
+
@@DB_TYPE.each do |db_name|
|
102
|
+
@@RESERVED_DB_DEPLOY_TYPE2[db_name].each do |db, deploy_types|
|
103
|
+
deploy_types.each do |deploy_type|
|
104
|
+
is_byol = is_byol? deploy_type
|
105
|
+
is_multi_az = deploy_type.upcase.include?("MULTIAZ")
|
106
|
+
db_str = db == :sqlserver_se ? 'sql-server-se' : db.to_s.gsub(/_/, '-')
|
107
|
+
dbs_with_same_pricing = @@RESERVED_DB_WITH_SAME_PRICING2[db]
|
108
|
+
fetch_reserved_rds_instance_pricing2(RDS_BASE_URL+"reserved-instances/#{db_str}-#{deploy_type}.min.js", dbs_with_same_pricing, is_multi_az, is_byol)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def fetch_reserved_rds_instance_pricing2(url, dbs, is_multi_az, is_byol)
|
115
|
+
res = PriceList.fetch_url(url)
|
116
|
+
res['config']['regions'].each do |reg|
|
117
|
+
region_name = reg['region']
|
118
|
+
region = get_region(region_name)
|
119
|
+
if region.nil?
|
120
|
+
$stderr.puts "[fetch_reserved_rds_instance_pricing2] WARNING: unable to find region #{region_name}"
|
121
|
+
next
|
122
|
+
end
|
123
|
+
reg['instanceTypes'].each do |type|
|
124
|
+
api_name = type["type"]
|
125
|
+
instance_type = region.get_rds_instance_type(api_name)
|
126
|
+
if instance_type.nil?
|
127
|
+
$stderr.puts "[fetch_reserved_rds_instance_pricing2] WARNING: new reserved instances not found for #{api_name} in #{region_name}"
|
128
|
+
next
|
129
|
+
end
|
130
|
+
|
131
|
+
type["terms"].each do |term|
|
132
|
+
term["purchaseOptions"].each do |option|
|
133
|
+
case option["purchaseOption"]
|
134
|
+
when "noUpfront"
|
135
|
+
reservation_type = :noupfront
|
136
|
+
when "allUpfront"
|
137
|
+
reservation_type = :allupfront
|
138
|
+
when "partialUpfront"
|
139
|
+
reservation_type = :partialupfront
|
140
|
+
end
|
141
|
+
|
142
|
+
duration = term["term"]
|
143
|
+
prices = option["valueColumns"]
|
144
|
+
dbs.each do |db|
|
145
|
+
instance_type.update_pricing_new(db, reservation_type, prices, duration, is_multi_az, is_byol)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
83
154
|
def get_rds_reserved_instance_pricing
|
84
155
|
@@DB_TYPE.each do |db|
|
85
156
|
if [:mysql, :postgresql].include? db
|
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.63
|
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: 2015-06-
|
12
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|