joyent-cloud-pricing 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7222aa546480d563b40f139b9678c17b6855780a
4
- data.tar.gz: 5100b881cfc5e2cf42c3862a121049d53a71b8db
3
+ metadata.gz: abf4af6ca921b105e367ac1235c83b136ba0cf17
4
+ data.tar.gz: c555428055b9b12a35199ee16bacfac178441150
5
5
  SHA512:
6
- metadata.gz: 446c0daa3bfd9431ea8bbf61400ea0f269352901abe21194dfd6968cde81e540b21bb936b0534e946d61f4fcb73d5fc6b52387b85f86d04a3e9374b28c4a05e3
7
- data.tar.gz: b5d4beb509476cbcd89671043bb7cf7fa03262d1a7d6a7117b4d75caf7e3faf4720ea8ba123d3b9cb5cc1158fee1d1d0745bb3ba6dca3796b82440eb0dcd955e
6
+ metadata.gz: aa060031a58028cd6c8cbc15a40aceddbbb29a4a8ffa3c16dc6650685c951f5a833d96a379ed24af9a9f998b1174a9064be90c7ac33d491452bebaec3cf4d0b0
7
+ data.tar.gz: 4cf153950979dfa5c0f87f0966529c93c4fadc40780e52871c1c6150a41c4cfdfb3a25bb2619d10b46d9997e7ad49ec052c0af3cf5629d1e7f961486e8e89606
data/README.md CHANGED
@@ -113,7 +113,7 @@ flavors = %w(
113
113
  commit = Joyent::Cloud::Pricing::Commit.from_yaml 'my_company/config/joyent-commit-pricing.yml'
114
114
  analyzer = Joyent::Cloud::Pricing::Analyzer.new(commit, flavors)
115
115
 
116
- analyzer.excess_monthly_price # => monthly $$ for instances in excess of reserve
116
+ analyzer.monthly_overages_price # => monthly $$ for instances in excess of reserve
117
117
  analyzer.over_reserved_zone_list # => list of zones in reserve, but not in reality
118
118
  ```
119
119
 
@@ -124,45 +124,48 @@ reserve discounts.
124
124
 
125
125
  ```ruby
126
126
  current_zone_list = %w(g3-highcpu-8-smartos g3-highcpu-8-smartos ... )
127
- reporter = Joyent::Cloud::Pricing::Reporter.new('config/reserve-commit.yml', current_zone_list)
128
- puts reporter.render```
129
-
130
- Output (prices are arbitrary in this sample output):
131
-
132
- ```bash
133
-
134
- SUMMARY:
135
- Total # of zones : 123
136
- Total # of reserved zones : 98
137
- Total # of reserved but WASTED zones : 0
138
- Reserve Pricing Term/Duration (years) : 1
139
-
140
- ONE TIME:
141
- Reserve Pricing Upfront Payments : $211,717.18
142
-
143
- MONTHLY:
144
- Monthly Cost of Reserve Pricing Zones : $12,457.51
145
- On Demand Resources Cost : $23,679.68
146
- Total Monthly (reserve + on demand) : $41,087.19
147
-
148
- YEARLY TOTALS:
149
- With reserve discounts : $331,607.30
150
- Without reserve discounts : $926,224.00
151
- Savings % : 41%
152
-
153
- UNRESERVED FLAVORS MONTHLY COST
154
- 9 x g3-highmemory-68.375-smartos : $10,562.40
155
- 1 x g3-highmemory-256-smartos-cc : $4,393.44
156
- 6 x g3-standard-7.5-smartos : $1,036.80
157
- 1 x g3-highmemory-34.25-smartos : $588.24
158
- 4 x g3-highcpu-1.75-kvm : $365.76
159
- 4 x g3-standard-0.5-smartos : $46.08
160
- 1 x g3-standard-0.625-smartos : $14.40
127
+ reporter = Joyent::Cloud::Pricing::Reporter.new('config/reserve-commit.yml', current_zone_list)
128
+
129
+ puts reporter.render
161
130
  ```
162
131
 
163
- ## Command Line Tools
132
+ Example output with commit pricing used:
164
133
 
165
- TBD.
134
+ ```
135
+ ZONE COUNTS:
136
+ Total # of zones 33
137
+ Total # of reserved zones 27
138
+ Total # of reserved but absent zones 1
139
+ Reserve Pricing Term/Duration (years) 1
140
+ .................................................................
141
+
142
+ RESERVE UPFRONT COST:
143
+ Reserve Pricing Upfront Payments $98,600.00
144
+ .................................................................
145
+
146
+ MONTHLY COSTS:
147
+ List of on-demand flavors by price
148
+ 2 x g3-highcpu-32-smartos-cc $3,339.36
149
+ 2 x g3-highcpu-16-smartos $1,670.40
150
+ 2 x g3-highcpu-7-smartos $731.52
151
+ 1 x g3-standard-30-smartos $691.20
152
+ ___________
153
+ On Demand Monthly $6,432.48
154
+
155
+ Zones Under Reserve Pricing $8,720.00
156
+ ___________
157
+ Total $15,152.48
158
+ .................................................................
159
+
160
+ YEARLY COSTS:
161
+ Savings due to Reserved Pricing $145,522.24
162
+ Savings % 34%
163
+
164
+ Reserve Yearly $203,240.00
165
+ On Demand Yearly $77,189.76
166
+ ___________
167
+ Total $280,429.76
168
+ ```
166
169
 
167
170
  ## Contributing
168
171
 
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency 'nokogiri'
23
- spec.add_dependency 'mixlib-cli'
24
23
  spec.add_dependency 'colored'
25
24
 
26
25
  spec.add_development_dependency 'bundler', '~> 1.5'
data/lib/pricing.rb CHANGED
@@ -22,5 +22,3 @@ require "pricing/formatter"
22
22
  require "pricing/commit"
23
23
  require "pricing/analyzer"
24
24
  require "pricing/reporter"
25
-
26
- require "pricing/cli"
@@ -30,31 +30,50 @@ module Joyent::Cloud::Pricing
30
30
  end
31
31
 
32
32
  # Excess zones cost this much
33
- def excess_monthly_price
33
+ def monthly_overages_price
34
34
  monthly_full_price_for(excess_zone_list)
35
35
  end
36
36
 
37
37
  # Monthly for all of the commits
38
- def commit_monthly_price
38
+ def monthly_commit_price
39
39
  commit.monthly_price
40
40
  end
41
41
 
42
42
  # Commits + excess non reserved zones
43
- def total_monthly_price
44
- excess_monthly_price + commit_monthly_price
43
+ def monthly_total_price
44
+ monthly_overages_price + monthly_commit_price
45
45
  end
46
46
 
47
47
  def upfront
48
48
  commit.upfront
49
49
  end
50
50
 
51
-
52
51
  def monthly_full_price_for zones
53
52
  total_price_for zones do |flavor|
54
53
  pricing.monthly(flavor)
55
54
  end
56
55
  end
57
56
 
57
+ def yearly_overages_price
58
+ monthly_overages_price * 12
59
+ end
60
+
61
+ def yearly_full_price
62
+ monthly_full_price * 12
63
+ end
64
+
65
+ def yearly_total
66
+ yearly_overages_price + commit.yearly_price
67
+ end
68
+
69
+ def yearly_savings
70
+ yearly_full_price - yearly_total
71
+ end
72
+
73
+ def yearly_savings_percent
74
+ 100 * (yearly_full_price - yearly_total) / yearly_full_price
75
+ end
76
+
58
77
  private
59
78
 
60
79
  def total_price_for zones, &block
@@ -27,7 +27,7 @@ module Joyent::Cloud::Pricing
27
27
  def render
28
28
  @r = self
29
29
  @f = formatter
30
- ERB.new(REPORT_ASCII).result(binding)
30
+ ERB.new(REPORT_ASCII, 0, '-').result(binding)
31
31
  end
32
32
 
33
33
  def reserve?
@@ -42,10 +42,6 @@ module Joyent::Cloud::Pricing
42
42
  Configuration.instance
43
43
  end
44
44
 
45
- def monthly_without_commit_discount
46
- analyzer.monthly_full_price_for(analyzer.zone_list)
47
- end
48
-
49
45
  def excess_zones
50
46
  zones = analyzer.excess_zone_list.each_pair.map{|flavor, count| [ flavor, count, pricing.monthly(flavor) * count ]}.sort{|x,y| y[2] <=> x[2]}
51
47
  zones
@@ -54,33 +50,54 @@ module Joyent::Cloud::Pricing
54
50
  def excess_zone_list
55
51
  excess_zones.map do |tuple|
56
52
  flavor, count, monthly = tuple
57
- sprintf(" %2d x %-36s : %20s",
58
- count, flavor, formatter.format_price(monthly, 20).red)
53
+ sprintf(" %2d x %-36s %20s",
54
+ count, flavor, formatter.format_price(monthly, 20).yellow)
59
55
  end.join("\n")
60
56
  end
61
57
 
58
+ SEPARATOR = ('.' * 65).cyan
62
59
  REPORT_ASCII = <<ASCII
63
- SUMMARY:
64
- Total # of zones : <%= sprintf("%20d", @r.zones).blue %>
65
- <% if @r.reserve? %> Total # of reserved zones : <%= sprintf("%20d", @r.commit.total_zones).green %>
66
- Total # of reserved but WASTED zones : <%= sprintf("%20d", @r.analyzer.over_reserved_zone_list.size || 0).red %>
67
- Reserve Pricing Term/Duration (years) : <%= sprintf("%20d", @r.commit.years || 0).green %>
68
-
69
- ONE TIME:
70
- Reserve Pricing Upfront Payments : <%= @f.format_price(@r.commit.upfront_price, 20).green %>
71
- <% end %>
72
- MONTHLY:
73
- <% if @r.reserve? %> Monthly Cost of Reserve Pricing Zones : <%= @f.format_price(@r.commit.monthly_price, 20).green %>
74
- <% end %> On Demand Resources Cost : <%= @f.format_price(@r.analyzer.excess_monthly_price, 20).red %>
75
- <% if @r.reserve? %> Total Monthly (reserve + on demand) : <%= @f.format_price(@r.analyzer.total_monthly_price, 20).blue %><% end %>
76
-
77
- YEARLY TOTALS:
78
- <% if @r.reserve? %> With reserve discounts : <%= @f.format_price(@r.commit.yearly_price, 20).green %>
79
- <% end %> Without reserve discounts : <%= @f.format_price(@r.monthly_without_commit_discount * 12, 20).red %>
80
- <% if @r.reserve? %> Savings % : <%= (sprintf "%19d", (100 * (@r.monthly_without_commit_discount * 12 - @r.commit.yearly_price) / (@r.monthly_without_commit_discount * 12))).green %>%<% end %>
81
-
82
- UNRESERVED FLAVORS MONTHLY COST
60
+
61
+ ZONE COUNTS:
62
+ Total # of zones <%= sprintf("%20d", @r.zones).cyan %>
63
+ <%- if @r.reserve? -%>
64
+ Total # of reserved zones <%= sprintf("%20d", @r.commit.total_zones).green %>
65
+ Total # of reserved but absent zones <%= value = sprintf("%20d", @r.analyzer.over_reserved_zone_list.size || 0); value == "0" ? value.blue : value.red %>
66
+ Reserve Pricing Term/Duration (years) <%= sprintf("%20d", @r.commit.years || 0).blue %>
67
+ <%= SEPARATOR %>
68
+
69
+ RESERVE UPFRONT COST:
70
+ Reserve Pricing Upfront Payments <%= @f.format_price(@r.commit.upfront_price, 20).green %>
71
+ <%- end -%>
72
+ <%= SEPARATOR %>
73
+
74
+ MONTHLY COSTS:
75
+ List of on-demand flavors by price
83
76
  <%= @r.excess_zone_list %>
77
+ <%= "___________".yellow %>
78
+ On Demand Monthly <%= @f.format_price(@r.analyzer.monthly_overages_price, 20).yellow %>
79
+
80
+ <%- if @r.reserve? -%>
81
+ Zones Under Reserve Pricing <%= @f.format_price(@r.commit.monthly_price, 20).green %>
82
+ <%- end -%>
83
+ <%- if @r.reserve? -%>
84
+ <%= "___________".cyan %>
85
+ Total <%= @f.format_price(@r.analyzer.monthly_total_price, 20).cyan %>
86
+ <%- end -%>
87
+ <%= SEPARATOR %>
88
+
89
+ YEARLY COSTS:
90
+ <%- if @r.reserve? -%>
91
+ Savings due to Reserved Pricing <%= @f.format_price(@r.analyzer.yearly_savings, 20).green %>
92
+ Savings % <%= sprintf("%19d", @r.analyzer.yearly_savings_percent).green + '%'.green %>
93
+
94
+ Reserve Yearly <%= @f.format_price(@r.commit.yearly_price, 20).green %>
95
+ On Demand Yearly <%= @f.format_price(@r.analyzer.yearly_overages_price, 20).yellow %>
96
+ <%= "___________".cyan %>
97
+ Total <%= @f.format_price(@r.analyzer.yearly_total, 20).cyan %>
98
+ <%- else -%>
99
+ On Demand Yearly <%= @f.format_price(@r.analyzer.yearly_full_price, 20).cyan %>
100
+ <%- end -%>
84
101
 
85
102
  ASCII
86
103
 
@@ -1,7 +1,7 @@
1
1
  module Joyent
2
2
  module Cloud
3
3
  module Pricing
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
6
6
  end
7
7
  end
@@ -70,8 +70,8 @@ describe 'Joyent::Cloud::Pricing::Analyze' do
70
70
  })
71
71
  end
72
72
 
73
- it '#excess_monthly_price' do
74
- expect(analyzer.excess_monthly_price).to eql( 6432.48 )
73
+ it '#monthly_overages_price' do
74
+ expect(analyzer.monthly_overages_price).to eql( 6432.48 )
75
75
  end
76
76
 
77
77
  it '#over_reserved_zone_list' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joyent-cloud-pricing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-29 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: mixlib-cli
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: colored
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -112,8 +98,7 @@ description: Various set of tools and helpers to calculate infrastructure footpr
112
98
  and cost on Joyent Cloud. Supports commit discounts.
113
99
  email:
114
100
  - kigster@gmail.com
115
- executables:
116
- - joyent-price-helper
101
+ executables: []
117
102
  extensions: []
118
103
  extra_rdoc_files: []
119
104
  files:
@@ -124,14 +109,12 @@ files:
124
109
  - LICENSE.txt
125
110
  - README.md
126
111
  - Rakefile
127
- - bin/joyent-price-helper
128
112
  - config/commit_pricing.yml.example
129
113
  - config/joyent_pricing.yml
130
114
  - config/legacy_prices.yml
131
115
  - joyent-cloud-pricing.gemspec
132
116
  - lib/pricing.rb
133
117
  - lib/pricing/analyzer.rb
134
- - lib/pricing/cli.rb
135
118
  - lib/pricing/commit.rb
136
119
  - lib/pricing/configuration.rb
137
120
  - lib/pricing/formatter.rb
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- require 'rubygems'
4
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
- require 'pricing'
6
-
7
- Joyent::Cloud::Pricing::CLI.new.run
8
-
data/lib/pricing/cli.rb DELETED
@@ -1,36 +0,0 @@
1
- require 'mixlib/cli'
2
-
3
- module Joyent
4
- module Cloud
5
- module Pricing
6
- class CLI
7
- include Mixlib::CLI
8
-
9
- banner 'Usage: joyent-price-helper [--commit <path-to-commit.yml] '
10
-
11
- option :commit_config,
12
- short: '-c COMMIT_CONFIG',
13
- long: '--commit COMMIT_CONFIG',
14
- description: 'Path to the config file for commit pricing (YML), default is "config/commit_pricing.yml"',
15
- required: false
16
-
17
- option :help,
18
- short: '-h',
19
- long: '--help',
20
- description: 'Show this message',
21
- on: :tail,
22
- boolean: true,
23
- show_options: true,
24
- exit: 0
25
-
26
- attr_reader :args
27
-
28
- def run argv = ARGV
29
- parse_options(argv)
30
- end
31
-
32
- end
33
- end
34
- end
35
- end
36
-