aws 2.7.1 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awsbase/awsbase.rb +32 -29
- metadata +2 -2
data/lib/awsbase/awsbase.rb
CHANGED
@@ -157,13 +157,16 @@ module Aws
|
|
157
157
|
if !@params[:multi_thread].nil? && @params[:connection_mode].nil? # user defined this
|
158
158
|
@params[:connection_mode] = @params[:multi_thread] ? :per_thread : :single
|
159
159
|
end
|
160
|
-
# @params[:multi_thread] ||= defined?(AWS_DAEMON)
|
160
|
+
# @params[:multi_thread] ||= defined?(AWS_DAEMON)
|
161
161
|
@params[:connection_mode] ||= :default
|
162
162
|
@params[:connection_mode] = :per_request if @params[:connection_mode] == :default
|
163
163
|
@logger = @params[:logger]
|
164
164
|
@logger = Rails.logger if !@logger && defined?(Rails) && defined?(Rails.logger)
|
165
165
|
@logger = ::Rails.logger if !@logger && defined?(::Rails.logger)
|
166
|
-
|
166
|
+
if !@logger
|
167
|
+
@logger = Logger.new(STDOUT)
|
168
|
+
@logger.level = Logger::INFO
|
169
|
+
end
|
167
170
|
@logger.debug "New #{self.class.name} using #{@params[:connection_mode].to_s}-connection mode"
|
168
171
|
@error_handler = nil
|
169
172
|
@cache = {}
|
@@ -189,13 +192,13 @@ module Aws
|
|
189
192
|
|
190
193
|
# FROM SDB
|
191
194
|
def generate_request2(aws_access_key, aws_secret_key, action, api_version, lib_params, user_params={}, options={}) #:nodoc:
|
192
|
-
|
195
|
+
# remove empty params from request
|
193
196
|
user_params.delete_if { |key, value| value.nil? }
|
194
197
|
# user_params.each_pair do |k,v|
|
195
198
|
# user_params[k] = v.force_encoding("UTF-8")
|
196
199
|
# end
|
197
|
-
|
198
|
-
|
200
|
+
#params_string = params.to_a.collect{|key,val| key + "=#{CGI::escape(val.to_s)}" }.join("&")
|
201
|
+
# prepare service data
|
199
202
|
service = lib_params[:service]
|
200
203
|
|
201
204
|
now = Time.now.getutc
|
@@ -232,7 +235,7 @@ module Aws
|
|
232
235
|
headers.each_pair do |k, v|
|
233
236
|
request[k] = v
|
234
237
|
end
|
235
|
-
# puts "header=" + request['X-Amzn-Authorization']
|
238
|
+
# puts "header=" + request['X-Amzn-Authorization']
|
236
239
|
|
237
240
|
#puts "\n\n --------------- QUERY REQUEST TO AWS -------------- \n\n"
|
238
241
|
#puts "#{@params[:service]}?#{service_params}\n\n"
|
@@ -259,12 +262,12 @@ module Aws
|
|
259
262
|
http_conn = nil
|
260
263
|
conn_mode = lib_params[:connection_mode]
|
261
264
|
|
262
|
-
params = {
|
263
|
-
|
265
|
+
params = {:exception => AwsError, :logger => logger}
|
266
|
+
|
264
267
|
# Adds all parameters accepted by Rightscale::HttpConnection#new
|
265
|
-
[
|
266
|
-
|
267
|
-
|
268
|
+
[:user_agent, :ca_file, :http_connection_retry_count,
|
269
|
+
:http_connection_open_timeout, :http_connection_read_timeout,
|
270
|
+
:http_connection_retry_delay
|
268
271
|
].each do |key|
|
269
272
|
params[key] = lib_params[key] if lib_params.has_key?(key)
|
270
273
|
end
|
@@ -353,7 +356,7 @@ module Aws
|
|
353
356
|
|
354
357
|
response = connection.request(request)
|
355
358
|
# puts "response=" + response.body
|
356
|
-
# benchblock.service.add!{ response = connection.request(request) }
|
359
|
+
# benchblock.service.add!{ response = connection.request(request) }
|
357
360
|
# check response for errors...
|
358
361
|
@last_response = response
|
359
362
|
if response.is_a?(Net::HTTPSuccess)
|
@@ -361,20 +364,20 @@ module Aws
|
|
361
364
|
# benchblock.xml.add! { parser.parse(response) }
|
362
365
|
# return parser.result
|
363
366
|
force_array = params[:force_array] || false
|
364
|
-
|
365
|
-
xml_simple_options = {"KeyToSymbol"=>false, 'ForceArray' => false}
|
367
|
+
# Force_array and group_tags don't work nice together so going to force array manually
|
368
|
+
xml_simple_options = {"KeyToSymbol" => false, 'ForceArray' => false}
|
366
369
|
xml_simple_options["GroupTags"] = params[:group_tags] if params[:group_tags]
|
367
370
|
|
368
371
|
# { 'GroupTags' => { 'searchpath' => 'dir' }
|
369
372
|
# 'ForceArray' => %r(_list$)
|
370
373
|
parsed = XmlSimple.xml_in(response.body, xml_simple_options)
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
374
|
+
# todo: we may want to consider stripping off a couple of layers when doing this, for instance:
|
375
|
+
# <DescribeDBInstancesResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
|
376
|
+
# <DescribeDBInstancesResult>
|
377
|
+
# <DBInstances>
|
378
|
+
# <DBInstance>....
|
379
|
+
# Strip it off and only return an array or hash of <DBInstance>'s (hash by identifier).
|
380
|
+
# would have to be able to make the RequestId available somehow though, perhaps some special array subclass which included that?
|
378
381
|
unless force_array.is_a? Array
|
379
382
|
force_array = []
|
380
383
|
end
|
@@ -389,7 +392,7 @@ module Aws
|
|
389
392
|
if level_hash.is_a? Hash # When there's only one
|
390
393
|
ret << level_hash
|
391
394
|
else # should be array
|
392
|
-
# puts 'level_hash=' + level_hash.inspect
|
395
|
+
# puts 'level_hash=' + level_hash.inspect
|
393
396
|
level_hash.each do |x|
|
394
397
|
ret << x
|
395
398
|
end
|
@@ -492,7 +495,7 @@ module Aws
|
|
492
495
|
(@cache[function.to_sym] ||= {}).merge!(hash) if caching?
|
493
496
|
end
|
494
497
|
|
495
|
-
def on_exception(options={:raise=>true, :log=>true}) # :nodoc:
|
498
|
+
def on_exception(options={:raise => true, :log => true}) # :nodoc:
|
496
499
|
raise if $!.is_a?(AwsNoChange)
|
497
500
|
AwsError::on_aws_exception(self, options)
|
498
501
|
end
|
@@ -578,11 +581,11 @@ module Aws
|
|
578
581
|
end
|
579
582
|
|
580
583
|
def request_cache_or_info(method, link, parser_class, benchblock, use_cache=true) #:nodoc:
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
584
|
+
# We do not want to break the logic of parsing hence will use a dummy parser to process all the standard
|
585
|
+
# steps (errors checking etc). The dummy parser does nothig - just returns back the params it received.
|
586
|
+
# If the caching is enabled and hit then throw AwsNoChange.
|
587
|
+
# P.S. caching works for the whole images list only! (when the list param is blank)
|
588
|
+
# check cache
|
586
589
|
response, params = request_info(link, RightDummyParser.new)
|
587
590
|
cache_hits?(method.to_sym, response.body) if use_cache
|
588
591
|
parser = parser_class.new(:logger => @logger)
|
@@ -600,7 +603,7 @@ module Aws
|
|
600
603
|
|
601
604
|
def hash_params(prefix, list) #:nodoc:
|
602
605
|
groups = {}
|
603
|
-
list.each_index { |i| groups.update("#{prefix}.#{i+1}"=>list[i]) } if list
|
606
|
+
list.each_index { |i| groups.update("#{prefix}.#{i+1}" => list[i]) } if list
|
604
607
|
return groups
|
605
608
|
end
|
606
609
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-02-
|
14
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: uuidtools
|