amazon-pricing 0.1.43 → 0.1.44

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWRkNGE0ZDA5YzQzNWFiNjRjMTVmZWZlYTE2MTg0YWIwNTk4MTNiNQ==
4
+ ZmVmZGI2MDkyMzAzZDUwMmYzMzc0NmE2ZjkxY2JmNjdjNTlkYzg5Yw==
5
5
  data.tar.gz: !binary |-
6
- MWI3OTJkNzY3MDE1NTIzNTZhZjM3NGI2MzUxNjY1ZTg5YWYxOGFkYg==
6
+ YzZiZDJhNDc3ZWIxZWU4ZWQyYjAyM2RmMWQ3OGFmYTAyNTA1NDIyNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTU2MzA2NWJlNGQxNjEzMmYwODU2YzlmNjQ3YzA4ODIwYzkwZDE0MTQyNGVh
10
- NTAyZmM3MDllYzQxMzYyMjBhN2ZkMzI1ZjNlOGYxNTgxMDk5ZDUzNjkzY2Yy
11
- Y2MyNjhjN2IyNDkwNWZlNzZiNTQxZTA0ZTVkODBhODg4YmI5NmM=
9
+ MzQ4YWM0NWM1MjRlMGFjNjFkNTc0ZjFjZWExMjJjYjgzYTJlMDMwM2Y0ZDkw
10
+ MTU1MGQ3MDMyNjI3NDk5YzM3ZjNkOWJjNzdhYTJkY2I3YTk5ODZjODRiMjIz
11
+ YzI1ZDYwMDk2M2M3ZDQ4ODg2NjdjN2VlZTZmNjQ1MzIxYTlmMTQ=
12
12
  data.tar.gz: !binary |-
13
- MzQ3YjZhNWE3ZWU3MjVmZTdiYmI4ODA2Y2VmZjllNWQwOWJjODc0YjRjOGEy
14
- N2Y5N2MwMDYzM2M3MDIzODg1ZGE4OGY1MzUzYjhiMDcyZDFiM2JhYmMzNDlm
15
- NjA4YWQ1YTM5ZjdkMTc1MmVjNmRjYjJmODRlMTA1MWM4YTQ4M2Y=
13
+ ZGJlZGM0NzdiMDY5Yjg1MjllN2M5NmY3OTQzZjE2ZTE3NWEyNjBiNDUyY2M5
14
+ OGJhOTcxOWM4MzcwMzc2MzA4Mzc5ZWQ1ZjE3OGIyOTRiM2UyNDQ2MjkzMjky
15
+ MDJkMDY4MTA0NzFhOGFmYzViNjJiZTFmOTEzZjNmNmE5MzllOGM=
@@ -8,5 +8,5 @@
8
8
  # Home:: http://github.com/CloudHealth/amazon-pricing
9
9
  #++
10
10
  module AwsPricing
11
- VERSION = '0.1.43'
11
+ VERSION = '0.1.44'
12
12
  end
@@ -98,130 +98,4 @@ module AwsPricing
98
98
  end
99
99
 
100
100
 
