class AwsPricing::Ec2DedicatedHostPriceList

Public Class Methods

new() click to toggle source
Calls superclass method AwsPricing::PriceList::new
  # File lib/amazon-pricing/ec2-dh-price-list.rb
5 def initialize
6   super
7   InstanceType.populate_lookups
8   get_ec2_dh_od_pricing
9 end

Public Instance Methods

os_types() click to toggle source
   # File lib/amazon-pricing/ec2-dh-price-list.rb
11 def os_types
12   @@OS_TYPES
13 end

Protected Instance Methods

fetch_ec2_dedicated_host_pricing(url, operating_system) click to toggle source
   # File lib/amazon-pricing/ec2-dh-price-list.rb
25 def fetch_ec2_dedicated_host_pricing(url, operating_system)
26   res = PriceList.fetch_url(url)
27   begin
28     res['config']['regions'].each do |reg|
29       region_name = reg['region']
30       region = get_region(region_name)
31       if region.nil?
32         $stderr.puts "[fetch_ec2_dedicated_host_pricing] WARNING: unable to find region #{region_name}"
33         next
34       end
35       reg['types'].each do |type|
36         type_name = type['name']
37         tiers = type['tiers']
38         next if tiers.nil?
39         tiers.each do |tier|
40             family = tier['name']
41             api_name = family
42             dhprice = tier['prices']['USD']
43             dh_type = region.add_or_update_ec2_dh_type(family)
44             dh_type.update_dh_pricing(operating_system, dhprice)
45         end
46       end
47     end
48   rescue UnknownTypeError
49     $stderr.puts "[fetch_ec2_dedicated_host_pricing] WARNING: encountered #{$!.message}"
50   end
51 end
get_ec2_dh_od_pricing() click to toggle source
   # File lib/amazon-pricing/ec2-dh-price-list.rb
19 def get_ec2_dh_od_pricing
20   @@OS_TYPES.each do |os|
21     fetch_ec2_dedicated_host_pricing(DH_OD_BASE_URL + "dh-od.min.js", os.to_sym)
22   end
23 end