class AwsPricing::ElastiCacheNodeType
Public Class Methods
new(region, api_name, name)
click to toggle source
# File lib/amazon-pricing/definitions/elasticache_node_type.rb 6 def initialize(region, api_name, name) 7 @category_types = {} 8 9 @region = region 10 @name = name 11 @api_name = api_name 12 13 api_name_for_lookup = api_name.sub("cache.", "") 14 15 @memory_in_mb = InstanceType.get_memory(api_name) 16 @virtual_cores = InstanceType.get_virtual_cores(api_name_for_lookup) 17 end
Protected Class Methods
get_name(instance_type, api_name, is_reserved = false)
click to toggle source
# File lib/amazon-pricing/definitions/elasticache_node_type.rb 63 def self.get_name(instance_type, api_name, is_reserved = false) 64 api_name.sub!(" *", "") 65 66 unless @@Name_Lookup.has_key? api_name 67 raise UnknownTypeError, "Unknown instance type #{instance_type} #{api_name}", caller 68 end 69 70 name = @@Name_Lookup.has_key? api_name 71 72 [api_name, name] 73 end
Public Instance Methods
available?(cache_type = :memcached, type_of_instance = :ondemand)
click to toggle source
# File lib/amazon-pricing/definitions/elasticache_node_type.rb 19 def available?(cache_type = :memcached, type_of_instance = :ondemand) 20 cache = get_category_type(cache_type) 21 return false if cache.nil? 22 cache.available?(type_of_instance) 23 end
update_pricing(cache_type, type_of_instance, json)
click to toggle source
# File lib/amazon-pricing/definitions/elasticache_node_type.rb 25 def update_pricing(cache_type, type_of_instance, json) 26 cache = get_category_type(cache_type) 27 if cache.nil? 28 cache = Cache.new(self, cache_type) 29 @category_types[cache_type] = cache 30 end 31 32 if type_of_instance == :ondemand 33 values = ElastiCacheNodeType::get_values(json, cache_type) 34 price = coerce_price(values[cache_type.to_s]) 35 cache.set_price_per_hour(type_of_instance, nil, price) 36 else 37 json['valueColumns'].each do |val| 38 39 if val['prices']['USD'].empty? 40 next 41 end 42 43 price = coerce_price(val['prices']['USD']) 44 45 case val['name'] 46 when "yrTerm1", "yrTerm1Standard" 47 cache.set_prepay(type_of_instance, :year1, price) 48 when "yrTerm3", "yrTerm3Standard" 49 cache.set_prepay(type_of_instance, :year3, price) 50 when "yearTerm1Hourly" 51 cache.set_price_per_hour(type_of_instance, :year1, price) 52 when "yearTerm3Hourly" 53 cache.set_price_per_hour(type_of_instance, :year3, price) 54 else 55 $stderr.puts "[#{__method__}] WARNING: unknown term:#{val["name"]}" 56 end 57 end 58 end 59 end