101
- class GovCloudEc2PriceList < PriceList
102
- GOV_CLOUD_URL = "http://aws.amazon.com/govcloud-us/pricing/ec2/"
103
- GOV_CLOUD_EBS_URL = "http://aws.amazon.com/govcloud-us/pricing/ebs/"
104
-
105
- def initialize
106
- @_regions = {}
107
- @_regions["us-gov-west-1"] = Region.new("us-gov-west-1")
108
- InstanceType.populate_lookups
109
- get_ec2_instance_pricing
110
- fetch_ec2_ebs_pricing
111
- end
112
-
113
- protected
114
-
115
- def get_ec2_instance_pricing
116
-
117
- client = Mechanize.new
118
- page = client.get(GOV_CLOUD_URL)
119
- tables = page.search("//div[@class='aws-table section']")
120
- create_ondemand_instances(get_rows(tables[0]))
121
- create_ondemand_instances(get_rows(tables[1]))
122
-
123
- for i in 2..7
124
- create_reserved_instances(get_rows(tables[i]), :light)
125
- end
126
- for i in 8..13
127
- create_reserved_instances(get_rows(tables[i]), :medium)
128
- end
129
- for i in 14..19
130
- create_reserved_instances(get_rows(tables[i]), :heavy)
131
- end
132
-
133
- end
134
-
135
- # e.g. [["Prices / Hour", "Amazon Linux", "RHEL", "SLES"], ["m1.small", "$0.053", "$0.083", "$0.083"]]
136
- def create_ondemand_instances(rows)
137
- header = rows[0]
138
- @_regions.values.each do |region|
139
-
140
- rows.slice(1, rows.size).each do |row|
141
- api_name = row[0]
142
- instance_type = region.get_ec2_instance_type(api_name)
143
- if instance_type.nil?
144
- api_name, name = Ec2InstanceType.get_name(nil, row[0], false)
145
- instance_type = region.add_or_update_ec2_instance_type(api_name, name)
146
- end
147
- instance_type.update_pricing2(get_os(header[1]), :ondemand, row[1])
148
- instance_type.update_pricing2(get_os(header[2]), :ondemand, row[2])
149
- instance_type.update_pricing2(get_os(header[3]), :ondemand, row[3])
150
- end
151
- end
152
- end
153
-
154
- # e.g. [["RHEL", "1 yr Term Upfront", "1 yr TermHourly", "3 yr TermUpfront", "3 yr Term Hourly"], ["m1.small", "$68.00", "$0.099", "$105.00", "$0.098"]]
155
- def create_reserved_instances(rows, res_type)
156
- header = rows[0]
157
- operating_system = get_os(header[0])
158
- @_regions.values.each do |region|
159
-
160
- rows.slice(1, rows.size).each do |row|
161
- api_name = row[0]
162
- instance_type = region.get_instance_type(api_name)
163
- if instance_type.nil?
164
- api_name, name = Ec2InstanceType.get_name(nil, row[0], true)
165
- instance_type = region.add_or_update_ec2_instance_type(api_name, name)
166
- end
167
- instance_type.update_pricing2(operating_system, res_type, nil, row[1], row[3], row[2], row[4])
168
- end
169
- end
170
- end
171
-
172
- def fetch_ec2_ebs_pricing
173
- client = Mechanize.new
174
- page = client.get(GOV_CLOUD_EBS_URL)
175
- ebs_costs = page.search("//div[@class='text section']//li")
176
- @_regions.values.each do |region|
177
- region.ebs_price = EbsPrice.new(region)
178
- region.ebs_price.preferred_per_gb = get_ebs_price(ebs_costs[1])
179
- region.ebs_price.preferred_per_iops = get_ebs_price(ebs_costs[2])
180
- region.ebs_price.standard_per_gb = get_ebs_price(ebs_costs[3])
181
- region.ebs_price.standard_per_million_io = get_ebs_price(ebs_costs[4])
182
- region.ebs_price.ssd_per_gb = nil
183
- region.ebs_price.s3_snaps_per_gb = get_ebs_price(ebs_costs[5])
184
- end
185
-
186
- end
187
-
188
- # e.g. $0.065 per GB-Month of provisioned storage
189
- def get_ebs_price(xml_element)
190
- tokens = xml_element.text.split(" ")
191
- tokens[0].gsub("$", "").to_f
192
- end
193
-
194
- def get_os(val)
195
- case val
196
- when "Amazon Linux"
197
- :linux
198
- when "RHEL"
199
- :rhel
200
- when "SLES"
201
- :sles
202
- when "Windows"
203
- :mswin
204
- when "Windows SQL Server Web", "Windows SQL Server Web Edition"
205
- :mswinSQL
206
- when "Windows SQL Server Standard", "Windows SQL Server Standard Edition"
207
- :mswinSQLWeb
208
- else
209
- raise "Unable to identify operating system '#{val}'"
210
- end
211
- end
212
-
213
- def get_rows(html_table)
214
- rows = []
215
- html_table.search(".//tr").each do |tr|
216
- row = []
217
- tr.search(".//td").each do |td|
218
- row << td.inner_text.strip.sub("\n", " ").sub(" ", " ")
219
- end
220
- next if row.size == 1
221
- rows << row unless row.empty?
222
- end
223
- rows
224
- end
225
- end
226
-
227
101
  end
@@ -1,4 +1,132 @@
1
1
  module AwsPricing
