aws-rikanjo 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4c067004f10a46d44863269eb50b313ca8a9704
4
- data.tar.gz: c8e0260f8f12941aa39a736d3a6664ff6a5e3c0e
3
+ metadata.gz: d20547de4100a48c07cedd2e62556660f13d457d
4
+ data.tar.gz: e4befc2b64921bc3f89ae0f78e48088bd0fc7508
5
5
  SHA512:
6
- metadata.gz: e7d4125e4f7f0ec49087e7fbca65803058689d28c352bfcf8e3ccf5fdf274185ebb799d17a60cd09a659c70470c38a6853177d0d1108109580ec42be9318dcc1
7
- data.tar.gz: 950c8dbdd2fb0b382107c5fcff7c7d0f47350f59d2841a0bf6c22842ec02ad88f4434ca2b4c503964b40184337707c1978c9f4b7b9a5b143c0c520079eb7b02c
6
+ metadata.gz: 6857d213ebbd5e210ec747de6bb3b1e1bb956a0e415c18bd755a88351dd4775000920c02bb32a1c0cdd6fb8b8165ac30d3bbe5fdea34e3e0d16245f2f4529e40
7
+ data.tar.gz: d5a23f1b7359e50994b79629e5563bccd1b7afcb4cf22cb19c82c66e9a423019219ea4a26e78387bd2198f85deff4bde8922103f369118a95e83c54fa6a80905
data/README.md CHANGED
@@ -41,11 +41,33 @@ a.total_cost_year
41
41
 
42
42
  ## CLI Usage
43
43
 
44
+ ### EC2
45
+
46
+ help text:
47
+
48
+ ```
49
+ $ rikanjo ec2 --help
50
+ Usage: rikanjo ec2/rds [options]
51
+ -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
+ -t, --instance_type=VALUE specify ec2-instance-type
53
+ -u, --ri_util=VALUE specify ri-util (light/medium/heavy)
54
+ -h, --help
55
+ ```
56
+
57
+ example:
58
+
59
+ ```
60
+ $ rikanjo ec2 -r ap-northeast-1 -t c3.large -u medium
61
+ ```
62
+
63
+ ### RDS
64
+
44
65
  help text:
45
66
 
46
67
  ```
47
- $ rikanjo --help
48
- Usage: rikanjo [options]
68
+ $ rikanjo rds --help
69
+ Usage: rikanjo ec2/rds [options]
70
+ --multiaz enable multi-az
49
71
  -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)
50
72
  -t, --instance_type=VALUE specify ec2-instance-type
51
73
  -u, --ri_util=VALUE specify ri-util (light/medium/heavy)
@@ -55,9 +77,11 @@ Usage: rikanjo [options]
55
77
  example:
56
78
 
57
79
  ```
