aws-rikanjo 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +6 -0
- data/.travis.yml +8 -0
- data/Gemfile +0 -6
- data/README.md +18 -15
- data/aws-rikanjo.gemspec +12 -9
- data/bin/rikanjo +3 -75
- data/lib/aws/rikanjo.rb +6 -126
- data/lib/aws/rikanjo/base.rb +40 -0
- data/lib/aws/rikanjo/calc.rb +103 -0
- data/lib/aws/rikanjo/cli.rb +113 -0
- data/lib/aws/rikanjo/ec2.rb +117 -0
- data/lib/aws/rikanjo/rds.rb +120 -0
- data/lib/aws/rikanjo/version.rb +1 -1
- data/spec/lib/rikanjo_ec2_spec.rb +12 -12
- data/spec/lib/rikanjo_rds_spec.rb +22 -12
- metadata +60 -13
- data/lib/aws/rikanjo/mode/ec2.rb +0 -120
- data/lib/aws/rikanjo/mode/rds.rb +0 -117
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8953135308c2709a6b820c95d653585028303427
|
4
|
+
data.tar.gz: 79cbab1f693c606da4383cd12a0b377c5a038d5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890ff68ab047bfc5f827551766c9b88af6ce2f3bb003a8ea440fab619a1fd60ea47bb17d36553177b1109f5461110f2cb479b84d107d50beee373a98208f938e
|
7
|
+
data.tar.gz: 7a762a60a45a02b354c9ef0acb68032e1b529795acfec1187692e34562d9a06147465cb1ad02f79417514a07b9951242be080e15ef247d9e587858e303ab9448
|
data/.hound.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
# Aws::Rikanjo
|
2
|
-
|
1
|
+
# Aws::Rikanjo [![Build Status](https://travis-ci.org/kenjiskywalker/aws-rikanjo.svg?branch=master)](https://travis-ci.org/kenjiskywalker/aws-rikanjo)
|
3
2
|
RI Cost Calc Tool( Only new price ).
|
4
3
|
|
5
4
|
## Installation
|
@@ -23,20 +22,22 @@ example
|
|
23
22
|
```
|
24
23
|
require "aws/rikanjo"
|
25
24
|
|
26
|
-
a = Aws::RiKanjoo.new(
|
25
|
+
a = Aws::RiKanjoo::Base.new('ec2', 'ap-northeast-1', 'm3.xlarge', 'medium')
|
27
26
|
a.total_cost_year
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
27
|
+
{
|
28
|
+
"sweet spot price (doller)": "269.08",
|
29
|
+
"sweet spot date (date)": "2015-02-17",
|
30
|
+
"sweet spot day (day)": "254",
|
31
|
+
"reserved upfront (doller)": "61",
|
32
|
+
"region": "us-east-1",
|
33
|
+
"instance_type": "m1.small",
|
34
|
+
"ri_util": "light",
|
35
|
+
"discont percent (percent)": "6.9",
|
36
|
+
"ondemand hour price (doller)": "0.044",
|
37
|
+
"reserved hour price (doller)": "0.034",
|
38
|
+
"ondemand year price (doller)": "385.44",
|
39
|
+
"reserved year price (doller)": "358.84"
|
40
|
+
}
|
40
41
|
```
|
41
42
|
|
42
43
|
## CLI Usage
|
@@ -51,6 +52,7 @@ Usage: rikanjo ec2/rds [options]
|
|
51
52
|
-r, --region=VALUE specify aws-region (us-east-1/us-west-1/us-west-2/eu-west-1/ap-southeast-1/ap-northeast-1/ap-southeast-2/sa-east-1)
|
52
53
|
-t, --instance_type=VALUE specify ec2-instance-type
|
53
54
|
-u, --ri_util=VALUE specify ri-util (light/medium/heavy)
|
55
|
+
-j, --output_json specify output_json flg
|
54
56
|
-h, --help
|
55
57
|
```
|
56
58
|
|
@@ -71,6 +73,7 @@ Usage: rikanjo ec2/rds [options]
|
|
71
73
|
-r, --region=VALUE specify aws-region (us-east-1/us-west-1/us-west-2/eu-west-1/ap-southeast-1/ap-northeast-1/ap-southeast-2/sa-east-1)
|
72
74
|
-t, --instance_type=VALUE specify ec2-instance-type
|
73
75
|
-u, --ri_util=VALUE specify ri-util (light/medium/heavy)
|
76
|
+
-j, --output_json specify output_json flg
|
74
77
|
-h, --help
|
75
78
|
```
|
76
79
|
|
data/aws-rikanjo.gemspec
CHANGED
@@ -4,22 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'aws/rikanjo/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version =
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
7
|
+
spec.name = 'aws-rikanjo'
|
8
|
+
spec.version = '0.0.9'
|
9
|
+
spec.authors = ['kenjiskywalker']
|
10
|
+
spec.email = ['git@kenjiskywalker.org']
|
11
11
|
spec.description = %q{AWS RI Cost Calc Tool}
|
12
12
|
spec.summary = %q{calc 1 year cost. check sweet spot}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/kenjiskywalker/aws-rikanjo'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 2.0'
|
24
|
+
spec.add_dependency 'rake'
|
25
|
+
spec.add_dependency 'yajl-ruby'
|
23
26
|
|
24
27
|
spec.bindir = 'bin'
|
25
28
|
spec.executables << 'rikanjo'
|
data/bin/rikanjo
CHANGED
@@ -1,78 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
3
|
|
3
|
-
|
4
|
+
require 'aws/rikanjo/cli'
|
4
5
|
|
5
|
-
|
6
|
-
require 'optparse'
|
7
|
-
|
8
|
-
options = { }
|
9
|
-
|
10
|
-
optparse = OptionParser.new do |opts|
|
11
|
-
|
12
|
-
opts.banner = "Usage: rikanjo ec2/rds [options]"
|
13
|
-
|
14
|
-
# subcommand
|
15
|
-
mode = ARGV.shift
|
16
|
-
if mode == 'ec2'
|
17
|
-
elsif mode == 'rds'
|
18
|
-
opts.on("--multiaz", "enable multi-az") do |value|
|
19
|
-
options[:multiaz] = value
|
20
|
-
end
|
21
|
-
else
|
22
|
-
$stderr.puts "no such subcommand: #{mode}"
|
23
|
-
puts opts
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
options[:mode] = mode
|
27
|
-
|
28
|
-
region_values = %w[us-east-1 us-west-1 us-west-2 eu-west-1 ap-southeast-1 ap-northeast-1 ap-southeast-2 sa-east-1 ]
|
29
|
-
opts.on("-r", "--region=VALUE", region_values, "specify aws-region (#{region_values.join('/')})") do |value|
|
30
|
-
options[:region] = value
|
31
|
-
end
|
32
|
-
|
33
|
-
opts.on("-t", "--instance_type=VALUE", "specify ec2-instance-type") do |value|
|
34
|
-
options[:instance_type] = value
|
35
|
-
end
|
36
|
-
|
37
|
-
ri_util_values = %w[light medium heavy]
|
38
|
-
opts.on("-u", "--ri_util=VALUE", ri_util_values, "specify ri-util (#{ri_util_values.join('/')})") do |value|
|
39
|
-
options[:ri_util] = value
|
40
|
-
end
|
41
|
-
|
42
|
-
opts.on("-h", "--help") do
|
43
|
-
puts opts
|
44
|
-
exit
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# validation
|
52
|
-
begin
|
53
|
-
optparse.parse!
|
54
|
-
require_args = [:region, :instance_type, :ri_util]
|
55
|
-
error_args = require_args.select{ |param| options[param].nil? }
|
56
|
-
if not error_args.empty?
|
57
|
-
puts "require arguments: #{error_args.join(', ')}"
|
58
|
-
puts
|
59
|
-
puts optparse
|
60
|
-
exit
|
61
|
-
end
|
62
|
-
rescue
|
63
|
-
puts $!.to_s
|
64
|
-
puts
|
65
|
-
puts optparse
|
66
|
-
exit
|
67
|
-
end
|
68
|
-
|
69
|
-
# rikanjo
|
70
|
-
require "aws/rikanjo"
|
71
|
-
a = Aws::RiKanjoo.new(
|
72
|
-
mode = options[:mode],
|
73
|
-
region = options[:region],
|
74
|
-
instance_type = options[:instance_type],
|
75
|
-
ri_util = options[:ri_util],
|
76
|
-
multiaz = options[:multiaz],
|
77
|
-
)
|
78
|
-
a.total_cost_year
|
6
|
+
Aws::RiKanjoo::CLI.new.start
|
data/lib/aws/rikanjo.rb
CHANGED
@@ -1,133 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require_relative 'rikanjo/mode/ec2'
|
8
|
-
require_relative 'rikanjo/mode/rds'
|
3
|
+
require 'aws/rikanjo/base'
|
4
|
+
require 'aws/rikanjo/ec2'
|
5
|
+
require 'aws/rikanjo/rds'
|
6
|
+
require 'aws/rikanjo/calc'
|
9
7
|
|
10
8
|
module Aws
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def initialize(mode='ec2', region, instance_type, ri_util, multiaz)
|
15
|
-
if mode == 'ec2'
|
16
|
-
@mode_class = Aws::RiKanjoo::Mode::Ec2.new(region, instance_type, ri_util)
|
17
|
-
elsif mode == 'rds'
|
18
|
-
@mode_class = Aws::RiKanjoo::Mode::Rds.new(region, instance_type, ri_util, multiaz)
|
19
|
-
end
|
20
|
-
@region = region
|
21
|
-
@instance_type = instance_type
|
22
|
-
@ri_util = ri_util
|
23
|
-
@om_info = Hash.new
|
24
|
-
@ri_info = Hash.new
|
25
|
-
end
|
26
|
-
|
27
|
-
def om_get_hr_price
|
28
|
-
# TODO: merge om and ri
|
29
|
-
uri = URI.parse("#{@mode_class.price_url}/#{@mode_class.om_price_file}")
|
30
|
-
contents = Net::HTTP.get(uri)
|
31
|
-
|
32
|
-
# parse om info
|
33
|
-
@om_info = @mode_class.om_price_from_contents(contents)
|
34
|
-
end
|
35
|
-
|
36
|
-
def ri_get_hr_price_and_upfront
|
37
|
-
uri = URI.parse("#{@mode_class.price_url}/#{@mode_class.ri_price_file}")
|
38
|
-
contents = Net::HTTP.get(uri)
|
39
|
-
|
40
|
-
# parse ri info
|
41
|
-
@ri_info = @mode_class.ri_price_from_contents(contents)
|
9
|
+
module RiKanjoo
|
10
|
+
class Base
|
42
11
|
end
|
43
|
-
|
44
|
-
def calc_year_cost
|
45
|
-
|
46
|
-
om_hr_price = @om_info[:hr_price].to_f
|
47
|
-
ri_hr_price = @ri_info[@ri_util][:hr_price].to_f
|
48
|
-
upfront = @ri_info[@ri_util][:upfront].to_f
|
49
|
-
|
50
|
-
om_day_paid = (om_hr_price * 24).to_f
|
51
|
-
ri_day_paid = (ri_hr_price * 24).to_f
|
52
|
-
|
53
|
-
sum_om_price = om_day_paid
|
54
|
-
sum_ri_price = ri_day_paid + upfront
|
55
|
-
365.times.each do |d|
|
56
|
-
d = d + 1
|
57
|
-
sum_om_price = sum_om_price + om_day_paid
|
58
|
-
sum_ri_price = sum_ri_price + ri_day_paid
|
59
|
-
|
60
|
-
if sum_ri_price < sum_om_price
|
61
|
-
@ri_info[@ri_util].store(:sweet_spot_price, sum_ri_price.round(2))
|
62
|
-
@ri_info[@ri_util].store(:sweet_spot_start_day, d)
|
63
|
-
break
|
64
|
-
end
|
65
|
-
end
|
66
|
-
total_om_price = (om_day_paid * 365).round(2)
|
67
|
-
@om_info.store(:yr_price, total_om_price)
|
68
|
-
total_ri_price = ((ri_day_paid * 365) + upfront).round(2)
|
69
|
-
@ri_info[@ri_util].store(:yr_price, total_ri_price)
|
70
|
-
|
71
|
-
# exp. @om_info = {:hr_price=>"0.350", :yr_price=>3066.0}
|
72
|
-
# exp. @ri_info = {"ri_util"=>{:upfront=>"NNN", :hr_price=>"NNN",
|
73
|
-
# :sweet_spot_price=>NNN, :sweet_spot_start_day=>78, :yr_price=>2074.56}}
|
74
|
-
return @om_info, @ri_info
|
75
|
-
end
|
76
|
-
|
77
|
-
def total_cost_year
|
78
|
-
om_get_hr_price
|
79
|
-
ri_get_hr_price_and_upfront
|
80
|
-
calc_year_cost
|
81
|
-
|
82
|
-
discount_per = (100 - ((@ri_info[@ri_util][:yr_price] / @om_info[:yr_price]) * 100)).round(2)
|
83
|
-
|
84
|
-
# If the Reserved Instance does not become cheaper than the On-demand Instance.
|
85
|
-
if @ri_info[@ri_util][:sweet_spot_start_day].nil?
|
86
|
-
puts "\"Price of the Reserved Instance is higher than the price of On-Demand Instances.\""
|
87
|
-
puts "\"region\" : #{@region}"
|
88
|
-
puts "\"instance_type\" : #{@instance_type}"
|
89
|
-
puts "\"ri_util\" : #{@ri_util}"
|
90
|
-
puts "\"discont percent (percent)\" : #{discount_per}"
|
91
|
-
puts "\"ondemand hour price (doller)\" : #{@om_info[:hr_price]}"
|
92
|
-
puts "\"reserved hour price (doller)\" : #{@ri_info[@ri_util][:hr_price]}"
|
93
|
-
puts "\"ondemand year price (doller)\" : #{@om_info[:yr_price]}"
|
94
|
-
puts "\"reserved year price (doller)\" : #{@ri_info[@ri_util][:yr_price]}"
|
95
|
-
puts "\"reserved upfront (doller)\" : #{@ri_info[@ri_util][:upfront]}"
|
96
|
-
|
97
|
-
exit 1
|
98
|
-
end
|
99
|
-
|
100
|
-
sweet_spot_date = Date.today + @ri_info[@ri_util][:sweet_spot_start_day]
|
101
|
-
|
102
|
-
puts "\"region\" : #{@region}"
|
103
|
-
puts "\"instance_type\" : #{@instance_type}"
|
104
|
-
puts "\"ri_util\" : #{@ri_util}"
|
105
|
-
puts "\"discont percent (percent)\" : #{discount_per}"
|
106
|
-
puts "\"ondemand hour price (doller)\" : #{@om_info[:hr_price]}"
|
107
|
-
puts "\"reserved hour price (doller)\" : #{@ri_info[@ri_util][:hr_price]}"
|
108
|
-
puts "\"ondemand year price (doller)\" : #{@om_info[:yr_price]}"
|
109
|
-
puts "\"reserved year price (doller)\" : #{@ri_info[@ri_util][:yr_price]}"
|
110
|
-
puts "\"reserved upfront (doller)\" : #{@ri_info[@ri_util][:upfront]}"
|
111
|
-
puts "\"sweet spot day (day)\" : #{@ri_info[@ri_util][:sweet_spot_start_day]}"
|
112
|
-
puts "\"sweet spot date (date)\" : #{sweet_spot_date}"
|
113
|
-
puts "\"sweet spot price (doller)\" : #{@ri_info[@ri_util][:sweet_spot_price]}"
|
114
|
-
end
|
115
|
-
|
116
12
|
end
|
117
13
|
end
|
118
|
-
|
119
|
-
# m = Aws::RiKanjoo.new(region = "ap-northeast-1", instance_type = "m3.large", ri_util = "medium")
|
120
|
-
# m.total_cost_year
|
121
|
-
#
|
122
|
-
# "region" : ap-northeast-1
|
123
|
-
# "instance_type" : m3.large
|
124
|
-
# "ri_util" : medium
|
125
|
-
# "discont percent (percent)" : 35.09
|
126
|
-
# "ondemand hour price (doller)" : 0.203
|
127
|
-
# "reserved hour price (doller)" : 0.086
|
128
|
-
# "ondemand year price (doller)" : 1778.28
|
129
|
-
# "reserved year price (doller)" : 1154.36
|
130
|
-
# "reserved upfront (doller)" : 401
|
131
|
-
# "sweet spot day (day)" : 142
|
132
|
-
# "sweet spot date (date)" : 2014-09-19
|
133
|
-
# "sweet spot price (doller)" : 696.15
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'aws/rikanjo/ec2'
|
2
|
+
require 'aws/rikanjo/rds'
|
3
|
+
require 'aws/rikanjo/calc'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module RiKanjoo
|
7
|
+
class Base < Calc
|
8
|
+
attr_reader :region, :instance_type, :ri_util, :multiaz
|
9
|
+
|
10
|
+
def initialize(mode = 'ec2', region, instance_type, ri_util, multiaz)
|
11
|
+
if mode == 'ec2'
|
12
|
+
@mode = Aws::RiKanjoo::Ec2.new(region, instance_type, ri_util)
|
13
|
+
elsif mode == 'rds'
|
14
|
+
@mode = Aws::RiKanjoo::Rds.new(region, instance_type, ri_util, multiaz)
|
15
|
+
end
|
16
|
+
@region = region
|
17
|
+
@instance_type = instance_type
|
18
|
+
@ri_util = ri_util
|
19
|
+
@om_info = {}
|
20
|
+
@ri_info = {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# m = Aws::RiKanjoo.new(region = "ap-northeast-1", instance_type = "m3.large", ri_util = "medium")
|
27
|
+
# m.total_cost_year
|
28
|
+
#
|
29
|
+
# "region" : ap-northeast-1
|
30
|
+
# "instance_type" : m3.large
|
31
|
+
# "ri_util" : medium
|
32
|
+
# "discont percent (percent)" : 35.09
|
33
|
+
# "ondemand hour price (doller)" : 0.203
|
34
|
+
# "reserved hour price (doller)" : 0.086
|
35
|
+
# "ondemand year price (doller)" : 1778.28
|
36
|
+
# "reserved year price (doller)" : 1154.36
|
37
|
+
# "reserved upfront (doller)" : 401
|
38
|
+
# "sweet spot day (day)" : 142
|
39
|
+
# "sweet spot date (date)" : 2014-09-19
|
40
|
+
# "sweet spot price (doller)" : 696.15
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'yajl'
|
4
|
+
require 'date'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Aws
|
8
|
+
module RiKanjoo
|
9
|
+
class Calc
|
10
|
+
def om_get_hr_price
|
11
|
+
# TODO: merge om and ri
|
12
|
+
uri = URI.parse("#{@mode.price_url}/#{@mode.om_price_file}")
|
13
|
+
contents = Net::HTTP.get(uri)
|
14
|
+
|
15
|
+
# parse om info
|
16
|
+
@om_info = @mode.om_price_from_contents(contents)
|
17
|
+
end
|
18
|
+
|
19
|
+
def ri_get_hr_price_and_upfront
|
20
|
+
uri = URI.parse("#{@mode.price_url}/#{@mode.ri_price_file}")
|
21
|
+
contents = Net::HTTP.get(uri)
|
22
|
+
|
23
|
+
# parse ri info
|
24
|
+
@ri_info = @mode.ri_price_from_contents(contents)
|
25
|
+
end
|
26
|
+
|
27
|
+
def calc_year_cost
|
28
|
+
om_hr_price = @om_info[:hr_price].to_f
|
29
|
+
ri_hr_price = @ri_info[@ri_util][:hr_price].to_f
|
30
|
+
upfront = @ri_info[@ri_util][:upfront].to_f
|
31
|
+
|
32
|
+
om_day_paid = (om_hr_price * 24).to_f
|
33
|
+
ri_day_paid = (ri_hr_price * 24).to_f
|
34
|
+
|
35
|
+
sum_om_price = om_day_paid
|
36
|
+
sum_ri_price = ri_day_paid + upfront
|
37
|
+
365.times.each do |d|
|
38
|
+
d += 1
|
39
|
+
sum_om_price += om_day_paid
|
40
|
+
sum_ri_price += ri_day_paid
|
41
|
+
|
42
|
+
if sum_ri_price < sum_om_price
|
43
|
+
@ri_info[@ri_util].store(:sweet_spot_price, sum_ri_price.round(2))
|
44
|
+
@ri_info[@ri_util].store(:sweet_spot_start_day, d)
|
45
|
+
break
|
46
|
+
end
|
47
|
+
end
|
48
|
+
total_om_price = (om_day_paid * 365).round(2)
|
49
|
+
@om_info.store(:yr_price, total_om_price)
|
50
|
+
total_ri_price = ((ri_day_paid * 365) + upfront).round(2)
|
51
|
+
@ri_info[@ri_util].store(:yr_price, total_ri_price)
|
52
|
+
|
53
|
+
# exp. @om_info = {:hr_price=>"0.350", :yr_price=>3066.0}
|
54
|
+
# exp. @ri_info = {"ri_util"=>{:upfront=>"NNN", :hr_price=>"NNN",
|
55
|
+
# :sweet_spot_price=>NNN, :sweet_spot_start_day=>78, :yr_price=>2074.56}}
|
56
|
+
return @om_info, @ri_info
|
57
|
+
end
|
58
|
+
|
59
|
+
def total_cost_year
|
60
|
+
om_get_hr_price
|
61
|
+
ri_get_hr_price_and_upfront
|
62
|
+
calc_year_cost
|
63
|
+
|
64
|
+
discount_per = (100 - ((@ri_info[@ri_util][:yr_price] / @om_info[:yr_price]) * 100)).round(2)
|
65
|
+
|
66
|
+
# If the Reserved Instance does not become cheaper than the On-demand Instance.
|
67
|
+
if @ri_info[@ri_util][:sweet_spot_start_day].nil?
|
68
|
+
message = {
|
69
|
+
"Price of the Reserved Instance is higher than the price of On-Demand Instances." => nil,
|
70
|
+
"region" => "#{@region}",
|
71
|
+
"instance_type" => "#{@instance_type}",
|
72
|
+
"ri_util" => "#{@ri_util}",
|
73
|
+
"discont percent (percent)" => "#{discount_per}",
|
74
|
+
"ondemand hour price (doller)" => "#{@om_info[:hr_price]}",
|
75
|
+
"reserved hour price (doller)" => "#{@ri_info[@ri_util][:hr_price]}",
|
76
|
+
"ondemand year price (doller)" => "#{@om_info[:yr_price]}",
|
77
|
+
"reserved year price (doller)" => "#{@ri_info[@ri_util][:yr_price]}",
|
78
|
+
"reserved upfront (doller)" => "#{@ri_info[@ri_util][:upfront]}",
|
79
|
+
}
|
80
|
+
puts message.to_json
|
81
|
+
exit 1
|
82
|
+
end
|
83
|
+
|
84
|
+
sweet_spot_date = Date.today + @ri_info[@ri_util][:sweet_spot_start_day]
|
85
|
+
message = {
|
86
|
+
"region" => "#{@region}",
|
87
|
+
"instance_type" => "#{@instance_type}",
|
88
|
+
"ri_util" => "#{@ri_util}",
|
89
|
+
"discont percent (percent)" => "#{discount_per}",
|
90
|
+
"ondemand hour price (doller)" => "#{@om_info[:hr_price]}",
|
91
|
+
"reserved hour price (doller)" => "#{@ri_info[@ri_util][:hr_price]}",
|
92
|
+
"ondemand year price (doller)" => "#{@om_info[:yr_price]}",
|
93
|
+
"reserved year price (doller)" => "#{@ri_info[@ri_util][:yr_price]}",
|
94
|
+
"reserved upfront (doller)" => "#{@ri_info[@ri_util][:upfront]}",
|
95
|
+
"sweet spot day (day)" => "#{@ri_info[@ri_util][:sweet_spot_start_day]}",
|
96
|
+
"sweet spot date (date)" => "#{sweet_spot_date}",
|
97
|
+
"sweet spot price (doller)" => "#{@ri_info[@ri_util][:sweet_spot_price]}",
|
98
|
+
}
|
99
|
+
return message
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|