2
+
3
+ class GovCloudEc2PriceList < PriceList
4
+ GOV_CLOUD_URL = "http://aws.amazon.com/govcloud-us/pricing/ec2/"
5
+ GOV_CLOUD_EBS_URL = "http://aws.amazon.com/govcloud-us/pricing/ebs/"
6
+
7
+ def initialize
8
+ @_regions = {}
9
+ @_regions["us-gov-west-1"] = Region.new("us-gov-west-1")
10
+ InstanceType.populate_lookups
11
+ get_ec2_instance_pricing
12
+ fetch_ec2_ebs_pricing
13
+ end
14
+
15
+ protected
16
+
17
+ def get_ec2_instance_pricing
18
+
19
+ client = Mechanize.new
20
+ page = client.get(GOV_CLOUD_URL)
21
+ tables = page.search("//div[@class='aws-table ']")
22
+ create_ondemand_instances(get_rows(tables[0]))
23
+ create_ondemand_instances(get_rows(tables[1]))
24
+
25
+ for i in 2..7
26
+ create_reserved_instances(get_rows(tables[i]), :light)
27
+ end
28
+ for i in 8..13
29
+ create_reserved_instances(get_rows(tables[i]), :medium)
30
+ end
31
+ for i in 14..19
32
+ create_reserved_instances(get_rows(tables[i]), :heavy)
33
+ end
34
+
35
+ end
36
+
37
+ # e.g. [["Prices / Hour", "Amazon Linux", "RHEL", "SLES"], ["m1.small", "$0.053", "$0.083", "$0.083"]]
38
+ def create_ondemand_instances(rows)
39
+ header = rows[0]
40
+ @_regions.values.each do |region|
41
+
42
+ rows.slice(1, rows.size).each do |row|
43
+ api_name = row[0]
44
+ instance_type = region.get_ec2_instance_type(api_name)
45
+ if instance_type.nil?
46
+ api_name, name = Ec2InstanceType.get_name(nil, row[0], false)
47
+ instance_type = region.add_or_update_ec2_instance_type(api_name, name)
48
+ end
49
+ instance_type.update_pricing2(get_os(header[1]), :ondemand, row[1])
50
+ instance_type.update_pricing2(get_os(header[2]), :ondemand, row[2])
51
+ instance_type.update_pricing2(get_os(header[3]), :ondemand, row[3])
52
+ end
53
+ end
54
+ end
55
+
56
+ # e.g. [["RHEL", "1 yr Term Upfront", "1 yr TermHourly", "3 yr TermUpfront", "3 yr Term Hourly"], ["m1.small", "$68.00", "$0.099", "$105.00", "$0.098"]]
57
+ def create_reserved_instances(rows, res_type)
58
+ header = rows[0]
59
+ operating_system = get_os(header[0])
60
+ @_regions.values.each do |region|
61
+
62
+ rows.slice(1, rows.size).each do |row|
63
+ api_name = row[0]
64
+ instance_type = region.get_instance_type(api_name)
65
+ if instance_type.nil?
66
+ api_name, name = Ec2InstanceType.get_name(nil, row[0], true)
67
+ instance_type = region.add_or_update_ec2_instance_type(api_name, name)
68
+ end
69
+ instance_type.update_pricing2(operating_system, res_type, nil, row[1], row[3], row[2], row[4])
70
+ end
71
+ end
72
+ end
73
+
74
+ def fetch_ec2_ebs_pricing
75
+ client = Mechanize.new
76
+ page = client.get(GOV_CLOUD_EBS_URL)
77
+ ebs_costs = page.search("//div[@class='text-box section']//li")
78
+ @_regions.values.each do |region|
79
+ region.ebs_price = EbsPrice.new(region)
80
+ region.ebs_price.preferred_per_gb = get_ebs_price(ebs_costs[1])
81
+ region.ebs_price.preferred_per_iops = get_ebs_price(ebs_costs[2])
82
+ region.ebs_price.standard_per_gb = get_ebs_price(ebs_costs[3])
83
+ region.ebs_price.standard_per_million_io = get_ebs_price(ebs_costs[4])
84
+ region.ebs_price.ssd_per_gb = nil
85
+ region.ebs_price.s3_snaps_per_gb = get_ebs_price(ebs_costs[5])
86
+ end
87
+
88
+ end
89
+
90
+ # e.g. $0.065 per GB-Month of provisioned storage
91
+ def get_ebs_price(xml_element)
92
+ tokens = xml_element.text.split(" ")
93
+ tokens[0].gsub("$", "").to_f
94
+ end
95
+
96
+ def get_os(val)
97
+ case val
98
+ when "Amazon Linux"
99
+ :linux
100
+ when "RHEL"
101
+ :rhel
102
+ when "SLES"
103
+ :sles
104
+ when "Windows"
105
+ :mswin
106
+ when "Windows SQL Server Web", "Windows SQL Server Web Edition"
107
+ :mswinSQL
108
+ when "Windows SQL Server Standard", "Windows SQL Server Standard Edition"
109
+ :mswinSQLWeb
110
+ else
111
+ raise "Unable to identify operating system '#{val}'"
112
+ end
113
+ end
114
+
115
+ def get_rows(html_table)
116
+ rows = []
117
+ html_table.search(".//tr").each do |tr|
118
+ row = []
119
+ tr.search(".//td").each do |td|
120
+ row << td.inner_text.strip.sub("\n", " ").sub(" ", " ")
121
+ end
122
+ next if row.size == 1
123
+ rows << row unless row.empty?
124
+ end
125
+ rows
126
+ end
127
+ end
128
+
129
+
2
130
  class GovCloudRdsPriceList < PriceList
