aws 2.3.28 → 2.3.29

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,24 +6,18 @@ Brought to you by: [![Appoxy](http://www.simpledeployr.com/images/global/appoxy-
6
6
 
7
7
  ## Discussion Group
8
8
 
9
- http://groups.google.com/group/ruby-aws
10
-
11
- ## Issue Tracker
12
-
13
- http://appoxy.lighthouseapp.com/projects/38441-aws/overview
9
+ [http://groups.google.com/group/ruby-aws](http://groups.google.com/group/ruby-aws)
14
10
 
15
11
  ## Documentation
16
12
 
17
- http://rdoc.info/projects/appoxy/aws
13
+ [http://rubydoc.info/gems/aws/](http://rubydoc.info/gems/aws/)
18
14
 
19
15
  ## Appoxy Amazon Web Services Ruby Gems
20
16
 
21
- Published by Appoxy LLC, under the MIT License. Special thanks to RightScale from which this project is forked.
17
+ Published by [Appoxy LLC](http://www.appoxy.com), under the MIT License. Special thanks to RightScale from which this project is forked.
22
18
 
23
19
  ## INSTALL:
24
20
 
25
- THEN (you should have http://gemcutter.org in your sources and it MUST be above rubyforge.org):
26
-
27
21
  gem install aws
28
22
 
29
23
 
@@ -70,6 +64,7 @@ The RightScale AWS gems comprise:
70
64
  ## THREADING:
71
65
 
72
66
  All AWS interfaces offer three threading options:
67
+
73
68
  1. Use a single persistent HTTP connection per process. :single
74
69
  2. Use a persistent HTTP connection per Ruby thread. :per_thread
75
70
  3. Open a new connection for each request. :per_request
@@ -81,6 +76,7 @@ persistent HTTP connection open to avoid paying connection
81
76
  overhead on every request. However, if you have multiple concurrent
82
77
  threads, you may want or need an HTTP connection per thread to enable
83
78
  concurrent requests to AWS. The way this plays out in practice is:
79
+
84
80
  1. If you have a non-multithreaded Ruby program, use the non-multithreaded setting.
85
81
  2. If you have a multi-threaded Ruby program, use the multithreaded setting to enable
86
82
  concurrent requests to S3 (or SQS, or SDB, or EC2).
@@ -91,7 +87,7 @@ concurrent requests to AWS. The way this plays out in practice is:
91
87
  Note that due to limitations in the I/O of the Ruby interpreter you
92
88
  may not get the degree of parallelism you may expect with the multi-threaded setting.
93
89
 
94
- By default, EC2/S3/SQS/SDB/ACF interface instances are created in single-threaded mode. Set
90
+ By default, EC2/S3/SQS/SDB/ACF interface instances are created in per_request mode. Set
95
91
  params[:connection_mode] to :per_thread in the initialization arguments to use
96
92
  multithreaded mode.
97
93
 
@@ -155,10 +151,12 @@ multithreaded mode.
155
151
 
156
152
  ## REQUIREMENTS:
157
153
 
158
- Aws requires REXML and the right_http_connection gem.
154
+ Aws requires REXML and the http_connection gem.
159
155
  If libxml and its Ruby bindings (distributed in the libxml-ruby gem) are
160
156
  present, Aws can be configured to use them:
161
- Aws::AwsParser.xml_lib = 'libxml'
157
+
158
+ Aws::AwsParser.xml_lib = 'libxml'
159
+
162
160
  Any error with the libxml installation will result in Aws failing-safe to
163
161
  REXML parsing.
164
162
 
@@ -141,9 +141,8 @@ module Aws
141
141
  # Sends request to Amazon and parses the response.
142
142
  # Raises AwsError if any banana happened.
143
143
  def request_info(request, parser, options={}, &block) # :nodoc:
144
- thread = @params[:multi_thread] ? Thread.current : Thread.main
145
- thread[:acf_connection] ||= Rightscale::HttpConnection.new(:exception => Aws::AwsError, :logger => @logger)
146
- request_info_impl(thread[:acf_connection], @@bench, request, parser, options, &block)
144
+ conn = get_conn(:acf_connection, @params, @logger)
145
+ request_info_impl(conn, @@bench, request, parser, options, &block)
147
146
  end
148
147
 
149
148
  #-----------------------------------------------------------------
@@ -418,12 +418,20 @@ module Aws
418
418
  # return conn
419
419
  http_conn = nil
420
420
  conn_mode = lib_params[:connection_mode]
421
+
422
+ # Slice all parameters accepted by Rightscale::HttpConnection#new
423
+ params = lib_params.slice(
424
+ :user_agent, :ca_file, :http_connection_retry_count, :http_connection_open_timeout,
425
+ :http_connection_read_timeout, :http_connection_retry_delay
426
+ )
427
+ params.merge!(:exception => AwsError, :logger => logger)
428
+
421
429
  if conn_mode == :per_request
422
- http_conn = Rightscale::HttpConnection.new(:exception => AwsError, :logger => logger)
430
+ http_conn = Rightscale::HttpConnection.new(params)
423
431
 
424
432
  elsif conn_mode == :per_thread || conn_mode == :single
425
433
  thread = conn_mode == :per_thread ? Thread.current : Thread.main
426
- thread[connection_name] ||= Rightscale::HttpConnection.new(:exception => AwsError, :logger => logger)
434
+ thread[connection_name] ||= Rightscale::HttpConnection.new(params)
427
435
  http_conn = thread[connection_name]
428
436
  # ret = request_info_impl(http_conn, bench, request, parser, &block)
429
437
  end
@@ -46,7 +46,14 @@ unless defined? ActiveSupport
46
46
 
47
47
  constant = Object
48
48
  names.each do |name|
49
- constant = constant.const_get(name, false) || constant.const_missing(name)
49
+ # constant = constant.const_get(name, false) || constant.const_missing(name)
50
+ if Module.method(:const_get).arity == 1
51
+ # ruby 1.8
52
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
53
+ else
54
+ # ruby 1.9
55
+ constant = constant.const_get(name, false) || constant.const_missing(name)
56
+ end
50
57
  end
51
58
  constant
52
59
  end
@@ -99,6 +106,26 @@ unless defined? ActiveSupport
99
106
  options
100
107
  end
101
108
  end
109
+
110
+ # Slice a hash to include only the given keys. This is useful for
111
+ # limiting an options hash to valid keys before passing to a method:
112
+ #
113
+ # def search(criteria = {})
114
+ # assert_valid_keys(:mass, :velocity, :time)
115
+ # end
116
+ #
117
+ # search(options.slice(:mass, :velocity, :time))
118
+ #
119
+ # If you have an array of keys you want to limit to, you should splat them:
120
+ #
121
+ # valid_keys = [:mass, :velocity, :time]
122
+ # search(options.slice(*valid_keys))
123
+ def slice(*keys)
124
+ keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
125
+ hash = self.class.new
126
+ keys.each { |k| hash[k] = self[k] if has_key?(k) }
127
+ hash
128
+ end
102
129
  end
103
130
 
104
131
  class String #:nodoc:
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  #
2
3
  # Copyright (c) 2007-2008 RightScale Inc
3
4
  #
@@ -161,9 +162,8 @@ module Aws
161
162
  # Sends request to Amazon and parses the response
162
163
  # Raises AwsError if any banana happened
163
164
  def request_info(request, parser, options={}) #:nodoc:
164
- thread = @params[:multi_thread] ? Thread.current : Thread.main
165
- thread[:ec2_connection] ||= Rightscale::HttpConnection.new(:exception => AwsError, :logger => @logger)
166
- request_info_impl(thread[:ec2_connection], @@bench, request, parser, options)
165
+ conn = get_conn(:ec2_connection, @params, @logger)
166
+ request_info_impl(conn, @@bench, request, parser, options)
167
167
  end
168
168
 
169
169
  def hash_params(prefix, list) #:nodoc:
@@ -1519,7 +1519,8 @@ module Aws
1519
1519
  :ami_launch_index => '',
1520
1520
  :ssh_key_name => '',
1521
1521
  :aws_state => '',
1522
- :aws_product_codes => [] }
1522
+ :aws_product_codes => [],
1523
+ :tags => {} }
1523
1524
  end
1524
1525
  end
1525
1526
  def tagend(name)
@@ -1546,17 +1547,21 @@ module Aws
1546
1547
  when 'platform' then @instance[:aws_platform] = @text
1547
1548
  when 'availabilityZone' then @instance[:aws_availability_zone] = @text
1548
1549
  when 'privateIpAddress' then @instance[:aws_private_ip_address] = @text
1550
+ when 'key' then @tag_key = @text
1551
+ when 'value' then @tag_value = @text
1549
1552
  when 'state'
1550
1553
  if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/monitoring' || # DescribeInstances property
1551
1554
  @xmlpath == 'RunInstancesResponse/instancesSet/item/monitoring' # RunInstances property
1552
1555
  @instance[:monitoring_state] = @text
1553
1556
  end
1554
1557
  when 'item'
1555
- if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
1556
- @xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
1557
- @reservation[:instances_set] << @instance
1558
+ if @xmlpath=='DescribeInstancesResponse/reservationSet/item/instancesSet/item/tagSet' # Tags
1559
+ @instance[:tags][@tag_key] = @tag_value
1560
+ elsif @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
1561
+ @xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
1562
+ @reservation[:instances_set] << @instance
1558
1563
  elsif @xmlpath=='DescribeInstancesResponse/reservationSet' # DescribeInstances property
1559
- @result << @reservation
1564
+ @result << @reservation
1560
1565
  end
1561
1566
  when 'RunInstancesResponse' then @result << @reservation # RunInstances property
1562
1567
  end
@@ -80,9 +80,8 @@ module Aws
80
80
  # Sends request to Amazon and parses the response
81
81
  # Raises AwsError if any banana happened
82
82
  def request_info(request, parser, options={})
83
- thread = @params[:multi_thread] ? Thread.current : Thread.main
84
- thread[:elb_connection] ||= Rightscale::HttpConnection.new(:exception => Aws::AwsError, :logger => @logger)
85
- request_info_impl(thread[:elb_connection], @@bench, request, parser, options)
83
+ conn = get_conn(:mon_connection, @params, @logger)
84
+ request_info_impl(conn, @@bench, request, parser, options)
86
85
  end
87
86
 
88
87
  #-----------------------------------------------------------------
@@ -105,6 +105,7 @@ module Aws
105
105
  out_string << path.gsub(/\?.*$/, '')
106
106
  # ...unless there is an acl or torrent parameter
107
107
  out_string << '?acl' if path[/[&?]acl($|&|=)/]
108
+ out_string << '?policy' if path[/[&?]policy($|&|=)/]
108
109
  out_string << '?torrent' if path[/[&?]torrent($|&|=)/]
109
110
  out_string << '?location' if path[/[&?]location($|&|=)/]
110
111
  out_string << '?logging' if path[/[&?]logging($|&|=)/] # this one is beta, no support for now
@@ -769,6 +770,20 @@ module Aws
769
770
  on_exception
770
771
  end
771
772
 
773
+ def get_bucket_policy(bucket)
774
+ req_hash = generate_rest_request('GET', {:url=>"#{bucket}?policy"})
775
+ request_info(req_hash, S3HttpResponseBodyParser.new)
776
+ rescue
777
+ on_exception
778
+ end
779
+
780
+ def put_bucket_policy(bucket, policy)
781
+ key = key.blank? ? '' : "/#{CGI::escape key}"
782
+ req_hash = generate_rest_request('PUT', {:url=>"#{bucket}?policy", :data=>policy})
783
+ request_info(req_hash, S3HttpResponseBodyParser.new)
784
+ rescue
785
+ on_exception
786
+ end
772
787
 
773
788
  # Removes all keys from bucket. Returns +true+ or an exception.
774
789
  #
@@ -360,6 +360,7 @@ module Aws
360
360
  def put_attributes(domain_name, item_name, attributes, replace = false)
361
361
  params = { 'DomainName' => domain_name,
362
362
  'ItemName' => item_name }.merge(pack_attributes(attributes, replace))
363
+ logger.debug 'PUT=' + params.inspect
363
364
  link = generate_request("PutAttributes", params)
364
365
  request_info( link, QSdbSimpleParser.new )
365
366
  rescue Exception
@@ -141,12 +141,10 @@ module Aws
141
141
  # Sends request to Amazon and parses the response
142
142
  # Raises AwsError if any banana happened
143
143
  def request_info(request, parser, options={}) # :nodoc:
144
- thread = @params[:multi_thread] ? Thread.current : Thread.main
145
- thread[:sqs_connection] ||= Rightscale::HttpConnection.new(:exception => AwsError, :logger => @logger)
146
- request_info_impl(thread[:sqs_connection], @@bench, request, parser, options)
144
+ conn = get_conn(:sqs_connection, @params, @logger)
145
+ request_info_impl(conn, @@bench, request, parser, options)
147
146
  end
148
147
 
149
-
150
148
  # Creates a new queue, returning its URI.
151
149
  #
152
150
  # sqs.create_queue('my_awesome_queue') #=> 'http://queue.amazonaws.com/ZZ7XXXYYYBINS/my_awesome_queue'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 3
8
- - 28
9
- version: 2.3.28
8
+ - 29
9
+ version: 2.3.29
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Reeder
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-05 00:00:00 -08:00
19
+ date: 2010-12-13 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency