Class: AwsPricing::RdsInstanceType
- Inherits:
-
InstanceType
- Object
- InstanceType
- AwsPricing::RdsInstanceType
- Defined in:
- lib/amazon-pricing/definitions/rds-instance-type.rb
Instance Attribute Summary
Attributes inherited from InstanceType
#api_name, #compute_units, #disk_in_gb, #disk_type, #memory_in_mb, #name, #platform, #virtual_cores
Instance Method Summary collapse
-
#available?(database_type = :mysql, type_of_instance = :ondemand, is_multi_az, is_byol) ⇒ Boolean
database_type = :mysql, :oracle, :sqlserver type_of_instance = :ondemand, :light, :medium, :heavy.
-
#initialize(region, api_name, name) ⇒ RdsInstanceType
constructor
A new instance of RdsInstanceType.
- #update_pricing(database_type, type_of_instance, json, is_multi_az, is_byol) ⇒ Object
- #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) ⇒ Object
- #update_pricing_new(database_type, type_of_instance, prices, term = nil, is_multi_az, is_byol) ⇒ Object
Methods inherited from InstanceType
#category_types, disk_bytes_per_sec_capacity, #disk_in_mb, disk_ops_per_sec_capacity, #get_breakeven_month, #get_category_type, get_descriptive_cache_name, get_descriptive_name, #memory_in_gb, populate_lookups, #prepay, #price_per_hour, service_type
Constructor Details
#initialize(region, api_name, name) ⇒ RdsInstanceType
Returns a new instance of RdsInstanceType.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/amazon-pricing/definitions/rds-instance-type.rb', line 6 def initialize(region, api_name, name) @category_types = {} @region = region @name = name @api_name = api_name # Let's look up using the standard name but need to remove leading "db." to do so api_name_for_lookup = api_name.sub("db.", "") @disk_in_gb = InstanceType.get_disk(api_name_for_lookup) @platform = InstanceType.get_platform(api_name_for_lookup) @disk_type = InstanceType.get_disk_type(api_name_for_lookup) @memory_in_mb = InstanceType.get_memory(api_name_for_lookup) @compute_units = InstanceType.get_compute_units(api_name_for_lookup) @virtual_cores = InstanceType.get_virtual_cores(api_name_for_lookup) end |
Instance Method Details
#available?(database_type = :mysql, type_of_instance = :ondemand, is_multi_az, is_byol) ⇒ Boolean
database_type = :mysql, :oracle, :sqlserver type_of_instance = :ondemand, :light, :medium, :heavy
28 29 30 31 32 |
# File 'lib/amazon-pricing/definitions/rds-instance-type.rb', line 28 def available?(database_type = :mysql, type_of_instance = :ondemand, is_multi_az, is_byol) db = get_category_type(database_type, is_multi_az, is_byol) return false if db.nil? db.available?(type_of_instance) end |
#update_pricing(database_type, type_of_instance, json, is_multi_az, is_byol) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/amazon-pricing/definitions/rds-instance-type.rb', line 34 def update_pricing(database_type, type_of_instance, json, is_multi_az, is_byol) db = get_category_type(database_type, is_multi_az, is_byol) if db.nil? db = DatabaseType.new(self, database_type) if is_multi_az == true and is_byol == true @category_types["#{database_type}_byol_multiaz"] = db elsif is_multi_az == true and is_byol == false @category_types["#{database_type}_multiaz"] = db elsif is_multi_az == false and is_byol == true @category_types["#{database_type}_byol"] = db else @category_types[database_type] = db end end if type_of_instance == :ondemand values = RdsInstanceType::get_values(json, database_type) price = coerce_price(values[database_type.to_s]) db.set_price_per_hour(type_of_instance, nil, price) else # Amazon has another data error where they are still exposing reserved instance types when they do not actually exist (e.g. SQL Server t1.micro). # Just warn and continue. if db.ondemand_price_per_hour.nil? $stderr.puts "WARNING: Skipping RDS instance type #{api_name}:#{database_type}:#{type_of_instance}:#{is_multi_az}:#{is_byol} due to lack of on-demand pricing" return end json['valueColumns'].each do |val| # As of 2014-04-02 we see entries w/o pricing, e.g. sqlserver_web heavy 1 year reservation = {"prices"=>{"USD"=>{}}, "name"=>"yrTerm1"} if val['prices']['USD'].empty? #puts "The following instance type does not have pricing: #{@region.name} : #{@api_name} : #{database_type} : #{type_of_instance} : #{val['name']} : #{is_multi_az} : #{is_byol}" next end price = coerce_price(val['prices']['USD']) case val["name"] when "yrTerm1", "yrTerm1Standard" db.set_prepay(type_of_instance, :year1, price) when "yrTerm3", "yrTerm3Standard" db.set_prepay(type_of_instance, :year3, price) when "yrTerm1Hourly" db.set_price_per_hour(type_of_instance, :year1, price) when "yrTerm3Hourly" db.set_price_per_hour(type_of_instance, :year3, price) when "yearTerm1Hourly" db.set_price_per_hour(type_of_instance, :year1, price) when "yearTerm3Hourly" db.set_price_per_hour(type_of_instance, :year3, price) else $stderr.puts "[#{__method__}] WARNING: unknown term:#{val["name"]}" end end end # Copy byol prices from oracle_se to oracle_{ee,se1,se2} if database_type == :oracle_se && is_byol update_pricing :oracle_ee, type_of_instance, json, is_multi_az, is_byol update_pricing :oracle_se1, type_of_instance, json, is_multi_az, is_byol update_pricing :oracle_se2, type_of_instance, json, is_multi_az, is_byol end end |
#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) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/amazon-pricing/definitions/rds-instance-type.rb', line 147 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) db = get_category_type(database_type, is_multi_az, is_byol) if db.nil? db = DatabaseType.new(self, database_type) if is_multi_az == true and is_byol == true @category_types["#{database_type}_byol_multiaz"] = db elsif is_multi_az == true and is_byol == false @category_types["#{database_type}_multiaz"] = db elsif is_multi_az == false and is_byol == true @category_types["#{database_type}_byol"] = db else @category_types[database_type] = db end end db.set_price_per_hour(type_of_instance, nil, coerce_price(ondemand_pph)) unless ondemand_pph.nil? db.set_prepay(type_of_instance, :year1, coerce_price(year1_prepay)) unless year1_prepay.nil? db.set_prepay(type_of_instance, :year3, coerce_price(year3_prepay)) unless year3_prepay.nil? db.set_price_per_hour(type_of_instance, :year1, coerce_price(year1_pph)) unless year1_pph.nil? db.set_price_per_hour(type_of_instance, :year3, coerce_price(year3_pph)) unless year3_pph.nil? end |
#update_pricing_new(database_type, type_of_instance, prices, term = nil, is_multi_az, is_byol) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/amazon-pricing/definitions/rds-instance-type.rb', line 98 def update_pricing_new(database_type, type_of_instance, prices, term = nil, is_multi_az, is_byol) db = get_category_type(database_type, is_multi_az, is_byol) if db.nil? db = DatabaseType.new(self, database_type) if is_multi_az == true and is_byol == true @category_types["#{database_type}_byol_multiaz"] = db elsif is_multi_az == true and is_byol == false @category_types["#{database_type}_multiaz"] = db elsif is_multi_az == false and is_byol == true @category_types["#{database_type}_byol"] = db else @category_types[database_type] = db end end terms_to_years = { "yrTerm1" => :year1, "yrTerm3" => :year3, "yrTerm1Standard" => :year1, "yrTerm3Standard" => :year3 } years = terms_to_years[term] if years.nil? $stderr.puts "[#{__method__}] WARNING: unknown term:#{val["name"]}" end prices.each do |price| p = coerce_price(price['prices']['USD']) case price['name'] when 'upfront' db.set_prepay(type_of_instance, years, p.to_f) unless type_of_instance == :noupfront || p == "N/A" when 'monthlyStar' # note for partialupfront, this purposely differs from AWS' "effective hourly" since we do not # include the amortization of the partialupfront cost into this rate. db.set_price_per_hour(type_of_instance, years, p.to_f * 12 / 365 / 24) unless type_of_instance == :allupfront || p == "N/A" else # Do nothing for other names end end # Copy byol prices from oracle_se to oracle_{ee,se1,se2} if database_type == :oracle_se && is_byol update_pricing_new :oracle_ee, type_of_instance, prices, term, is_multi_az, is_byol update_pricing_new :oracle_se1, type_of_instance, prices, term, is_multi_az, is_byol update_pricing_new :oracle_se2, type_of_instance, prices, term, is_multi_az, is_byol end end |