16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/ec2spot.rb', line 16
def prices(*instance_types)
json = spot_price_history(*instance_types).group_by(&:instance_type).map do |instance_type, spot_price_history|
prices = spot_price_history.map(&:spot_price).map(&:to_f)
{
instance: instance_type,
min: prices.min,
max: prices.max,
avg: prices.sum / prices.length,
full: instance_price(instance_type),
savings: (1 - (prices.sum / prices.length) / instance_price(instance_type)),
interrupts: spot_advisor_range(instance_type)
}
end
end
|