aws-ec2-instance_types 1.0.3 → 1.0.4
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 +8 -8
- data/VERSION +1 -1
- data/aws-ec2-instance_types.gemspec +2 -2
- data/bin/aws-ec2-instance_types +1 -1
- data/lib/dldinternet/aws/ec2/instance_types.rb +45 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGEyNTViMmMxZDgwMDMyZjExMTA2YjgwZWRmYjAwMTY0MGVhYjgwYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGFiZjM3MmM5NTlmOWE2NmRlYmRiYWMwOThlMGEyYmQ0ZTU3YTVkMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjU1YTA2Mjg4M2IwMjU1OTBmZDkyMGFmMmNhZTc3NzFhNGQ2MzNmYWE2YWI4
|
10
|
+
YzNhNTczNTcwMjAxMjZhMzZmYTRlNDM3Y2Q0NGEwZmNmOWRlYTg4ZWY4ZGZl
|
11
|
+
OGQ0Y2E5NWMzMzU3ZmEzNDk5MDM5YWVmMzJmNDQzNjk3MTBlYjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGY1NmFhYzliYTZhMTdlOWIwOTU2ZjI0M2NlODljNjMxNGM3ZDUzYWI3MjY2
|
14
|
+
OWY3MTI5NDdiZDIxYThkZjdhNzk1MTI3YzYwNGU1OGFlZDE0MGE5MzIwZTE1
|
15
|
+
MWJjM2RkNDk2MGMyYWViY2Q0MDA1M2I1MzVlM2ZiODFhNGMwNzY=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: aws-ec2-instance_types 1.0.
|
5
|
+
# stub: aws-ec2-instance_types 1.0.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "aws-ec2-instance_types"
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Christo De Lange"]
|
data/bin/aws-ec2-instance_types
CHANGED
@@ -16,7 +16,7 @@ require "awesome_print"
|
|
16
16
|
require "colorize"
|
17
17
|
|
18
18
|
begin
|
19
|
-
puts getInstanceTypes(:mechanize => mechanize).ai
|
19
|
+
puts getInstanceTypes(:mechanize => mechanize)[:instance_type_details].ai
|
20
20
|
rescue Timeout::Error => e
|
21
21
|
puts "Unable to retrieve instance type details in a reasonable time (#{mechanize.open_timeout}s). Giving up ...".light_red
|
22
22
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module DLDInternet
|
2
2
|
module AWS
|
3
3
|
module EC2
|
4
|
+
class Error < StandardError ; end
|
4
5
|
HEADINGS = [
|
5
6
|
:instance_family, # [0]
|
6
7
|
:instance_type, # [1]
|
@@ -12,9 +13,22 @@ module DLDInternet
|
|
12
13
|
:EBS_optimized_available, # [7]
|
13
14
|
:network_performance # [8]
|
14
15
|
]
|
16
|
+
HEADINGS_CPU = [
|
17
|
+
:instance_family, # [0]
|
18
|
+
:instance_type, # [1]
|
19
|
+
:processor_arch, # [2]
|
20
|
+
:vCPU, # [3]
|
21
|
+
:ECU, # [4]
|
22
|
+
:physical_processor, # [5]
|
23
|
+
:Intel_AES_NI, # [6]
|
24
|
+
:Intel_AVX, # [7]
|
25
|
+
:Intel_Turbo, # [8]
|
26
|
+
|
27
|
+
]
|
15
28
|
|
16
29
|
attr_reader :instance_types
|
17
30
|
|
31
|
+
# ---------------------------------------------------------------------------------------------------------------
|
18
32
|
def getInstanceTypes(options={})
|
19
33
|
unless @instance_types
|
20
34
|
@instance_types = {}
|
@@ -30,34 +44,43 @@ module DLDInternet
|
|
30
44
|
|
31
45
|
require "nokogiri"
|
32
46
|
nk = Nokogiri::HTML(page.body)
|
33
|
-
|
34
|
-
|
35
|
-
rows = table.search('tr')[0..-1]
|
36
|
-
head = rows.shift
|
47
|
+
div = nk.css("div#yui-main div.yui-b")
|
48
|
+
tables = div.search('table')
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
50
|
+
@instance_types[:instance_type_details] = scrapeTable(HEADINGS, tables[0])
|
51
|
+
@instance_types[:processor_details] = scrapeTable(HEADINGS_CPU, tables[1])
|
52
|
+
end
|
53
|
+
@instance_types
|
54
|
+
end
|
43
55
|
|
44
|
-
|
45
|
-
|
56
|
+
# ---------------------------------------------------------------------------------------------------------------
|
57
|
+
def scrapeTable(cHeadings,table)
|
58
|
+
raise Error.new "Cannot find instance type table" unless table.is_a?(Nokogiri::XML::Element)
|
59
|
+
rows = table.search('tr')[0..-1]
|
60
|
+
head = rows.shift
|
46
61
|
|
47
|
-
|
48
|
-
|
62
|
+
cols = head.search('td').collect { |td|
|
63
|
+
text = td.text.to_s
|
64
|
+
text = text.gsub(%r/(\r?\n)+/, ' ').strip
|
65
|
+
CGI.unescapeHTML(text)
|
66
|
+
}
|
67
|
+
instance_types = {
|
68
|
+
:headings => {},
|
69
|
+
:details => []
|
70
|
+
}
|
71
|
+
(0..cols.size-1).map { |i| instance_types[:headings][cHeadings[i]] = cols[i] }
|
49
72
|
|
50
|
-
|
51
|
-
CGI.unescapeHTML(td.text.to_s.gsub(%r/(\r?\n)+/, ' ').strip.gsub('32-bit or64-bit', '32-bit or 64-bit'))
|
52
|
-
}
|
53
|
-
raise StandardError.new "This row does not have the same number of cells as the table header: #{row.text.to_s.strip}" unless cells.size == cols.size
|
54
|
-
instance = {}
|
55
|
-
(0..cells.size-1).map{|i| instance[HEADINGS[i]] = cells[i] }
|
56
|
-
@instance_types[:details] << instance
|
73
|
+
rows.each do |row|
|
57
74
|
|
58
|
-
|
75
|
+
cells = row.search('td').collect { |td|
|
76
|
+
CGI.unescapeHTML(td.text.to_s.gsub(%r/(\r?\n)+/, ' ').strip.gsub('32-bit or64-bit', '32-bit or 64-bit'))
|
77
|
+
}
|
78
|
+
raise StandardError.new "This row does not have the same number of cells as the table header: #{row.text.to_s.strip}" unless cells.size == cols.size
|
79
|
+
instance = {}
|
80
|
+
(0..cells.size-1).map { |i| instance[cHeadings[i]] = cells[i] }
|
81
|
+
instance_types[:details] << instance
|
59
82
|
end
|
60
|
-
|
83
|
+
instance_types
|
61
84
|
end
|
62
85
|
end
|
63
86
|
end
|