joyent-cloud-pricing 1.0.2 → 1.0.3
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 +4 -4
- data/README.md +40 -37
- data/joyent-cloud-pricing.gemspec +0 -1
- data/lib/pricing.rb +0 -2
- data/lib/pricing/analyzer.rb +24 -5
- data/lib/pricing/reporter.rb +44 -27
- data/lib/pricing/version.rb +1 -1
- data/spec/pricing/analyze_spec.rb +2 -2
- metadata +3 -20
- data/bin/joyent-price-helper +0 -8
- data/lib/pricing/cli.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abf4af6ca921b105e367ac1235c83b136ba0cf17
|
4
|
+
data.tar.gz: c555428055b9b12a35199ee16bacfac178441150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
128
|
-
|
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
|
-
|
132
|
+
Example output with commit pricing used:
|
164
133
|
|
165
|
-
|
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
|
|
data/lib/pricing.rb
CHANGED
data/lib/pricing/analyzer.rb
CHANGED
@@ -30,31 +30,50 @@ module Joyent::Cloud::Pricing
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Excess zones cost this much
|
33
|
-
def
|
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
|
38
|
+
def monthly_commit_price
|
39
39
|
commit.monthly_price
|
40
40
|
end
|
41
41
|
|
42
42
|
# Commits + excess non reserved zones
|
43
|
-
def
|
44
|
-
|
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
|
data/lib/pricing/reporter.rb
CHANGED
@@ -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
|
58
|
-
count, flavor, formatter.format_price(monthly, 20).
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
|
data/lib/pricing/version.rb
CHANGED
@@ -70,8 +70,8 @@ describe 'Joyent::Cloud::Pricing::Analyze' do
|
|
70
70
|
})
|
71
71
|
end
|
72
72
|
|
73
|
-
it '#
|
74
|
-
expect(analyzer.
|
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.
|
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-
|
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
|
data/bin/joyent-price-helper
DELETED
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
|
-
|