58
- $ rikanjo -r ap-northeast-1 -t c3.large -u medium
80
+ $ rikanjo rds -r ap-northeast-1 -t m2.xlarge -u heavy --multiaz
59
81
  ```
60
82
 
83
+
84
+
61
85
  ## Contributing
62
86
 
63
87
  1. Fork it
data/aws-rikanjo.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'aws/rikanjo/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "aws-rikanjo"
8
- spec.version = "0.0.6"
8
+ spec.version = "0.0.7"
9
9
  spec.authors = ["kenjiskywalker"]
10
10
  spec.email = ["git@kenjiskywalker.org"]
11
11
  spec.description = %q{AWS RI Cost Calc Tool}
data/bin/rikanjo CHANGED
@@ -9,7 +9,21 @@ options = { }
9
9
 
10
10
  optparse = OptionParser.new do |opts|
11
11
 
12
- opts.banner = "Usage: rikanjo [options]"
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
13
27
 
14
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 ]
15
29
  opts.on("-r", "--region=VALUE", region_values, "specify aws-region (#{region_values.join('/')})") do |value|
@@ -32,6 +46,8 @@ optparse = OptionParser.new do |opts|
32
46
 
33
47
  end
34
48
 
49
+
50
+
35
51
  # validation
36
52
  begin
37
53
  optparse.parse!
@@ -53,8 +69,10 @@ end
53
69
  # rikanjo
54
70
  require "aws/rikanjo"
55
71
  a = Aws::RiKanjoo.new(
72
+ mode = options[:mode],
56
73
  region = options[:region],
57
74
  instance_type = options[:instance_type],
58
75
  ri_util = options[:ri_util],
76
+ multiaz = options[:multiaz],
59
77
  )
60
78
  a.total_cost_year
@@ -0,0 +1,109 @@
1
+ require 'yajl'
2
+
3
+ module Aws
4
+ class RiKanjoo
5
+ class Mode
6
+ class Ec2
7
+ attr_reader :region, :instance_type, :ri_util
8
+
9
+ def initialize(region, instance_type, ri_util)
10
+ @region = region
11
+ @instance_type = instance_type
12
+ @ri_util = ri_util
13
+ @os = 'linux'
14
+ @current_price_url = 'http://a0.awsstatic.com/pricing/1/ec2'
15
+ @previous_price_url = 'http://a0.awsstatic.com/pricing/1/ec2/previous-generation'
16
+ end
17
+
18
+ def om_price_from_contents contents
19
+ region = self.convert_region(@region)
20
+
21
+ # parse
22
+ json = self.parse_contents(contents)
23
+
24
+ # select 'region' and 'instance_type'
25
+ json["config"]["regions"].each do |r|
26
+ # r = {"region"=>"us-east", "instanceTypes"=>[{"type"=>"generalCurrentGen", ...
27
+ next unless r["region"] == region
28
+ r["instanceTypes"].each do |type|
29
+ # type = {"type"=>"generalCurrentGen", "sizes"=>[{"size"=>"m3.medium", "vCPU"=>"1" ...
30
+ type["sizes"].each do |i|
31
+ next unless i["size"] == @instance_type
32
+
33
+ return {:hr_price => i["valueColumns"][0]["prices"]["USD"]}
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def ri_price_from_contents contents
40
+ region = @region
41
+
42
+ # parse
43
+ json = self.parse_contents(contents)
44
+
45
+ ri_info = {}
46
+
47
+ json["config"]["regions"].each do |r|
48
+ next unless r["region"] == region
49
+ r["instanceTypes"].each do |type|
50
+ type["sizes"].each do |i|
51
+ next unless i["size"] == @instance_type
52
+
53
+ i["valueColumns"].each do |y|
54
+ case y["name"]
55
+ when "yrTerm1"
56
+ ri_info[@ri_util] = {:upfront => y["prices"]["USD"]}
57
+ when "yrTerm1Hourly"
58
+ ri_info[@ri_util].store(:hr_price, y["prices"]["USD"])
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ return ri_info
66
+ end
67
+
68
+ def price_url
69
+ return (self.previous_generation_type) ? @previous_price_url : @current_price_url
70
+ end
71
+
72
+ def om_price_file
73
+ return "#{@os}-od.min.js"
74
+ end
75
+
76
+ def ri_price_file
77
+ return (self.previous_generation_type) ? "#{@ri_util}_#{@os}.min.js" : "#{@os}-ri-#{@ri_util}.min.js"
78
+ end
79
+
80
+ def previous_generation_type
81
+ case @instance_type
82
+ when /^(c1|m2|cc2\.8xlarge|cr1\.8xlarge|hi1\.4xlarge|cg1\.4xlarge)/ then true
83
+ when /^m1/ then (@instance_type == "m1.small") ? false : true
84
+ else false
85
+ end
86
+ end
87
+
88
+ def parse_contents data
89
+ data = data.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
90
+ return Yajl::Parser.parse(data)
91
+ end
92
+
93
+ def convert_region region
94
+ # not same om region
95
+ case region
96
+ when "us-east-1" then "us-east"
97
+ when "us-west-1" then "us-west"
98
+ when "eu-west-1" then "eu-ireland"
99
+ when "ap-southeast-1" then "apac-sin"
100
+ when "ap-northeast-1" then "apac-tokyo"
101
+ when "ap-southeast-2" then "apac-syd"
102
+ when "sa-east-1" then "sa-east-1"
103
+ end
104
+ end
105
+
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,110 @@
1
+ module Aws
2
+ class RiKanjoo
3
+ class Mode
4
+ class Rds
5
+ attr_reader :region, :instance_type, :ri_util
6
+
7
+ def initialize(region, instance_type, ri_util, multiaz)
8
+ @region = region
9
+ @instance_type = "db.#{instance_type}"
10
+ @ri_util = ri_util
11
+ @rdbms = 'mysql'
12
+ @price_url = "https://a0.awsstatic.com/pricing/1/rds/#{@rdbms}"
13
+ @multiaz = multiaz
14
+ end
15
+
16
+ def om_price_from_contents contents
17
+ region = self.convert_region(@region)
18
+
19
+ # parse
20
+ json = self.parse_contents(contents)
21
+
22
+ # select 'region' and 'instance_type'
23
+ json["config"]["regions"].each do |r|
24
+ # r = {"region"=>"us-east", "instanceTypes"=>[{"type"=>"generalCurrentGen", ...
25
+ next unless r["region"] == region
26
+ r["types"].each do |type|
27
+ # type = {"type"=>"generalCurrentGen", "sizes"=>[{"size"=>"m3.medium", "vCPU"=>"1" ...
28
+ type["tiers"].each do |i|
29
+ next unless i["name"] == @instance_type
30
+
31
+ return {:hr_price => i["prices"]["USD"]}
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ def ri_price_from_contents contents
38
+ region = self.convert_region(@region)
39
+ mtype = (@multiaz) ? 'multiAZdeployRes' : 'stdDeployRes'
40
+
41
+ # parse
42
+ json = self.parse_contents(contents)
43
+
44
+ ri_info = {}
45
+
46
+ json["config"]["regions"].each do |r|
47
+ next unless r["region"] == region
48
+
49
+ r["instanceTypes"].each do |type|
50
+ # beauty
51
+ type["type"].gsub!(/Single-AZ Deployment \(Reserved\)/, 'stdDeployRes')
52
+
53
+ next unless type["type"] == mtype
54
+
55
+ type["tiers"].each do |i|
56
+ next unless i["size"] == @instance_type
57
+
58
+ i["valueColumns"].each do |y|
59
+ # beauty
60
+ y["name"].gsub!(/^year/, 'yr')
61
+ y["prices"]["USD"].gsub!(/,/, '')
62
+
63
+ case y["name"]
64
+ when "yrTerm1"
65
+ ri_info[@ri_util] = {:upfront => y["prices"]["USD"]}
66
+ when "yrTerm1Hourly"
67
+ ri_info[@ri_util].store(:hr_price, y["prices"]["USD"])
68
+ end
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+
75
+ return ri_info
76
+ end
77
+
78
+ def price_url
79
+ @price_url
80
+ end
81
+
82
+ def om_price_file
83
+ return (@multiaz) ? "pricing-multiAZ-deployments.min.js" : "pricing-standard-deployments.min.js"
84
+ end
85
+
86
+ def ri_price_file
87
+ return "pricing-#{@ri_util}-utilization-reserved-instances.min.js"
88
+ end
89
+
90
+ def parse_contents data
91
+ data = data.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
92
+ return Yajl::Parser.parse(data)
93
+ end
94
+
95
+ def convert_region region
96
+ # not same om region
97
+ case region
98
+ when "us-east-1" then "us-east"
99
+ when "us-west-1" then "us-west"
100
+ when "eu-west-1" then "eu-ireland"
101
+ when "ap-southeast-1" then "apac-sin"
102
+ when "ap-northeast-1" then "apac-tokyo"
103
+ when "ap-southeast-2" then "apac-syd"
104
+ when "sa-east-1" then "sa-east-1"
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module Rikanjo
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
data/lib/aws/rikanjo.rb CHANGED
@@ -4,132 +4,41 @@ require 'net/http'
4
4
  require 'uri'
5
5
  require 'yajl'
6
6
  require 'date'
7
+ require_relative 'rikanjo/mode/ec2'
8
+ require_relative 'rikanjo/mode/rds'
7
9
 
8
10
  module Aws
9
11
  class RiKanjoo
10
12
  attr_reader :region, :instance_type, :ri_util
11
13
 
12
- def initialize(region, instance_type, ri_util)
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
13
20
  @region = region
14
21
  @instance_type = instance_type
15
22
  @ri_util = ri_util
16
23
  @om_info = Hash.new
17
24
  @ri_info = Hash.new
18
- @current_price_url = 'http://a0.awsstatic.com/pricing/1/ec2'
19
- @previous_price_url = 'http://a0.awsstatic.com/pricing/1/ec2/previous-generation'
20
25
  end
21
26
 
22
27
  def om_get_hr_price
23
- region = @region
24
- instance_type = @instance_type
25
- json = nil
26
-
27
- # not same ri region
28
- case region
29
- when "us-east-1"
30
- region = "us-east"
31
- when "us-west-1"
32
- region = "us-west"
33
- when "eu-west-1"
34
- region = "eu-ireland"
35
- when "ap-southeast-1"
36
- region = "apac-sin"
37
- when "ap-northeast-1"
38
- region = "apac-tokyo"
39
- when "ap-southeast-2"
40
- region = "apac-syd"
41
- when "sa-east-1"
42
- region = "sa-east-1"
43
- end
44
-
45
28
  # TODO: merge om and ri
46
- uri = URI.parse("#{price_url}/linux-od.min.js")
47
- Net::HTTP.start(uri.host, uri.port) do |http|
48
- response = http.get(uri.request_uri)
49
- json = response.body
50
- end
51
-
52
- # parse
53
- json = json.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({vers:0.01,",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
54
- ondemand_json_data = Yajl::Parser.parse(json)
55
-
56
- # select 'region' and 'instance_type'
57
- ondemand_json_data["config"]["regions"].each do |r|
58
- # r = {"region"=>"us-east", "instanceTypes"=>[{"type"=>"generalCurrentGen", ...
59
- next unless r["region"] == region
60
- r["instanceTypes"].each do |type|
61
- # type = {"type"=>"generalCurrentGen", "sizes"=>[{"size"=>"m3.medium", "vCPU"=>"1" ...
62
- type["sizes"].each do |i|
63
- next unless i["size"] == instance_type
64
- @om_info = {:hr_price => i["valueColumns"][0]["prices"]["USD"]}
65
- end
66
- end
67
- end
29
+ uri = URI.parse("#{@mode_class.price_url}/#{@mode_class.om_price_file}")
30
+ contents = Net::HTTP.get(uri)
68
31
 
69
- # :hr_price => price
70
- return @om_info
32
+ # parse om info
33
+ @om_info = @mode_class.om_price_from_contents(contents)
71
34
  end
72
35
 
73
36
  def ri_get_hr_price_and_upfront
74
- region = @region
75
-
76
- # not same om region
77
- case region
78
- when "us-east-1"
79
- region = "us-east"
80
- when "us-west"
81
- region = "us-west-1"
82
- when "eu-ireland"
83
- region = "eu-west-1"
84
- when "apac-sin"
85
- region = "ap-southeast-1"
86
- when "apac-tokyo"
87
- region = "ap-northeast-1"
88
- when "apac-syd"
89
- region = "ap-southeast-2"
90
- when "sa-east-1"
91
- region = "sa-east-1"
92
- end
37
+ uri = URI.parse("#{@mode_class.price_url}/#{@mode_class.ri_price_file}")
38
+ contents = Net::HTTP.get(uri)
93
39
 
94
- get_ri_price(region)
95
- end
96
-
97
- def get_ri_price(region)
98
- ri_util = @ri_util
99
-
100
- region = region
101
- instance_type = @instance_type
102
- json = nil
103
- reservedjson_data = nil
104
-
105
- uri = URI.parse("#{price_url}/#{ri_price_file}")
106
- Net::HTTP.start(uri.host, uri.port) do |http|
107
- response = http.get(uri.request_uri)
108
- json = response.body
109
- end
110
-
111
- json = json.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
112
- reservedjson_data = Yajl::Parser.parse(json)
113
-
114
- reservedjson_data["config"]["regions"].each do |r|
115
- next unless r["region"] == region
116
- r["instanceTypes"].each do |type|
117
- type["sizes"].each do |i|
118
- next unless i["size"] == instance_type
119
-
120
- i["valueColumns"].each do |y|
121
- case y["name"]
122
- when "yrTerm1"
123
- @ri_info[ri_util] = {:upfront => y["prices"]["USD"]}
124
- when "yrTerm1Hourly"
125
- @ri_info[ri_util].store(:hr_price, y["prices"]["USD"])
126
- end
127
- end
128
- end
129
- end
130
- end
131
- # exp. {"light"=>{:upfront=>"270", :hr_price=>"0.206"}}
132
- return @ri_info
40
+ # parse ri info
41
+ @ri_info = @mode_class.ri_price_from_contents(contents)
133
42
  end
134
43
 
135
44
  def calc_year_cost
@@ -204,22 +113,6 @@ module Aws
204
113
  puts "\"sweet spot price (doller)\" : #{@ri_info[@ri_util][:sweet_spot_price]}"
205
114
  end
206
115
 
207
- def price_url
208
- return (previous_generation_type) ? @previous_price_url : @current_price_url
209
- end
210
-
211
- def ri_price_file
212
- return (previous_generation_type) ? "#{@ri_util}_linux.min.js" : "linux-ri-#{@ri_util}.min.js"
213
- end
214
-
215
- def previous_generation_type
216
- case @instance_type
217
- when /^(c1|m2|cc2\.8xlarge|cr1\.8xlarge|hi1\.4xlarge|cg1\.4xlarge)/ then true
218
- when /^m1/ then (@instance_type == "m1.small") ? false : true
219
- else false
220
- end
221
- end
222
-
223
116
  end
224
117
  end
225
118
 
@@ -0,0 +1,64 @@
1
+ require "spec_helper"
2
+ require "aws/rikanjo/mode/ec2"
3
+
4
+ describe 'AWS::Rikanjo::Mode::Ec2' do
5
+
6
+ it "is previous instance type" do
7
+ %w{ m1.medium c1.medium m2.xlarge cc2.8xlarge cr1.8xlarge hi1.4xlarge cg1.4xlarge }.each do |t|
8
+ a = Aws::RiKanjoo::Mode::Ec2.new(
9
+ region = 'ap-northeast-1',
10
+ instance_type = t,
11
+ ri_util = 'light',
12
+ )
13
+ expect(a.previous_generation_type).to eq true
14
+ end
15
+ end
16
+
17
+ it "is current instance type" do
18
+ %w{ t1.micro m1.small m3.medium c3.medium r3.xlarge i2.xlarge }.each do |t|
19
+ a = Aws::RiKanjoo::Mode::Ec2.new(
20
+ region = 'ap-northeast-1',
21
+ instance_type = t,
22
+ ri_util = 'light',
23
+ )
24
+ expect(a.previous_generation_type).to eq false
25
+ end
26
+ end
27
+
28
+ it "build previous price url" do
29
+ a = Aws::RiKanjoo::Mode::Ec2.new(
30
+ region = 'ap-northeast-1',
31
+ instance_type = 'm1.medium',
32
+ ri_util = 'light',
33
+ )
34
+ expect(a.price_url).to eq "http://a0.awsstatic.com/pricing/1/ec2/previous-generation"
35
+ end
36
+
37
+ it "build current price url" do
38
+ a = Aws::RiKanjoo::Mode::Ec2.new(
39
+ region = 'ap-northeast-1',
40
+ instance_type = 'm3.medium',
41
+ ri_util = 'light',
42
+ )
43
+ expect(a.price_url).to eq "http://a0.awsstatic.com/pricing/1/ec2"
44
+ end
45
+
46
+ it "build previous ri price file" do
47
+ a = Aws::RiKanjoo::Mode::Ec2.new(
48
+ region = 'ap-northeast-1',
49
+ instance_type = 'm1.medium',
50
+ ri_util = 'light',
51
+ )
52
+ expect(a.ri_price_file).to eq "light_linux.min.js"
53
+ end
54
+
55
+ it "build current ri price file" do
56
+ a = Aws::RiKanjoo::Mode::Ec2.new(
57
+ region = 'ap-northeast-1',
58
+ instance_type = 'm3.medium',
59
+ ri_util = 'heavy',
60
+ )
61
+ expect(a.ri_price_file).to eq "linux-ri-heavy.min.js"
62
+ end
63
+
64
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+ require "aws/rikanjo/mode/rds"
3
+
4
+ describe 'AWS::Rikanjo::Mode::Rds' do
5
+
6
+ it "build current price url" do
7
+ a = Aws::RiKanjoo::Mode::Rds.new(
8
+ region = 'ap-northeast-1',
9
+ instance_type = 'm3.large',
10
+ ri_util = 'light',
11
+ multiaz = false,
12
+ )
13
+ expect(a.price_url).to eq "https://a0.awsstatic.com/pricing/1/rds/mysql"
14
+ end
15
+
16
+ it "build current om price file" do
17
+ a = Aws::RiKanjoo::Mode::Rds.new(
18
+ region = 'ap-northeast-1',
19
+ instance_type = 'm2.xlarge',
20
+ ri_util = 'medium',
21
+ multiaz = false,
22
+ )
23
+ expect(a.om_price_file).to eq "pricing-standard-deployments.min.js"
24
+ end
25
+
26
+ it "build current om price file(multiaz)" do
27
+ a = Aws::RiKanjoo::Mode::Rds.new(
28
+ region = 'ap-northeast-1',
29
+ instance_type = 'm2.xlarge',
30
+ ri_util = 'medium',
31
+ multiaz = true,
32
+ )
33
+ expect(a.om_price_file).to eq "pricing-multiAZ-deployments.min.js"
34
+ end
35
+
36
+ it "build current ri price file" do
37
+ a = Aws::RiKanjoo::Mode::Rds.new(
38
+ region = 'ap-northeast-1',
39
+ instance_type = 'm2.xlarge',
40
+ ri_util = 'medium',
41
+ multiaz = true,
42
+ )
43
+ expect(a.ri_price_file).to eq "pricing-medium-utilization-reserved-instances.min.js"
44
+ end
45
+
46
+ end
@@ -2,63 +2,4 @@ require "spec_helper"
2
2
  require "aws/rikanjo"
3
3
 
4
4
  describe 'AWS::Rikanjo' do
5
-
6
- it "is previous instance type" do
7
- %w{ m1.medium c1.medium m2.xlarge cc2.8xlarge cr1.8xlarge hi1.4xlarge cg1.4xlarge }.each do |t|
8
- a = Aws::RiKanjoo.new(
9
- region = 'ap-northeast-1',
10
- instance_type = t,
11
- ri_util = 'light',
12
- )
13
- expect(a.previous_generation_type).to eq true
14
- end
15
- end
16
-
17
- it "is current instance type" do
18
- %w{ t1.micro m1.small m3.medium c3.medium r3.xlarge i2.xlarge }.each do |t|
19
- a = Aws::RiKanjoo.new(
20
- region = 'ap-northeast-1',
21
- instance_type = t,
22
- ri_util = 'light',
23
- )
24
- expect(a.previous_generation_type).to eq false
25
- end
26
- end
27
-
28
- it "build previous price url" do
29
- a = Aws::RiKanjoo.new(
30
- region = 'ap-northeast-1',
31
- instance_type = 'm1.medium',
32
- ri_util = 'light',
33
- )
34
- expect(a.price_url).to eq "http://a0.awsstatic.com/pricing/1/ec2/previous-generation"
35
- end
36
-
37
- it "build current price url" do
38
- a = Aws::RiKanjoo.new(
39
- region = 'ap-northeast-1',
40
- instance_type = 'm3.medium',
41
- ri_util = 'light',
42
- )
43
- expect(a.price_url).to eq "http://a0.awsstatic.com/pricing/1/ec2"
44
- end
45
-
46
- it "build previous ri price file" do
47
- a = Aws::RiKanjoo.new(
48
- region = 'ap-northeast-1',
49
- instance_type = 'm1.medium',
50
- ri_util = 'light',
51
- )
52
- expect(a.ri_price_file).to eq "light_linux.min.js"
53
- end
54
-
55
- it "build current ri price file" do
56
- a = Aws::RiKanjoo.new(
57
- region = 'ap-northeast-1',
58
- instance_type = 'm3.medium',
59
- ri_util = 'heavy',
60
- )
61
- expect(a.ri_price_file).to eq "linux-ri-heavy.min.js"
62
- end
63
-
64
5
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-rikanjo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - kenjiskywalker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: AWS RI Cost Calc Tool
@@ -46,8 +46,8 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
50
- - .rspec
49
+ - ".gitignore"
50
+ - ".rspec"
51
51
  - Gemfile
52
52
  - LICENSE.txt
53
53
  - README.md
@@ -55,7 +55,11 @@ files:
55
55
  - aws-rikanjo.gemspec
56
56
  - bin/rikanjo
57
57
  - lib/aws/rikanjo.rb
58
+ - lib/aws/rikanjo/mode/ec2.rb
59
+ - lib/aws/rikanjo/mode/rds.rb
58
60
  - lib/aws/rikanjo/version.rb
61
+ - spec/lib/rikanjo_ec2_spec.rb
62
+ - spec/lib/rikanjo_rds_spec.rb
59
63
  - spec/lib/rikanjo_spec.rb
60
64
  - spec/spec_helper.rb
61
65
  homepage: https://github.com/kenjiskywalker/aws-rikanjo
@@ -68,20 +72,22 @@ require_paths:
68
72
  - lib
69
73
  required_ruby_version: !ruby/object:Gem::Requirement
70
74
  requirements:
71
- - - '>='
75
+ - - ">="
72
76
  - !ruby/object:Gem::Version
73
77
  version: '0'
74
78
  required_rubygems_version: !ruby/object:Gem::Requirement
75
79
  requirements:
76
- - - '>='
80
+ - - ">="
77
81
  - !ruby/object:Gem::Version
78
82
  version: '0'
79
83
  requirements: []
80
84
  rubyforge_project:
81
- rubygems_version: 2.1.11
85
+ rubygems_version: 2.2.2
82
86
  signing_key:
83
87
  specification_version: 4
84
88
  summary: calc 1 year cost. check sweet spot
85
89
  test_files:
90
+ - spec/lib/rikanjo_ec2_spec.rb
91
+ - spec/lib/rikanjo_rds_spec.rb
86
92
  - spec/lib/rikanjo_spec.rb
87
93
  - spec/spec_helper.rb