amazon-pricing 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,8 @@ module AwsPricing
13
13
  @@Database_Name_Lookup = {
14
14
  'mysql_standard'=> 'MySQL Community Edition',
15
15
  'mysql_multiaz'=> 'MySQL Community Edition (Multi-AZ)',
16
+ 'postgresql_standard'=> 'PostgreSql Community Edition(Beta)',
17
+ 'postgresql_multiaz'=> 'PostgreSql Community Edition(Beta) (Multi-AZ)',
16
18
  'oracle_se1_standard'=> 'Oracle Database Standard Edition One',
17
19
  'oracle_se1_multiaz'=> 'Oracle Database Standard Edition One (Multi-AZ)',
18
20
  'oracle_se1_byol'=> 'Oracle Database Standard Edition One (BYOL)',
@@ -30,6 +32,7 @@ module AwsPricing
30
32
 
31
33
  @@DB_Deploy_Types = {
32
34
  :mysql=>[:standard, :multiaz],
35
+ :postgresql=>[:standard, :multiaz],
33
36
  :oracle_se1=>[:standard, :multiaz, :byol, :byol_multiaz],
34
37
  :oracle_se=>[:byol, :byol_multiaz],
35
38
  :oracle_ee=>[:byol, :byol_multiaz],
@@ -42,7 +45,7 @@ module AwsPricing
42
45
  end
43
46
 
44
47
  def self.get_database_name
45
- [:mysql, :oracle_se1, :oracle_se, :oracle_ee, :sqlserver_ex, :sqlserver_web, :sqlserver_se, :sqlserver_ee]
48
+ [:mysql, :postgresql, :oracle_se1, :oracle_se, :oracle_ee, :sqlserver_ex, :sqlserver_web, :sqlserver_se, :sqlserver_ee]
46
49
  end
47
50
 
48
51
  def self.get_available_types(db)
@@ -77,9 +77,9 @@ module AwsPricing
77
77
 
78
78
  # type_of_instance = :ondemand, :light, :medium, :heavy
79
79
  # term = :year_1, :year_3, nil
80
- def get_breakeven_month(category_types, type_of_instance, term)
81
- os = get_category_type(category_types)
82
- os.get_breakeven_month(type_of_instance, term)
80
+ def get_breakeven_month(category_types, type_of_instance, term, is_multi_az = false, isByol = false)
81
+ cat = get_category_type(category_types, is_multi_az, isByol)
82
+ cat.get_breakeven_month(type_of_instance, term) unless cat.nil?
83
83
  end
84
84
 
85
85
  protected
@@ -3,6 +3,13 @@ module AwsPricing
3
3
  class RdsInstanceType < InstanceType
4
4
  # database_type = :mysql, :oracle, :sqlserver
5
5
  # type_of_instance = :ondemand, :light, :medium, :heavy
6
+
7
+ def available?(database_type = :mysql, type_of_instance = :ondemand, is_multi_az, is_byol)
8
+ db = get_category_type(database_type, is_multi_az, is_byol)
9
+ return false if db.nil?
10
+ db.available?(type_of_instance)
11
+ end
12
+
6
13
  def update_pricing(database_type, type_of_instance, json, is_multi_az, is_byol)
7
14
  db = get_category_type(database_type, is_multi_az, is_byol)
8
15
  if db.nil?
@@ -8,5 +8,5 @@
8
8
  # Home:: http://github.com/CloudHealth/amazon-pricing
9
9
  #++
10
10
  module AwsPricing
11
- VERSION = '0.1.14'
11
+ VERSION = '0.1.15'
12
12
  end
@@ -147,11 +147,12 @@ module AwsPricing
147
147
 
148
148
  protected
149
149
 
150
- @@DB_TYPE = [:mysql, :oracle, :sqlserver]
150
+ @@DB_TYPE = [:mysql, :postgresql, :oracle, :sqlserver]
151
151
  @@RES_TYPES = [:light, :medium, :heavy]
152
152
 
153
153
  @@OD_DB_DEPLOY_TYPE = {
154
154
  :mysql=> {:mysql=>["standard","multiAZ"]},
155
+ :postgresql=> {:postgresql=>["standard","multiAZ"]},
155
156
  :oracle=> {:oracle_se1=>["li-standard","li-multiAZ","byol-standard","byol-multiAZ"], :oracle_se=>["byol-standard","byol-multiAZ"], :oracle_ee=>["byol-standard","byol-multiAZ"]},
156
157
  :sqlserver=> {:sqlserver_ex=>["li-ex"], :sqlserver_web=>["li-web"], :sqlserver_se=>["li-se", "byol"], :sqlserver_ee=>["byol"]}
157
158
  }
@@ -181,7 +182,7 @@ module AwsPricing
181
182
  # to find out the byol type
182
183
  is_byol = is_byol? dp_type
183
184
 
184
- if db == :mysql or db == :oracle
185
+ if [:mysql, :postgresql, :oracle].include? db
185
186
  fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{dp_type}-deployments.json",:ondemand, db_type, is_byol)
186
187
  elsif db == :sqlserver
187
188
  fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/sqlserver-#{dp_type}-ondemand.json",:ondemand, db_type, is_byol)
@@ -193,9 +194,13 @@ module AwsPricing
193
194
 
194
195
  def get_rds_reserved_instance_pricing
195
196
  @@DB_TYPE.each do |db|
196
- if db == :mysql
197
+ if [:mysql, :postgresql].include? db
197
198
  @@RES_TYPES.each do |res_type|
198
- fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{res_type}-utilization-reserved-instances.json", res_type, db, false)
199
+ if db == :postgresql and res_type == :heavy
200
+ fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{res_type}-utilization-reserved-instances.json", res_type, db, false)
201
+ elsif db == :mysql
202
+ fetch_reserved_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{res_type}-utilization-reserved-instances.json", res_type, db, false)
203
+ end
199
204
  end
200
205
  else
201
206
  @@RESERVED_DB_DEPLOY_TYPE[db].each {|db_type, db_instance|
@@ -1,4 +1,5 @@
1
1
  require 'amazon-pricing'
2
+ require File.join('amazon-pricing', 'database-type')
2
3
 
3
4
  describe AwsPricing::RdsPriceList do
4
5
 
@@ -27,8 +28,42 @@ describe AwsPricing::RdsPriceList do
27
28
  describe '::get_api_name' do
28
29
  it "raises an UnknownTypeError on an unexpected instance type" do
29
30
  expect {
30
- AwsPricing::InstanceType::get_name 'QuantumODI', 'huge'
31
+ AwsPricing::RdsInstanceType::get_name 'QuantumODI', 'huge'
31
32
  }.to raise_error(AwsPricing::UnknownTypeError)
32
33
  end
33
34
  end
35
+
36
+ describe 'get_breakeven_months' do
37
+ it "test_fetch_all_breakeven_months" do
38
+ pricing = AwsPricing::RdsPriceList.new
39
+ pricing.regions.each do |region|
40
+ region.rds_instance_types.each do |instance|
41
+ [:year1, :year3].each do |term|
42
+ [:light, :medium, :heavy].each do |res_type|
43
+ [:mysql, :postgresql, :oracle_se1, :oracle_se, :oracle_ee, :sqlserver_se, :sqlserver_ee].each do |db|
44
+ if db == :postgresql
45
+ if :heavy
46
+ AwsPricing::DatabaseType.get_available_types(db).each do |deploy_type|
47
+ next if not instance.available?(db, res_type, deploy_type == :multiaz, false)
48
+ instance.get_breakeven_month(db, res_type, term, deploy_type == :multiaz, false).should_not be_nil
49
+ end
50
+ end
51
+ else
52
+ AwsPricing::DatabaseType.get_available_types(db).each do |deploy_type|
53
+ if deploy_type == :byol_multiaz
54
+ next if not instance.available?(db, res_type, true, true)
55
+ instance.get_breakeven_month(db, res_type, term, true, true).should_not be_nil
56
+ else
57
+ next if not instance.available?(db, res_type, deploy_type == :multiaz, deploy_type == :byol)
58
+ instance.get_breakeven_month(db, res_type, term, deploy_type == :multiaz, deploy_type == :byol).should_not be_nil
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
34
69
  end
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.14
4
+ version: 0.1.15
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: 2013-11-15 00:00:00.000000000 Z
12
+ date: 2013-11-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: