Permalink
Browse files

Merge branch 'master' of github.com:appoxy/aws

  • Loading branch information...
2 parents bf1ad16 + 6912c10 commit e0fd9b37c486f2d926f3bd4351fa6f4d95821a74 @treeder treeder committed Dec 21, 2010
View
@@ -6,24 +6,18 @@ Brought to you by: [![Appoxy](http://www.simpledeployr.com/images/global/appoxy-
## Discussion Group
-http://groups.google.com/group/ruby-aws
-
-## Issue Tracker
-
-http://appoxy.lighthouseapp.com/projects/38441-aws/overview
+[http://groups.google.com/group/ruby-aws](http://groups.google.com/group/ruby-aws)
## Documentation
-http://rdoc.info/projects/appoxy/aws
+[http://rubydoc.info/gems/aws/](http://rubydoc.info/gems/aws/)
## Appoxy Amazon Web Services Ruby Gems
-Published by Appoxy LLC, under the MIT License. Special thanks to RightScale from which this project is forked.
+Published by [Appoxy LLC](http://www.appoxy.com), under the MIT License. Special thanks to RightScale from which this project is forked.
## INSTALL:
-THEN (you should have http://gemcutter.org in your sources and it MUST be above rubyforge.org):
-
gem install aws
@@ -70,6 +64,7 @@ The RightScale AWS gems comprise:
## THREADING:
All AWS interfaces offer three threading options:
+
1. Use a single persistent HTTP connection per process. :single
2. Use a persistent HTTP connection per Ruby thread. :per_thread
3. Open a new connection for each request. :per_request
@@ -81,6 +76,7 @@ persistent HTTP connection open to avoid paying connection
overhead on every request. However, if you have multiple concurrent
threads, you may want or need an HTTP connection per thread to enable
concurrent requests to AWS. The way this plays out in practice is:
+
1. If you have a non-multithreaded Ruby program, use the non-multithreaded setting.
2. If you have a multi-threaded Ruby program, use the multithreaded setting to enable
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:
Note that due to limitations in the I/O of the Ruby interpreter you
may not get the degree of parallelism you may expect with the multi-threaded setting.
-By default, EC2/S3/SQS/SDB/ACF interface instances are created in single-threaded mode. Set
+By default, EC2/S3/SQS/SDB/ACF interface instances are created in per_request mode. Set
params[:connection_mode] to :per_thread in the initialization arguments to use
multithreaded mode.
@@ -155,10 +151,12 @@ multithreaded mode.
## REQUIREMENTS:
-Aws requires REXML and the right_http_connection gem.
+Aws requires REXML and the http_connection gem.
If libxml and its Ruby bindings (distributed in the libxml-ruby gem) are
present, Aws can be configured to use them:
- Aws::AwsParser.xml_lib = 'libxml'
+
+ Aws::AwsParser.xml_lib = 'libxml'
+
Any error with the libxml installation will result in Aws failing-safe to
REXML parsing.
View
@@ -1,5 +1,5 @@
---
:major: 2
:minor: 3
-:patch: 28
+:patch: 32
:build:
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{aws}
- s.version = "2.3.28"
+ s.version = "2.3.32"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Travis Reeder", "Chad Arimura", "RightScale"]
- s.date = %q{2010-12-05}
+ s.date = %q{2010-12-19}
s.description = %q{AWS Ruby Library for interfacing with Amazon Web Services.}
s.email = %q{travis@appoxy.com}
s.extra_rdoc_files = [
@@ -141,9 +141,8 @@ def generate_request(method, path, body=nil, headers={}) # :nodoc:
# Sends request to Amazon and parses the response.
# Raises AwsError if any banana happened.
def request_info(request, parser, options={}, &block) # :nodoc:
- thread = @params[:multi_thread] ? Thread.current : Thread.main
- thread[:acf_connection] ||= Rightscale::HttpConnection.new(:exception => Aws::AwsError, :logger => @logger)
- request_info_impl(thread[:acf_connection], @@bench, request, parser, options, &block)
+ conn = get_conn(:acf_connection, @params, @logger)
+ request_info_impl(conn, @@bench, request, parser, options, &block)
end
#-----------------------------------------------------------------
@@ -418,12 +418,20 @@ def get_conn(connection_name, lib_params, logger)
# return conn
http_conn = nil
conn_mode = lib_params[:connection_mode]
+
+ # Slice all parameters accepted by Rightscale::HttpConnection#new
+ params = lib_params.slice(
+ :user_agent, :ca_file, :http_connection_retry_count, :http_connection_open_timeout,
+ :http_connection_read_timeout, :http_connection_retry_delay
+ )
+ params.merge!(:exception => AwsError, :logger => logger)
+
if conn_mode == :per_request
- http_conn = Rightscale::HttpConnection.new(:exception => AwsError, :logger => logger)
+ http_conn = Rightscale::HttpConnection.new(params)
elsif conn_mode == :per_thread || conn_mode == :single
thread = conn_mode == :per_thread ? Thread.current : Thread.main
- thread[connection_name] ||= Rightscale::HttpConnection.new(:exception => AwsError, :logger => logger)
+ thread[connection_name] ||= Rightscale::HttpConnection.new(params)
http_conn = thread[connection_name]
# ret = request_info_impl(http_conn, bench, request, parser, &block)
end
View
@@ -46,7 +46,14 @@ def constantize()
constant = Object
names.each do |name|
- constant = constant.const_get(name, false) || constant.const_missing(name)
+# constant = constant.const_get(name, false) || constant.const_missing(name)
+ if Module.method(:const_get).arity == 1
+ # ruby 1.8
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
+ else
+ # ruby 1.9
+ constant = constant.const_get(name, false) || constant.const_missing(name)
+ end
end
constant
end
@@ -99,6 +106,26 @@ def symbolize_keys
options
end
end
+
+ # Slice a hash to include only the given keys. This is useful for
+ # limiting an options hash to valid keys before passing to a method:
+ #
+ # def search(criteria = {})
+ # assert_valid_keys(:mass, :velocity, :time)
+ # end
+ #
+ # search(options.slice(:mass, :velocity, :time))
+ #
+ # If you have an array of keys you want to limit to, you should splat them:
+ #
+ # valid_keys = [:mass, :velocity, :time]
+ # search(options.slice(*valid_keys))
+ def slice(*keys)
+ keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
+ hash = self.class.new
+ keys.each { |k| hash[k] = self[k] if has_key?(k) }
+ hash
+ end
end
class String #:nodoc:
View
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
#
# Copyright (c) 2007-2008 RightScale Inc
#
@@ -161,9 +162,8 @@ def generate_request(action, params={}) #:nodoc:
# Sends request to Amazon and parses the response
# Raises AwsError if any banana happened
def request_info(request, parser, options={}) #:nodoc:
- thread = @params[:multi_thread] ? Thread.current : Thread.main
- thread[:ec2_connection] ||= Rightscale::HttpConnection.new(:exception => AwsError, :logger => @logger)
- request_info_impl(thread[:ec2_connection], @@bench, request, parser, options)
+ conn = get_conn(:ec2_connection, @params, @logger)
+ request_info_impl(conn, @@bench, request, parser, options)
end
def hash_params(prefix, list) #:nodoc:
@@ -1519,7 +1519,8 @@ def tagstart(name, attributes)
:ami_launch_index => '',
:ssh_key_name => '',
:aws_state => '',
- :aws_product_codes => [] }
+ :aws_product_codes => [],
+ :tags => {} }
end
end
def tagend(name)
@@ -1546,17 +1547,21 @@ def tagend(name)
when 'platform' then @instance[:aws_platform] = @text
when 'availabilityZone' then @instance[:aws_availability_zone] = @text
when 'privateIpAddress' then @instance[:aws_private_ip_address] = @text
+ when 'key' then @tag_key = @text
+ when 'value' then @tag_value = @text
when 'state'
if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/monitoring' || # DescribeInstances property
@xmlpath == 'RunInstancesResponse/instancesSet/item/monitoring' # RunInstances property
@instance[:monitoring_state] = @text
end
when 'item'
- if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
- @xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
- @reservation[:instances_set] << @instance
+ if @xmlpath=='DescribeInstancesResponse/reservationSet/item/instancesSet/item/tagSet' # Tags
+ @instance[:tags][@tag_key] = @tag_value
+ elsif @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
+ @xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
+ @reservation[:instances_set] << @instance
elsif @xmlpath=='DescribeInstancesResponse/reservationSet' # DescribeInstances property
- @result << @reservation
+ @result << @reservation
end
when 'RunInstancesResponse' then @result << @reservation # RunInstances property
end
@@ -80,9 +80,8 @@ def generate_request(action, params={})
# Sends request to Amazon and parses the response
# Raises AwsError if any banana happened
def request_info(request, parser, options={})
- thread = @params[:multi_thread] ? Thread.current : Thread.main
- thread[:elb_connection] ||= Rightscale::HttpConnection.new(:exception => Aws::AwsError, :logger => @logger)
- request_info_impl(thread[:elb_connection], @@bench, request, parser, options)
+ conn = get_conn(:mon_connection, @params, @logger)
+ request_info_impl(conn, @@bench, request, parser, options)
end
#-----------------------------------------------------------------
@@ -105,6 +105,7 @@ def canonical_string(method, path, headers={}, expires=nil) # :nodoc:
out_string << path.gsub(/\?.*$/, '')
# ...unless there is an acl or torrent parameter
out_string << '?acl' if path[/[&?]acl($|&|=)/]
+ out_string << '?policy' if path[/[&?]policy($|&|=)/]
out_string << '?torrent' if path[/[&?]torrent($|&|=)/]
out_string << '?location' if path[/[&?]location($|&|=)/]
out_string << '?logging' if path[/[&?]logging($|&|=)/] # this one is beta, no support for now
@@ -769,6 +770,20 @@ def put_bucket_acl(bucket, acl_xml_doc, headers={})
on_exception
end
+ def get_bucket_policy(bucket)
+ req_hash = generate_rest_request('GET', {:url=>"#{bucket}?policy"})
+ request_info(req_hash, S3HttpResponseBodyParser.new)
+ rescue
+ on_exception
+ end
+
+ def put_bucket_policy(bucket, policy)
+ key = key.blank? ? '' : "/#{CGI::escape key}"
+ req_hash = generate_rest_request('PUT', {:url=>"#{bucket}?policy", :data=>policy})
+ request_info(req_hash, S3HttpResponseBodyParser.new)
+ rescue
+ on_exception
+ end
# Removes all keys from bucket. Returns +true+ or an exception.
#
Oops, something went wrong.

0 comments on commit e0fd9b3

Please sign in to comment.