awsprice 0.0.1
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 +7 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +48 -0
- data/README.rdoc +6 -0
- data/Rakefile +44 -0
- data/awsprice.gemspec +26 -0
- data/awsprice.rdoc +5 -0
- data/bin/awsprice +112 -0
- data/features/awsprice.feature +32 -0
- data/features/step_definitions/awsprice_steps.rb +16 -0
- data/features/support/env.rb +18 -0
- data/lib/awsprice.rb +182 -0
- data/lib/awsprice/instance.rb +6 -0
- data/lib/awsprice/price.rb +5 -0
- data/lib/awsprice/price_ondemand.rb +7 -0
- data/lib/awsprice/price_reserved.rb +5 -0
- data/lib/awsprice/version.rb +3 -0
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1b55dc0f402413d4625c06b3bfe126cbfd6a61a9
|
4
|
+
data.tar.gz: 1ef08287d697c862c7205347b7ff74a6f9675a76
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e97ef861f133ebf843f96ea9298d03190011453c97c85789abf6718ef036db73c1ba9dd326fb36a26e99651598a16dd7a094b167531e25fc2c9f732caa219442
|
7
|
+
data.tar.gz: b4d7a1acf7496a590e3a2bbe116a30608560181ae0839ec8fc117788d34673ba4020e688b1d3a5577c4f1d0f7a843702e66a32a7d462d17e5fcb2adc1565de6e
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
awsprice (0.0.1)
|
5
|
+
gli (= 2.9.0)
|
6
|
+
rainbow
|
7
|
+
terminal-table
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
aruba (0.5.4)
|
13
|
+
childprocess (>= 0.3.6)
|
14
|
+
cucumber (>= 1.1.1)
|
15
|
+
rspec-expectations (>= 2.7.0)
|
16
|
+
builder (3.2.2)
|
17
|
+
childprocess (0.5.2)
|
18
|
+
ffi (~> 1.0, >= 1.0.11)
|
19
|
+
cucumber (1.3.14)
|
20
|
+
builder (>= 2.1.2)
|
21
|
+
diff-lcs (>= 1.1.3)
|
22
|
+
gherkin (~> 2.12)
|
23
|
+
multi_json (>= 1.7.5, < 2.0)
|
24
|
+
multi_test (>= 0.1.1)
|
25
|
+
diff-lcs (1.2.5)
|
26
|
+
ffi (1.9.3)
|
27
|
+
gherkin (2.12.2)
|
28
|
+
multi_json (~> 1.3)
|
29
|
+
gli (2.9.0)
|
30
|
+
json (1.8.1)
|
31
|
+
multi_json (1.9.2)
|
32
|
+
multi_test (0.1.1)
|
33
|
+
rainbow (2.0.0)
|
34
|
+
rake (10.2.2)
|
35
|
+
rdoc (4.1.1)
|
36
|
+
json (~> 1.4)
|
37
|
+
rspec-expectations (2.14.5)
|
38
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
39
|
+
terminal-table (1.4.5)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
aruba
|
46
|
+
awsprice!
|
47
|
+
rake
|
48
|
+
rdoc
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
Rake::RDocTask.new do |rd|
|
8
|
+
rd.main = "README.rdoc"
|
9
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
10
|
+
rd.title = 'Awsprice'
|
11
|
+
end
|
12
|
+
|
13
|
+
spec = eval(File.read('awsprice.gemspec'))
|
14
|
+
|
15
|
+
Gem::PackageTask.new(spec) do |pkg|
|
16
|
+
end
|
17
|
+
CUKE_RESULTS = 'results.html'
|
18
|
+
CLEAN << CUKE_RESULTS
|
19
|
+
desc 'Run features'
|
20
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
21
|
+
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
22
|
+
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
23
|
+
t.cucumber_opts = opts
|
24
|
+
t.fork = false
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Run features tagged as work-in-progress (@wip)'
|
28
|
+
Cucumber::Rake::Task.new('features:wip') do |t|
|
29
|
+
tag_opts = ' --tags ~@pending'
|
30
|
+
tag_opts = ' --tags @wip'
|
31
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
32
|
+
t.fork = false
|
33
|
+
end
|
34
|
+
|
35
|
+
task :cucumber => :features
|
36
|
+
task 'cucumber:wip' => 'features:wip'
|
37
|
+
task :wip => 'features:wip'
|
38
|
+
require 'rake/testtask'
|
39
|
+
Rake::TestTask.new do |t|
|
40
|
+
t.libs << "test"
|
41
|
+
t.test_files = FileList['test/*_test.rb']
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => [:test,:features]
|
data/awsprice.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','awsprice','version.rb'])
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = 'awsprice'
|
5
|
+
s.version = Awsprice::VERSION
|
6
|
+
s.author = 'netalpha'
|
7
|
+
s.license = 'MIT'
|
8
|
+
s.email = 'cs.chavez1986@email.com'
|
9
|
+
s.homepage = 'http://netalpha.github.io'
|
10
|
+
s.description = "I will improve this later."
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.summary = 'This is a command line application for query amazon webservice prices'
|
13
|
+
s.files = `git ls-files`.split(" ")
|
14
|
+
s.require_paths << 'lib'
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.extra_rdoc_files = ['README.rdoc','awsprice.rdoc']
|
17
|
+
s.rdoc_options << '--title' << 'awsprice' << '--main' << 'README.rdoc' << '-ri'
|
18
|
+
s.bindir = 'bin'
|
19
|
+
s.executables << 'awsprice'
|
20
|
+
s.add_development_dependency('rake', '~>0')
|
21
|
+
s.add_development_dependency('rdoc', '~>0')
|
22
|
+
s.add_development_dependency('aruba', '~>0')
|
23
|
+
s.add_runtime_dependency('gli','~>2.9')
|
24
|
+
s.add_runtime_dependency('terminal-table', '~>0')
|
25
|
+
s.add_runtime_dependency('rainbow', '~>0')
|
26
|
+
end
|
data/awsprice.rdoc
ADDED
data/bin/awsprice
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
require 'pstore'
|
4
|
+
require 'terminal-table'
|
5
|
+
require 'rainbow'
|
6
|
+
|
7
|
+
begin # XXX: Remove this begin/rescue before distributing your app
|
8
|
+
require 'awsprice'
|
9
|
+
rescue LoadError
|
10
|
+
STDERR.puts "In development, you need to use `bundle exec bin/awsprice` to run your app"
|
11
|
+
STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
|
12
|
+
STDERR.puts "Feel free to remove this message from bin/awsprice now"
|
13
|
+
exit 64
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
include GLI::App
|
18
|
+
|
19
|
+
program_desc 'This is an command line application for query latest amazon web service prices.'
|
20
|
+
|
21
|
+
version Awsprice::VERSION
|
22
|
+
|
23
|
+
desc "the display format: table, markdown, csv"
|
24
|
+
flag [:format, :f], required: false, must_match: ['table', 'markdown', 'csv'], default_value: 'table'
|
25
|
+
|
26
|
+
desc "list ondemand instances prices"
|
27
|
+
command :ondemand do |c|
|
28
|
+
c.action do |global_options, options, args|
|
29
|
+
if global_options[:format] == 'table'
|
30
|
+
table = Terminal::Table.new do |t|
|
31
|
+
t.headings = ["ID", "REGION", "SIZE", "OS", "PRICE(USD/HOUR)"]
|
32
|
+
id = 1
|
33
|
+
Awsprice::EC2.new.get_price_ondemand.each do |ins|
|
34
|
+
t << [id, ins.region, ins.size, ins.os, ins.price_per_hour]
|
35
|
+
id = id + 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
puts table
|
39
|
+
# elsif global_options[:format] == 'csv'
|
40
|
+
# puts "ID,REGION,TYPE,SIZE,VCPU,ECU,MEMORY,STORAGE,OS,PRICE"
|
41
|
+
# id = 1
|
42
|
+
# Awsprice::EC2.new.ondemand_instances.each do |ins|
|
43
|
+
# puts "#{id},#{ins.region},#{ins.type},#{ins.size},#{ins.vcpu},#{ins.ecu},#{ins.memory},#{ins.storage},#{ins.os},#{ins.price}"
|
44
|
+
# id = id + 1
|
45
|
+
# end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "list reserved instances prices"
|
51
|
+
command :reserved do |c|
|
52
|
+
c.desc "utilization type: medium or heavy"
|
53
|
+
c.flag [:utilization, :u], required: true, must_match: ['medium', 'heavy']
|
54
|
+
c.action do |global_options, options, args|
|
55
|
+
if global_options[:format] == 'table'
|
56
|
+
table = Terminal::Table.new do |t|
|
57
|
+
t.headings = ["ID", "REGION", "SIZE", "OS", "yrTerm1", "yrTerm1Hourly", "yrTerm3", "yrTerm3Hourly"]
|
58
|
+
id = 1
|
59
|
+
price = []
|
60
|
+
if options[:u] == 'medium'
|
61
|
+
price = Awsprice::EC2.new.get_price_reserved_medium
|
62
|
+
elsif options[:u] == 'heavy'
|
63
|
+
price = Awsprice::EC2.new.get_price_reserved_heavy
|
64
|
+
end
|
65
|
+
price.each do |ins|
|
66
|
+
t << [id, ins.region, ins.size, ins.os, ins.yrTerm1, ins.yrTerm1Hourly, ins.yrTerm3, ins.yrTerm3Hourly]
|
67
|
+
id = id + 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
puts table
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
pre do |global,command,options,args|
|
76
|
+
# @store = PStore.new %(#{ENV['HOME']}/awsprice.pstore)
|
77
|
+
# @store.transaction do
|
78
|
+
# @store[:regions] ||= []
|
79
|
+
# end
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
post do |global,command,options,args|
|
84
|
+
end
|
85
|
+
|
86
|
+
on_error do |exception|
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def print_table(headings, key)
|
92
|
+
table = Terminal::Table.new do |t|
|
93
|
+
t.headings = [headings]
|
94
|
+
@store.transaction do
|
95
|
+
@store[key].each do |value|
|
96
|
+
t << [value]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
puts table
|
101
|
+
end
|
102
|
+
|
103
|
+
def print_markdown headings, key
|
104
|
+
puts headings
|
105
|
+
@store.transaction do
|
106
|
+
@store[key].each do |value|
|
107
|
+
puts " * #{value}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
exit run(ARGV)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: My bootstrapped app kinda works
|
2
|
+
In order to get going on coding my awesome app
|
3
|
+
I want to have aruba and cucumber setup
|
4
|
+
So I don't have to do it myself
|
5
|
+
|
6
|
+
Scenario: App just runs
|
7
|
+
When I get help for "awsprice"
|
8
|
+
Then the exit status should be 0
|
9
|
+
|
10
|
+
Scenario: List all the regions
|
11
|
+
Given Amazon has the following regions:
|
12
|
+
"""
|
13
|
+
west
|
14
|
+
east
|
15
|
+
north
|
16
|
+
south
|
17
|
+
"""
|
18
|
+
When I run `awsprice region list`
|
19
|
+
Then the output should contain "west"
|
20
|
+
And the output should contain "east"
|
21
|
+
And the output should contain "north"
|
22
|
+
And the output should contain "south"
|
23
|
+
|
24
|
+
Scenario: list all the ondemand instances
|
25
|
+
When I run `awsprice ondemand`
|
26
|
+
Then the output should contain "hiMemCurrentGen"
|
27
|
+
And the output should contain "34000"
|
28
|
+
|
29
|
+
@wip
|
30
|
+
Scenario: list all the reserved instances
|
31
|
+
When I run `awsprice reserved`
|
32
|
+
Then the output should contain "not-known"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
When /^I get help for "([^"]*)"$/ do |app_name|
|
2
|
+
@app_name = app_name
|
3
|
+
step %(I run `#{app_name} help`)
|
4
|
+
end
|
5
|
+
|
6
|
+
# Add more step definitions here
|
7
|
+
When /^Amazon has the following regions:$/ do |regions|
|
8
|
+
store = PStore.new %(#{ENV["HOME"]}/awsprice.pstore)
|
9
|
+
store.transaction do
|
10
|
+
new_region = []
|
11
|
+
regions.lines.each do |region|
|
12
|
+
new_region << region.to_s
|
13
|
+
end
|
14
|
+
store[:regions] = new_region
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'pstore'
|
3
|
+
|
4
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
5
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
6
|
+
|
7
|
+
Before do
|
8
|
+
# Using "announce" causes massive warnings on 1.9.2
|
9
|
+
@puts = true
|
10
|
+
@original_rubylib = ENV['RUBYLIB']
|
11
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
12
|
+
%x(rm -rf #{ENV['HOME']}/awsprice.pstore)
|
13
|
+
@aruba_timeout_seconds = 1005
|
14
|
+
end
|
15
|
+
|
16
|
+
After do
|
17
|
+
ENV['RUBYLIB'] = @original_rubylib
|
18
|
+
end
|
data/lib/awsprice.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'awsprice/version.rb'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
require 'pstore'
|
5
|
+
|
6
|
+
Dir[File.join(File.dirname(__FILE__), 'awsprice/*.rb')].sort.each { |lib| require lib }
|
7
|
+
|
8
|
+
module Awsprice
|
9
|
+
class Info
|
10
|
+
@@REGIONS= {
|
11
|
+
'us-east-1' => 'us-east',
|
12
|
+
'us-west-1' => 'us-west',
|
13
|
+
'us-west-2' => 'us-west-2',
|
14
|
+
'eu-west-1' => 'eu-ireland',
|
15
|
+
'ap-southeast-1' => 'apac-sin',
|
16
|
+
'ap-southeast-2' => 'apac-syd',
|
17
|
+
'ap-northeast-1' => 'apac-tokyo',
|
18
|
+
'sa-east-1' => 'sa-east-1'
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
# @store = PStore.new %(#{ENV['HOME']}/awsprice.pstore)
|
24
|
+
|
25
|
+
# @store[:regions] = []
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.fetch_url url
|
29
|
+
uri = URI.parse(url)
|
30
|
+
page = Net::HTTP.get_response(uri)
|
31
|
+
|
32
|
+
body = page.body.gsub("callback(", "").reverse.sub(")", "").reverse
|
33
|
+
if body.split("\n").last == ";"
|
34
|
+
|
35
|
+
body = body.reverse.sub(";", "").reverse
|
36
|
+
elsif body[-1] == ";"
|
37
|
+
body.chop!
|
38
|
+
end
|
39
|
+
|
40
|
+
begin
|
41
|
+
JSON.parse(body)
|
42
|
+
rescue JSON::ParserError
|
43
|
+
JSON.parse(body.gsub(/(\w+)\s*:/, '"\1":'))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class EC2 < Info
|
49
|
+
#attr_accessor :all_instances, :ondemand_instances
|
50
|
+
|
51
|
+
EC2_BASE_URL = "http://a0.awsstatic.com/pricing/1/ec2/"
|
52
|
+
# EC2_BASE_URL = "http://aws-assets-pricing-prod.s3.amazonaws.com/pricing/ec2/"
|
53
|
+
|
54
|
+
@@OS_TYPES = [:linux, :mswin, :rhel, :sles, :mswinSQL, :mswinSQLWeb]
|
55
|
+
@@RES_TYPES = [:medium, :heavy]
|
56
|
+
|
57
|
+
def initialize
|
58
|
+
@ec2_spec = {}
|
59
|
+
@ec2_ondemand_price = []
|
60
|
+
@ec2_medium_reserved_price = []
|
61
|
+
@ec2_heavy_reserved_price = []
|
62
|
+
# unless File.exist? "awsprice.pstore"
|
63
|
+
crawl
|
64
|
+
# end
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_price_reserved_medium
|
68
|
+
@ec2_medium_reserved_price
|
69
|
+
# @ec2_medium_reserved_price.each do |price|
|
70
|
+
# puts "#{price.region} #{price.size} #{price.os} #{price.yrTerm1} #{price.yrTerm1Hourly}, #{price.yrTerm3}, #{price.yrTerm3Hourly}"
|
71
|
+
# end
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_price_reserved_heavy
|
75
|
+
@ec2_heavy_reserved_price
|
76
|
+
# @ec2_heavy_reserved_price.each do |price|
|
77
|
+
# puts "#{price.region} #{price.size} #{price.os} #{price.yrTerm1} #{price.yrTerm1Hourly}, #{price.yrTerm3}, #{price.yrTerm3Hourly}"
|
78
|
+
# end
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_price_ondemand
|
82
|
+
@ec2_ondemand_price
|
83
|
+
# @ec2_ondemand_price.each do |price|
|
84
|
+
# puts "#{price.region} #{price.size} #{price.os} #{price.price_per_hour}"
|
85
|
+
# end
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_spec
|
89
|
+
@ec2_spec.each do |key, ins|
|
90
|
+
puts "#{ins.size} #{ins.type} #{ins.memory}, #{ins.ecu}, #{ins.vcpu}, #{ins.storage}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def crawl
|
97
|
+
fetch_ondemand_prices
|
98
|
+
fetch_reserved_prices
|
99
|
+
end
|
100
|
+
|
101
|
+
def fetch_ondemand_prices
|
102
|
+
@@OS_TYPES.each do |os|
|
103
|
+
parse_ec2_ondemand_jsons(EC2_BASE_URL + "#{os}-od.min.js")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def fetch_reserved_prices
|
108
|
+
@@OS_TYPES.each do |os|
|
109
|
+
@@RES_TYPES.each do |use|
|
110
|
+
parse_ec2_reserved_json(EC2_BASE_URL + "#{os}-ri-#{use}.min.js", os, use)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def parse_ec2_reserved_json url, os, use
|
116
|
+
res = Info.fetch_url url
|
117
|
+
res['config']['regions'].each do |reg|
|
118
|
+
reg['instanceTypes'].each do |type|
|
119
|
+
type['sizes'].each do |size|
|
120
|
+
# ins_by_region_and_size = instances.select do |ins|
|
121
|
+
# ins.region = reg['region']
|
122
|
+
# ins.size = size['size']
|
123
|
+
# end
|
124
|
+
price = Price_reserved.new
|
125
|
+
price.region = reg['region']
|
126
|
+
price.size = size['size']
|
127
|
+
price.os = os
|
128
|
+
size['valueColumns'].each do |value_col|
|
129
|
+
case value_col['name']
|
130
|
+
when 'yrTerm1'
|
131
|
+
price.yrTerm1 = value_col['prices']['USD']
|
132
|
+
when 'yrTerm1Hourly'
|
133
|
+
price.yrTerm1Hourly = value_col['prices']['USD']
|
134
|
+
when 'yrTerm3'
|
135
|
+
price.yrTerm3 = value_col['prices']['USD']
|
136
|
+
when 'yrTerm3Hourly'
|
137
|
+
price.yrTerm3Hourly = value_col['prices']['USD']
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
if use == :medium
|
142
|
+
@ec2_medium_reserved_price << price
|
143
|
+
elsif use == :heavy
|
144
|
+
@ec2_heavy_reserved_price << price
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def parse_ec2_ondemand_jsons url
|
154
|
+
# fetch the json object
|
155
|
+
res = Info.fetch_url url
|
156
|
+
# parse the json object
|
157
|
+
res['config']['regions'].each do |reg|
|
158
|
+
reg['instanceTypes'].each do |type|
|
159
|
+
type['sizes'].each do |size|
|
160
|
+
ins = Instance.new
|
161
|
+
ins.type = type['type'];
|
162
|
+
ins.vcpu = size['vCPU'].to_i
|
163
|
+
ins.ecu = size['ECU']
|
164
|
+
ins.memory = (size['memoryGiB'].to_f * 1000).to_i
|
165
|
+
ins.storage = size['storageGB']
|
166
|
+
ins.size = size['size']
|
167
|
+
@ec2_spec[size['size']] ||= ins
|
168
|
+
size['valueColumns'].each do |value_col|
|
169
|
+
price = Price_ondemand.new
|
170
|
+
price.region = reg['region']
|
171
|
+
price.size = size['size']
|
172
|
+
price.os = value_col['name']
|
173
|
+
price.price_per_hour = value_col['prices']['USD'].to_f
|
174
|
+
@ec2_ondemand_price << price
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: awsprice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- netalpha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aruba
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.9'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: terminal-table
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rainbow
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: I will improve this later.
|
98
|
+
email: cs.chavez1986@email.com
|
99
|
+
executables:
|
100
|
+
- awsprice
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files:
|
103
|
+
- README.rdoc
|
104
|
+
- awsprice.rdoc
|
105
|
+
files:
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
108
|
+
- README.rdoc
|
109
|
+
- Rakefile
|
110
|
+
- awsprice.gemspec
|
111
|
+
- awsprice.rdoc
|
112
|
+
- bin/awsprice
|
113
|
+
- features/awsprice.feature
|
114
|
+
- features/step_definitions/awsprice_steps.rb
|
115
|
+
- features/support/env.rb
|
116
|
+
- lib/awsprice.rb
|
117
|
+
- lib/awsprice/instance.rb
|
118
|
+
- lib/awsprice/price.rb
|
119
|
+
- lib/awsprice/price_ondemand.rb
|
120
|
+
- lib/awsprice/price_reserved.rb
|
121
|
+
- lib/awsprice/version.rb
|
122
|
+
- test/default_test.rb
|
123
|
+
- test/test_helper.rb
|
124
|
+
homepage: http://netalpha.github.io
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options:
|
130
|
+
- "--title"
|
131
|
+
- awsprice
|
132
|
+
- "--main"
|
133
|
+
- README.rdoc
|
134
|
+
- "-ri"
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.2.2
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: This is a command line application for query amazon webservice prices
|
154
|
+
test_files: []
|
155
|
+
has_rdoc: true
|