3
131
  GOV_CLOUD_URL = "http://aws.amazon.com/govcloud-us/pricing/rds/"
4
132
 
@@ -17,7 +145,7 @@ module AwsPricing
17
145
 
18
146
  client = Mechanize.new
19
147
  page = client.get(GOV_CLOUD_URL)
20
- tables = page.search("//div[@class='aws-table section']")
148
+ tables = page.search("//div[@class='aws-table ']")
21
149
 
22
150
  # Mysql
23
151
  create_ondemand_instances(:mysql, :ondemand, false, false, get_rows(tables[0]))
@@ -28,7 +28,7 @@ module AwsPricing
28
28
 
29
29
 
30
30
  def is_multi_az?(type)
31
- return true if type.match("multiAZ")
31
+ return true if type.upcase.match("MULTI-AZ")
32
32
  false
33
33
  end
34
34
 
@@ -44,11 +44,12 @@ module AwsPricing
44
44
  #
45
45
  # to find out the byol type
46
46
  is_byol = is_byol? dp_type
47
+ is_multi_az = dp_type.upcase.include?("MULTIAZ")
47
48
 
48
49
  if [:mysql, :postgresql, :oracle].include? db
49
- fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{dp_type}-deployments.min.js",:ondemand, db_type, is_byol)
50
+ fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/pricing-#{dp_type}-deployments.min.js",:ondemand, db_type, is_byol, is_multi_az)
50
51
  elsif db == :sqlserver
51
- fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/sqlserver-#{dp_type}-ondemand.min.js",:ondemand, db_type, is_byol)
52
+ fetch_on_demand_rds_instance_pricing(RDS_BASE_URL+"#{db}/sqlserver-#{dp_type}-ondemand.min.js",:ondemand, db_type, is_byol, is_multi_az)
52
53
  end
53
54
  end
54
55
  }
@@ -82,7 +83,7 @@ module AwsPricing
82
83
  end
83
84
  end
84
85
 
85
- def fetch_on_demand_rds_instance_pricing(url, type_of_rds_instance, db_type, is_byol)
86
+ def fetch_on_demand_rds_instance_pricing(url, type_of_rds_instance, db_type, is_byol, is_multi_az = false)
86
87
  res = PriceList.fetch_url(url)
87
88
  res['config']['regions'].each do |reg|
88
89
  region_name = reg['region']
@@ -92,11 +93,11 @@ module AwsPricing
92
93
  begin
93
94
  #
94
95
  # this is special case URL, it is oracle - multiAZ type of deployment but it doesn't have mutliAZ attributes in json.
95
- if url == "http://aws.amazon.com/rds/pricing/oracle/pricing-li-multiAZ-deployments.min.js"
96
- is_multi_az = true
97
- else
98
- is_multi_az = is_multi_az? type["name"]
99
- end
96
+ #if url == "http://aws.amazon.com/rds/pricing/oracle/pricing-li-multiAZ-deployments.min.js"
97
+ # is_multi_az = true
98
+ #else
99
+ # is_multi_az = is_multi_az? type["name"]
100
+ #end
100
101
  api_name, name = RdsInstanceType.get_name(type["name"], tier["name"], type_of_rds_instance != :ondemand)
101
102
 
102
103
  instance_type = region.add_or_update_rds_instance_type(api_name, name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-pricing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.43
4
+ version: 0.1.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Kinsella
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby library for retrieving pricing for Amazon Web Services
14
14
  email: