right_aws 1.7.1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +46 -66
- data/Manifest.txt +1 -0
- data/README.txt +8 -1
- data/lib/awsbase/benchmark_fix.rb +1 -1
- data/lib/awsbase/file_fix.rb +33 -0
- data/lib/awsbase/right_awsbase.rb +23 -4
- data/lib/ec2/right_ec2.rb +112 -94
- data/lib/right_aws.rb +2 -1
- data/lib/s3/right_s3.rb +120 -6
- data/lib/s3/right_s3_interface.rb +79 -10
- data/lib/sdb/right_sdb_interface.rb +7 -3
- data/lib/sqs/right_sqs.rb +1 -1
- data/lib/sqs/right_sqs_gen2_interface.rb +1 -0
- data/lib/sqs/right_sqs_interface.rb +14 -11
- data/test/ec2/test_right_ec2.rb +8 -0
- data/test/s3/test_right_s3.rb +124 -6
- data/test/s3/test_right_s3_stubbed.rb +25 -0
- data/test/sdb/test_right_sdb.rb +21 -2
- data/test/sqs/test_right_sqs.rb +36 -3
- data/test/sqs/test_right_sqs_gen2.rb +9 -0
- metadata +52 -44
data/History.txt
CHANGED
@@ -89,104 +89,84 @@ Initial release.
|
|
89
89
|
(The Ec2 functions are being cached: describe_images, describe_instances,
|
90
90
|
describe_security_groups and describe_key_pairs)
|
91
91
|
|
92
|
-
== 1.4.5
|
93
|
-
|
94
|
-
*r 2619, konstantin, 01-17-08 16:18:36 +0300
|
92
|
+
== 1.4.5 - 1.4.6
|
93
|
+
* r 2619, konstantin, 01-17-08 16:18:36 +0300
|
95
94
|
* S3 Location constraints support added.
|
96
95
|
* Fixed bug with trailing '/' in the bucket name for 'EU' located buckets
|
97
96
|
* Added: S3Interface#bucket_location, S3::Bucket#location
|
98
97
|
|
99
98
|
== 1.4.7
|
100
|
-
*r 2622, konstantin, 01-18-08 13:52:20 +0300
|
99
|
+
* r 2622, konstantin, 01-18-08 13:52:20 +0300
|
101
100
|
* Virtual domains doc added
|
102
101
|
* S3 Query API fixed to support virtual domains.
|
103
102
|
|
104
103
|
== 1.4.8
|
105
|
-
*r 2650, konstantin, 01-24-08 11:12:00 +0300
|
104
|
+
* r 2650, konstantin, 01-24-08 11:12:00 +0300
|
106
105
|
* net_fix.rb moved to right_http_connection
|
107
106
|
|
108
107
|
== 1.5.0
|
109
|
-
*r 2688, konstantin, 02-30-08 15:42:00 +0300
|
108
|
+
* r 2688, konstantin, 02-30-08 15:42:00 +0300
|
110
109
|
* SDB support added.
|
111
110
|
* RightAws::S3::bucket and RightAws::S3::Bucket.create methods behaviour
|
112
111
|
changed: param +create+ is set to +false+ by default.
|
113
112
|
|
114
113
|
== 1.6.0
|
115
114
|
|
116
|
-
r2780
|
117
|
-
Some doc updates & tweaks: we now support ultra-large PUTs to S3, small SDB
|
118
|
-
cleanups, add SDB to the list of interfaces in RightAws, update some copyrights,
|
119
|
-
warn about loading attachment_fu AFTER right_aws (big no-no).
|
115
|
+
* r2780, todd, 2008-02-11 11:41:07 -0800 (Mon, 11 Feb 2008), 4 lines
|
116
|
+
* Some doc updates & tweaks: we now support ultra-large PUTs to S3, small SDB
|
117
|
+
cleanups, add SDB to the list of interfaces in RightAws, update some copyrights,
|
118
|
+
warn about loading attachment_fu AFTER right_aws (big no-no).
|
120
119
|
|
121
|
-
r2784
|
122
|
-
One final clarification: you may get a Net::HTTP bad monkey patch exception
|
120
|
+
* r2784, todd, 2008-02-11 13:46:47 -0800 (Mon, 11 Feb 2008), 2 lines
|
121
|
+
* One final clarification: you may get a Net::HTTP bad monkey patch exception
|
123
122
|
|
124
|
-
r2880
|
125
|
-
Add SQS 'Gen 2' interface implementation
|
123
|
+
* r2880, todd, 2008-02-25 18:06:22 -0800 (Mon, 25 Feb 2008), 2 lines
|
124
|
+
* Add SQS 'Gen 2' interface implementation
|
126
125
|
|
127
|
-
r2913
|
128
|
-
SqsGen2 (object interface), unit tests for both interfaces, documentation
|
129
|
-
updates.
|
126
|
+
* r2913, todd, 2008-02-29 16:57:07 -0800 (Fri, 29 Feb 2008), 3 lines
|
127
|
+
* SqsGen2 (object interface), unit tests for both interfaces, documentation updates.
|
130
128
|
|
131
|
-
r2922
|
132
|
-
couple of documentation tweaks in prep for 1.6.0
|
129
|
+
* r2922, todd, 2008-03-03 15:26:42 -0800 (Mon, 03 Mar 2008), 2 lines
|
130
|
+
* couple of documentation tweaks in prep for 1.6.0
|
133
131
|
|
134
|
-
== 1.6.1
|
132
|
+
== 1.6.1
|
135
133
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
(#950) Many minor fixes in incrementally_list_bucket to prevent a death loop
|
140
|
-
in
|
141
|
-
certain rare conditions
|
134
|
+
* r2963, todd, 2008-03-06 19:10:23 -0800 (Thu, 06 Mar 2008), 3 lines
|
135
|
+
* (#950) Many minor fixes in incrementally_list_bucket to prevent a death loop
|
136
|
+
in certain rare conditions
|
142
137
|
|
143
138
|
== 1.7.0
|
144
139
|
|
145
|
-
r3051
|
146
|
-
#897, ActiveSdb alpha release
|
147
|
-
|
148
|
-
<<<<<<< .mine
|
149
|
-
#897, ActiveSdb alpha release
|
150
|
-
|
151
|
-
------------------------------------------------------------------------
|
152
|
-
r3204 | todd | 2008-03-26 17:50:45 -0700 (Wed, 26 Mar 2008) | 4 lines
|
153
|
-
|
154
|
-
Do not autoload right_sdb with the rest of the modules; it requires uuidtools.
|
155
|
-
We want the user to explicly request ActiveSdb, at least as long as it is
|
156
|
-
alpha/beta.
|
157
|
-
|
158
|
-
------------------------------------------------------------------------
|
159
|
-
r3220 | konstantin | 2008-03-26 23:03:51 -0700 (Wed, 26 Mar 2008) | 1 line
|
160
|
-
|
161
|
-
mark ActiveSdb release as alpha,(port to 1.7.0)
|
162
|
-
------------------------------------------------------------------------
|
163
|
-
r3229 | konstantin | 2008-03-27 03:43:17 -0700 (Thu, 27 Mar 2008) | 1 line
|
140
|
+
* r3051, konstantin, 2008-03-14 21:26:12 +0300 (Fri, 14 Mar 2008), 1 line
|
141
|
+
* #897, ActiveSdb alpha release
|
164
142
|
|
165
|
-
|
166
|
-
------------------------------------------------------------------------
|
167
|
-
r3243 | todd | 2008-03-27 12:10:49 -0700 (Thu, 27 Mar 2008) | 1 line
|
143
|
+
== 1.7.1
|
168
144
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
r3249 | todd | 2008-03-27 17:59:14 -0700 (Thu, 27 Mar 2008) | 1 line
|
145
|
+
Do not autoload right_sdb with the rest of the modules; it requires uuidtools.
|
146
|
+
We want the user to explicly request ActiveSdb, at least as long as it is
|
147
|
+
alpha/beta.
|
173
148
|
|
174
|
-
|
175
|
-
ActiveSdb. Update RDoc to show how to include ActiveSdb class. Update README
|
176
|
-
to point to ActiveSdb RDoc.
|
177
|
-
------------------------------------------------------------------------
|
178
|
-
r3250 | todd | 2008-03-27 18:03:09 -0700 (Thu, 27 Mar 2008) | 2 lines
|
149
|
+
Fix escaping problem in SqsGen2Interface: POST bodies did not properly escape the '&' character
|
179
150
|
|
180
|
-
|
151
|
+
== 1.7.2
|
181
152
|
|
182
|
-
|
183
|
-
|
153
|
+
Release Notes:
|
154
|
+
|
155
|
+
RightAws includes some new features, including:
|
156
|
+
- Support in RightAws::S3 and RightAws::S3Interface for S3 key copy, move, and rename
|
157
|
+
- Support for signature version 0 request authentication to EC2, SQS, and SDB
|
158
|
+
- Enhanced S3 object meta-header read and update
|
159
|
+
- Interoperability with clouds running Eucalyptus (http://eucalyptus.cs.ucsb.edu)
|
160
|
+
[ Contributed by the Eucalyptus group ]
|
161
|
+
- Support for c1.medium and c1.xlarge instance types
|
184
162
|
|
185
|
-
|
186
|
-
|
187
|
-
|
163
|
+
Bug fixes include:
|
164
|
+
- Corrected the failure, under certain conditions, of retries of streaming PUTs to S3.
|
165
|
+
We now reset the seek pointer of the streaming IO object to its initial position.
|
166
|
+
- Removal of an accidental dependency on ActiveSupport in RightAws::S3Interface.get_link().
|
167
|
+
- Monkey-patch of the Ruby File class on Windows platforms to correct a problem in lstat.
|
168
|
+
The lstat bug was causing failure of very large file uploads on Windows [ Contributed by Benjamin Allfree ]
|
169
|
+
- Fixed parsing of the ETag field for S3 objects
|
170
|
+
|
188
171
|
|
189
|
-
right_aws 1.7.0
|
190
|
-
1. remove code duplication on the methods being cached
|
191
|
-
2. add describe_availability_zones to cached methods
|
192
172
|
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -34,6 +34,8 @@ The RightScale AWS gems have been designed to provide a robust, fast, and secure
|
|
34
34
|
AWS accounts.
|
35
35
|
- Support for both first- and second-generation SQS (API versions 2007-05-01
|
36
36
|
and 2008-01-01). These versions of SQS are not compatible.
|
37
|
+
- Support for signature versions 0 and 1 on SQS, SDB, and EC2.
|
38
|
+
- Interoperability with any cloud running Eucalyptus (http://eucalyptus.cs.ucsb.edu)
|
37
39
|
- Test suite (requires AWS account to do "live" testing).
|
38
40
|
|
39
41
|
== THREADING:
|
@@ -82,6 +84,11 @@ multithreaded mode.
|
|
82
84
|
|
83
85
|
== KNOWN ISSUES:
|
84
86
|
|
87
|
+
- Attempting to use the Gibberish plugin (used by the Beast forum app)
|
88
|
+
will break right_aws as well as lots of other code. Gibberish
|
89
|
+
changes the semantics of core Ruby (specifically, the String class) and thus presents a reliability
|
90
|
+
problem for most Ruby programs.
|
91
|
+
|
85
92
|
- 2/11/08: If you use RightAws in conjunction with attachment_fu, the
|
86
93
|
right_aws gem must be included (using the require statement) AFTER
|
87
94
|
attachment_fu. If right_aws is loaded before attachment_fu, you'll
|
@@ -113,7 +120,7 @@ REXML parsing.
|
|
113
120
|
|
114
121
|
== INSTALL:
|
115
122
|
|
116
|
-
sudo gem install
|
123
|
+
sudo gem install right_aws
|
117
124
|
|
118
125
|
== LICENSE:
|
119
126
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2007-2008 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
# File.lstat.size doesn't report large sizes correctly in Ruby 1.8 (Windows).
|
26
|
+
if RUBY_PLATFORM[/mswin|mingw|bccwin|wince/i]
|
27
|
+
require 'win32/file'
|
28
|
+
class File
|
29
|
+
def lstat
|
30
|
+
self.stat
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2007 RightScale Inc
|
2
|
+
# Copyright (c) 2007-2008 RightScale Inc
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -26,8 +26,9 @@ module RightAws
|
|
26
26
|
require 'md5'
|
27
27
|
|
28
28
|
class AwsUtils #:nodoc:
|
29
|
+
@@digest = OpenSSL::Digest::Digest.new("sha1")
|
29
30
|
def self.sign(aws_secret_access_key, auth_string)
|
30
|
-
Base64.encode64(OpenSSL::HMAC.digest(
|
31
|
+
Base64.encode64(OpenSSL::HMAC.digest(@@digest, aws_secret_access_key, auth_string)).strip
|
31
32
|
end
|
32
33
|
|
33
34
|
# From Amazon's SQS Dev Guide, a brief description of how to escape:
|
@@ -92,6 +93,8 @@ module RightAws
|
|
92
93
|
end
|
93
94
|
|
94
95
|
module RightAwsBaseInterface
|
96
|
+
DEFAULT_SIGNATURE_VERSION = '1'
|
97
|
+
|
95
98
|
@@caching = false
|
96
99
|
def self.caching
|
97
100
|
@@caching
|
@@ -118,6 +121,8 @@ module RightAws
|
|
118
121
|
attr_reader :connection
|
119
122
|
# Cache
|
120
123
|
attr_reader :cache
|
124
|
+
# Signature version (all services except s3)
|
125
|
+
attr_reader :signature_version
|
121
126
|
|
122
127
|
def init(service_info, aws_access_key_id, aws_secret_access_key, params={}) #:nodoc:
|
123
128
|
@params = params
|
@@ -127,6 +132,7 @@ module RightAws
|
|
127
132
|
@aws_secret_access_key = aws_secret_access_key
|
128
133
|
@params[:server] ||= service_info[:default_host]
|
129
134
|
@params[:port] ||= service_info[:default_port]
|
135
|
+
@params[:service] ||= service_info[:default_service]
|
130
136
|
@params[:protocol] ||= service_info[:default_protocol]
|
131
137
|
@params[:multi_thread] ||= defined?(AWS_DAEMON)
|
132
138
|
@logger = @params[:logger]
|
@@ -135,6 +141,7 @@ module RightAws
|
|
135
141
|
@logger.info "New #{self.class.name} using #{@params[:multi_thread] ? 'multi' : 'single'}-threaded mode"
|
136
142
|
@error_handler = nil
|
137
143
|
@cache = {}
|
144
|
+
@signature_version = (params[:signature_version] || DEFAULT_SIGNATURE_VERSION).to_s
|
138
145
|
end
|
139
146
|
|
140
147
|
# Returns +true+ if the describe_xxx responses are being cached
|
@@ -451,6 +458,17 @@ module RightAws
|
|
451
458
|
@aws.logger.warn("##### Retry ##{@retries} is being performed. Sleeping for #{@reiteration_delay} sec. Whole time: #{Time.now-@started_at} sec ####")
|
452
459
|
sleep @reiteration_delay
|
453
460
|
@reiteration_delay *= 2
|
461
|
+
|
462
|
+
# Always make sure that the fp is set to point to the beginning(?)
|
463
|
+
# of the File/IO. TODO: it assumes that offset is 0, which is bad.
|
464
|
+
if(request[:request].body_stream && request[:request].body_stream.respond_to?(:pos))
|
465
|
+
begin
|
466
|
+
request[:request].body_stream.pos = 0
|
467
|
+
rescue Exception => e
|
468
|
+
@logger.warn("Retry may fail due to unable to reset the file pointer" +
|
469
|
+
" -- #{self.class.name} : #{e.inspect}")
|
470
|
+
end
|
471
|
+
end
|
454
472
|
else
|
455
473
|
@aws.logger.info("##### Retry ##{@retries} is being performed due to a redirect. ####")
|
456
474
|
end
|
@@ -463,7 +481,7 @@ module RightAws
|
|
463
481
|
# Is this a 5xx error ?
|
464
482
|
if @aws.last_response.code.to_s[/^5\d\d$/]
|
465
483
|
@aws.connection.finish "#{self.class.name}: code: #{@aws.last_response.code}: '#{@aws.last_response.message}'"
|
466
|
-
# Is this a
|
484
|
+
# Is this a 4xx error ?
|
467
485
|
elsif @aws.last_response.code.to_s[/^4\d\d$/] && @close_on_4xx_probability > rand(100)
|
468
486
|
@aws.connection.finish "#{self.class.name}: code: #{@aws.last_response.code}: '#{@aws.last_response.message}', " +
|
469
487
|
"probability: #{@close_on_4xx_probability}%"
|
@@ -537,7 +555,7 @@ module RightAws
|
|
537
555
|
tagend(name)
|
538
556
|
end
|
539
557
|
def text(text)
|
540
|
-
@text
|
558
|
+
@text += text
|
541
559
|
tagtext(text)
|
542
560
|
end
|
543
561
|
# Parser method.
|
@@ -639,3 +657,4 @@ module RightAws
|
|
639
657
|
end
|
640
658
|
|
641
659
|
end
|
660
|
+
|
data/lib/ec2/right_ec2.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2007 RightScale Inc
|
2
|
+
# Copyright (c) 2007-2008 RightScale Inc
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -66,10 +66,10 @@ module RightAws
|
|
66
66
|
class Ec2 < RightAwsBase
|
67
67
|
include RightAwsBaseInterface
|
68
68
|
|
69
|
-
SIGNATURE_VERSION = "1"
|
70
69
|
# Amazon EC2 API version being used
|
71
70
|
API_VERSION = "2008-02-01"
|
72
71
|
DEFAULT_HOST = "ec2.amazonaws.com"
|
72
|
+
DEFAULT_PATH = '/'
|
73
73
|
DEFAULT_PROTOCOL = 'https'
|
74
74
|
DEFAULT_PORT = 443
|
75
75
|
|
@@ -77,9 +77,10 @@ module RightAws
|
|
77
77
|
DEFAULT_ADDRESSING_TYPE = 'public'
|
78
78
|
DNS_ADDRESSING_SET = ['public','direct']
|
79
79
|
|
80
|
+
# Amazon EC2 Instance Types : http://www.amazon.com/b?ie=UTF8&node=370375011
|
80
81
|
# Default EC2 instance type (platform)
|
81
82
|
DEFAULT_INSTANCE_TYPE = 'm1.small'
|
82
|
-
INSTANCE_TYPES = ['m1.small','m1.large','m1.xlarge']
|
83
|
+
INSTANCE_TYPES = ['m1.small','c1.medium','m1.large','m1.xlarge','c1.xlarge']
|
83
84
|
|
84
85
|
@@bench = AwsBenchmarkingBlock.new
|
85
86
|
def self.bench_xml
|
@@ -103,11 +104,13 @@ module RightAws
|
|
103
104
|
# * <tt>:protocol</tt>: 'http' or 'https', default: DEFAULT_PROTOCOL
|
104
105
|
# * <tt>:multi_thread</tt>: true=HTTP connection per thread, false=per process
|
105
106
|
# * <tt>:logger</tt>: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT
|
107
|
+
# * <tt>:signature_version</tt>: The signature version : '0' or '1'(default)
|
106
108
|
#
|
107
109
|
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
108
110
|
init({ :name => 'EC2',
|
109
111
|
:default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,
|
110
|
-
:default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,
|
112
|
+
:default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,
|
113
|
+
:default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH,
|
111
114
|
:default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL },
|
112
115
|
aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] ,
|
113
116
|
aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
|
@@ -115,18 +118,21 @@ module RightAws
|
|
115
118
|
end
|
116
119
|
|
117
120
|
|
118
|
-
def generate_request(action,
|
119
|
-
|
120
|
-
request_hash = {"Action" => action,
|
121
|
+
def generate_request(action, params={}) #:nodoc:
|
122
|
+
service_hash = {"Action" => action,
|
121
123
|
"AWSAccessKeyId" => @aws_access_key_id,
|
122
124
|
"Version" => @@api,
|
123
|
-
"Timestamp" =>
|
124
|
-
"SignatureVersion" =>
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
125
|
+
"Timestamp" => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.000Z"),
|
126
|
+
"SignatureVersion" => signature_version }
|
127
|
+
service_hash.update(params)
|
128
|
+
# prepare string to sight
|
129
|
+
string_to_sign = case signature_version
|
130
|
+
when '0' then service_hash["Action"] + service_hash["Timestamp"]
|
131
|
+
when '1' then service_hash.sort{|a,b| (a[0].to_s.downcase)<=>(b[0].to_s.downcase)}.to_s
|
132
|
+
end
|
133
|
+
service_hash.update('Signature' => AwsUtils::sign(@aws_secret_access_key, string_to_sign))
|
134
|
+
request_params = service_hash.to_a.collect{|key,val| key + "=" + CGI::escape(val) }.join("&")
|
135
|
+
request = Net::HTTP::Get.new("#{@params[:service]}?#{request_params}")
|
130
136
|
# prepare output hash
|
131
137
|
{ :request => request,
|
132
138
|
:server => @params[:server],
|
@@ -157,7 +163,7 @@ module RightAws
|
|
157
163
|
update_cache(method.to_sym, :parsed => result) if use_cache
|
158
164
|
result
|
159
165
|
end
|
160
|
-
|
166
|
+
|
161
167
|
def hash_params(prefix, list) #:nodoc:
|
162
168
|
groups = {}
|
163
169
|
list.each_index{|i| groups.update("#{prefix}.#{i+1}"=>list[i])} if list
|
@@ -165,7 +171,7 @@ module RightAws
|
|
165
171
|
end
|
166
172
|
|
167
173
|
#-----------------------------------------------------------------
|
168
|
-
|
174
|
+
# Images
|
169
175
|
#-----------------------------------------------------------------
|
170
176
|
|
171
177
|
def ec2_describe_images(list, list_by='ImageId', image_type=nil) #:nodoc:
|
@@ -345,6 +351,10 @@ module RightAws
|
|
345
351
|
modify_image_attribute(image_id, 'productCodes', nil, :product_code => product_code.to_a)
|
346
352
|
end
|
347
353
|
|
354
|
+
#-----------------------------------------------------------------
|
355
|
+
# Instances
|
356
|
+
#-----------------------------------------------------------------
|
357
|
+
|
348
358
|
def get_desc_instances(instances) # :nodoc:
|
349
359
|
result = []
|
350
360
|
instances.each do |reservation|
|
@@ -562,6 +572,10 @@ module RightAws
|
|
562
572
|
rescue Exception
|
563
573
|
on_exception
|
564
574
|
end
|
575
|
+
|
576
|
+
#-----------------------------------------------------------------
|
577
|
+
# Security groups
|
578
|
+
#-----------------------------------------------------------------
|
565
579
|
|
566
580
|
# Retrieve Security Group information. If +list+ is omitted the returns the whole list of groups.
|
567
581
|
#
|
@@ -706,6 +720,10 @@ module RightAws
|
|
706
720
|
on_exception
|
707
721
|
end
|
708
722
|
|
723
|
+
#-----------------------------------------------------------------
|
724
|
+
# Keys
|
725
|
+
#-----------------------------------------------------------------
|
726
|
+
|
709
727
|
# Retrieve a list of SSH keys. Returns an array of keys or an exception. Each key is
|
710
728
|
# represented as a two-element hash.
|
711
729
|
#
|
@@ -840,19 +858,18 @@ module RightAws
|
|
840
858
|
rescue Exception
|
841
859
|
on_exception
|
842
860
|
end
|
843
|
-
|
844
|
-
#- Internal stuff from here on down...
|
845
|
-
|
846
861
|
|
862
|
+
|
863
|
+
|
847
864
|
#-----------------------------------------------------------------
|
848
865
|
# PARSERS: Boolean Response Parser
|
849
866
|
#-----------------------------------------------------------------
|
850
867
|
|
851
|
-
|
852
|
-
|
853
|
-
|
868
|
+
class RightBoolResponseParser < RightAWSParser #:nodoc:
|
869
|
+
def tagend(name)
|
870
|
+
@result = @text=='true' ? true : false if name == 'return'
|
871
|
+
end
|
854
872
|
end
|
855
|
-
end
|
856
873
|
|
857
874
|
#-----------------------------------------------------------------
|
858
875
|
# PARSERS: Key Pair
|
@@ -864,9 +881,9 @@ module RightAws
|
|
864
881
|
end
|
865
882
|
def tagend(name)
|
866
883
|
case name
|
867
|
-
when 'keyName'
|
868
|
-
when 'keyFingerprint'
|
869
|
-
when 'item'
|
884
|
+
when 'keyName' then @item[:aws_key_name] = @text
|
885
|
+
when 'keyFingerprint' then @item[:aws_fingerprint] = @text
|
886
|
+
when 'item' then @result << @item
|
870
887
|
end
|
871
888
|
end
|
872
889
|
def reset
|
@@ -880,9 +897,9 @@ module RightAws
|
|
880
897
|
end
|
881
898
|
def tagend(name)
|
882
899
|
case name
|
883
|
-
when 'keyName'
|
884
|
-
when 'keyFingerprint'
|
885
|
-
when 'keyMaterial'
|
900
|
+
when 'keyName' then @result[:aws_key_name] = @text
|
901
|
+
when 'keyFingerprint' then @result[:aws_fingerprint] = @text
|
902
|
+
when 'keyMaterial' then @result[:aws_material] = @text
|
886
903
|
end
|
887
904
|
end
|
888
905
|
end
|
@@ -930,19 +947,19 @@ module RightAws
|
|
930
947
|
end
|
931
948
|
def tagend(name)
|
932
949
|
case name
|
933
|
-
when 'ownerId'
|
934
|
-
when 'groupDescription'
|
950
|
+
when 'ownerId' then @group.ownerId = @text
|
951
|
+
when 'groupDescription' then @group.groupDescription = @text
|
935
952
|
when 'groupName'
|
936
953
|
if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item'
|
937
954
|
@group.groupName = @text
|
938
955
|
elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups/item'
|
939
956
|
@sgroup.groupName = @text
|
940
957
|
end
|
941
|
-
when 'ipProtocol'
|
942
|
-
when 'fromPort'
|
943
|
-
when 'toPort'
|
944
|
-
when 'userId'
|
945
|
-
when 'cidrIp'
|
958
|
+
when 'ipProtocol' then @perm.ipProtocol = @text
|
959
|
+
when 'fromPort' then @perm.fromPort = @text
|
960
|
+
when 'toPort' then @perm.toPort = @text
|
961
|
+
when 'userId' then @sgroup.userId = @text
|
962
|
+
when 'cidrIp' then @perm.ipRanges << @text
|
946
963
|
when 'item'
|
947
964
|
if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups'
|
948
965
|
@perm.groups << @sgroup
|
@@ -970,17 +987,17 @@ module RightAws
|
|
970
987
|
end
|
971
988
|
def tagend(name)
|
972
989
|
case name
|
973
|
-
when 'imageId'
|
974
|
-
when 'imageLocation'
|
975
|
-
when 'imageState'
|
976
|
-
when 'imageOwnerId'
|
977
|
-
when 'isPublic'
|
978
|
-
when 'productCode'
|
979
|
-
when 'architecture'
|
980
|
-
when 'imageType'
|
981
|
-
when 'kernelId'
|
982
|
-
when 'ramdiskId'
|
983
|
-
when 'item'
|
990
|
+
when 'imageId' then @image[:aws_id] = @text
|
991
|
+
when 'imageLocation' then @image[:aws_location] = @text
|
992
|
+
when 'imageState' then @image[:aws_state] = @text
|
993
|
+
when 'imageOwnerId' then @image[:aws_owner] = @text
|
994
|
+
when 'isPublic' then @image[:aws_is_public]= @text == 'true' ? true : false
|
995
|
+
when 'productCode' then (@image[:aws_product_codes] ||= []) << @text
|
996
|
+
when 'architecture' then @image[:aws_architecture] = @text
|
997
|
+
when 'imageType' then @image[:aws_image_type] = @text
|
998
|
+
when 'kernelId' then @image[:aws_kernel_id] = @text
|
999
|
+
when 'ramdiskId' then @image[:aws_ramdisk_id] = @text
|
1000
|
+
when 'item' then @result << @image if @xmlpath[%r{.*/imagesSet$}]
|
984
1001
|
end
|
985
1002
|
end
|
986
1003
|
def reset
|
@@ -1013,13 +1030,13 @@ module RightAws
|
|
1013
1030
|
# But nobody know what will they xml later as attribute. That is why we
|
1014
1031
|
# check for 'group' and 'userId' inside of 'launchPermission/item'
|
1015
1032
|
case name
|
1016
|
-
when 'imageId'
|
1017
|
-
when 'group'
|
1018
|
-
when 'userId'
|
1019
|
-
when 'productCode'
|
1020
|
-
when 'kernel'
|
1021
|
-
when 'ramdisk'
|
1022
|
-
when 'blockDeviceMapping'
|
1033
|
+
when 'imageId' then @result[:aws_id] = @text
|
1034
|
+
when 'group' then @result[:groups] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
|
1035
|
+
when 'userId' then @result[:users] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
|
1036
|
+
when 'productCode' then @result[:aws_product_codes] << @text
|
1037
|
+
when 'kernel' then @result[:aws_kernel] = @text
|
1038
|
+
when 'ramdisk' then @result[:aws_ramdisk] = @text
|
1039
|
+
when 'blockDeviceMapping' then @result[:block_device_mapping] = @text
|
1023
1040
|
end
|
1024
1041
|
end
|
1025
1042
|
def reset
|
@@ -1046,37 +1063,37 @@ module RightAws
|
|
1046
1063
|
# RunInstances property
|
1047
1064
|
@xmlpath=='RunInstancesResponse/instancesSet' )
|
1048
1065
|
# the optional params (sometimes are missing and we dont want them to be nil)
|
1049
|
-
@instance = { :aws_reason
|
1050
|
-
:dns_name
|
1051
|
-
:private_dns_name
|
1052
|
-
:ami_launch_index
|
1053
|
-
:ssh_key_name
|
1054
|
-
:aws_state
|
1066
|
+
@instance = { :aws_reason => '',
|
1067
|
+
:dns_name => '',
|
1068
|
+
:private_dns_name => '',
|
1069
|
+
:ami_launch_index => '',
|
1070
|
+
:ssh_key_name => '',
|
1071
|
+
:aws_state => '',
|
1055
1072
|
:aws_product_codes => [] }
|
1056
1073
|
end
|
1057
1074
|
end
|
1058
1075
|
def tagend(name)
|
1059
1076
|
case name
|
1060
1077
|
# reservation
|
1061
|
-
when 'reservationId'
|
1062
|
-
when 'ownerId'
|
1063
|
-
when 'groupId'
|
1078
|
+
when 'reservationId' then @reservation[:aws_reservation_id] = @text
|
1079
|
+
when 'ownerId' then @reservation[:aws_owner] = @text
|
1080
|
+
when 'groupId' then @reservation[:aws_groups] << @text
|
1064
1081
|
# instance
|
1065
|
-
when 'instanceId'
|
1066
|
-
when 'imageId'
|
1067
|
-
when 'dnsName'
|
1068
|
-
when 'privateDnsName'
|
1069
|
-
when 'reason'
|
1070
|
-
when 'keyName'
|
1071
|
-
when 'amiLaunchIndex'
|
1072
|
-
when 'code'
|
1073
|
-
when 'name'
|
1074
|
-
when 'productCode'
|
1075
|
-
when 'instanceType'
|
1076
|
-
when 'launchTime'
|
1077
|
-
when 'kernelId'
|
1078
|
-
when 'ramdiskId'
|
1079
|
-
when 'availabilityZone'
|
1082
|
+
when 'instanceId' then @instance[:aws_instance_id] = @text
|
1083
|
+
when 'imageId' then @instance[:aws_image_id] = @text
|
1084
|
+
when 'dnsName' then @instance[:dns_name] = @text
|
1085
|
+
when 'privateDnsName' then @instance[:private_dns_name] = @text
|
1086
|
+
when 'reason' then @instance[:aws_reason] = @text
|
1087
|
+
when 'keyName' then @instance[:ssh_key_name] = @text
|
1088
|
+
when 'amiLaunchIndex' then @instance[:ami_launch_index] = @text
|
1089
|
+
when 'code' then @instance[:aws_state_code] = @text
|
1090
|
+
when 'name' then @instance[:aws_state] = @text
|
1091
|
+
when 'productCode' then @instance[:aws_product_codes] << @text
|
1092
|
+
when 'instanceType' then @instance[:aws_instance_type] = @text
|
1093
|
+
when 'launchTime' then @instance[:aws_launch_time] = @text
|
1094
|
+
when 'kernelId' then @instance[:aws_kernel_id] = @text
|
1095
|
+
when 'ramdiskId' then @instance[:aws_ramdisk_id] = @text
|
1096
|
+
when 'availabilityZone' then @instance[:aws_availability_zone] = @text
|
1080
1097
|
when 'item'
|
1081
1098
|
if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
|
1082
1099
|
@xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
|
@@ -1084,7 +1101,7 @@ module RightAws
|
|
1084
1101
|
elsif @xmlpath=='DescribeInstancesResponse/reservationSet' # DescribeInstances property
|
1085
1102
|
@result << @reservation
|
1086
1103
|
end
|
1087
|
-
when 'RunInstancesResponse'
|
1104
|
+
when 'RunInstancesResponse' then @result << @reservation # RunInstances property
|
1088
1105
|
end
|
1089
1106
|
end
|
1090
1107
|
def reset
|
@@ -1104,7 +1121,7 @@ module RightAws
|
|
1104
1121
|
end
|
1105
1122
|
def tagend(name)
|
1106
1123
|
case name
|
1107
|
-
when 'instanceId'
|
1124
|
+
when 'instanceId' then @instance[:aws_instance_id] = @text
|
1108
1125
|
when 'code'
|
1109
1126
|
if @xmlpath == 'TerminateInstancesResponse/instancesSet/item/shutdownState'
|
1110
1127
|
@instance[:aws_shutdown_state_code] = @text.to_i
|
@@ -1113,7 +1130,7 @@ module RightAws
|
|
1113
1130
|
if @xmlpath == 'TerminateInstancesResponse/instancesSet/item/shutdownState'
|
1114
1131
|
@instance[:aws_shutdown_state] = @text
|
1115
1132
|
else @instance[:aws_prev_state] = @text end
|
1116
|
-
when 'item'
|
1133
|
+
when 'item' then @result << @instance
|
1117
1134
|
end
|
1118
1135
|
end
|
1119
1136
|
def reset
|
@@ -1125,14 +1142,13 @@ module RightAws
|
|
1125
1142
|
# PARSERS: Console
|
1126
1143
|
#-----------------------------------------------------------------
|
1127
1144
|
|
1128
|
-
|
1129
1145
|
class QEc2GetConsoleOutputParser < RightAWSParser #:nodoc:
|
1130
1146
|
def tagend(name)
|
1131
1147
|
case name
|
1132
|
-
when 'instanceId'
|
1133
|
-
when 'timestamp'
|
1134
|
-
|
1135
|
-
when 'output'
|
1148
|
+
when 'instanceId' then @result[:aws_instance_id] = @text
|
1149
|
+
when 'timestamp' then @result[:aws_timestamp] = @text
|
1150
|
+
@result[:timestamp] = (Time.parse(@text)).utc
|
1151
|
+
when 'output' then @result[:aws_output] = Base64.decode64(@text)
|
1136
1152
|
end
|
1137
1153
|
end
|
1138
1154
|
def reset
|
@@ -1140,8 +1156,6 @@ module RightAws
|
|
1140
1156
|
end
|
1141
1157
|
end
|
1142
1158
|
|
1143
|
-
end
|
1144
|
-
|
1145
1159
|
#-----------------------------------------------------------------
|
1146
1160
|
# PARSERS: Fake
|
1147
1161
|
#-----------------------------------------------------------------
|
@@ -1171,9 +1185,9 @@ module RightAws
|
|
1171
1185
|
end
|
1172
1186
|
def tagend(name)
|
1173
1187
|
case name
|
1174
|
-
when 'instanceId'
|
1175
|
-
when 'publicIp'
|
1176
|
-
when 'item'
|
1188
|
+
when 'instanceId' then @address[:instance_id] = @text.blank? ? nil : @text
|
1189
|
+
when 'publicIp' then @address[:public_ip] = @text
|
1190
|
+
when 'item' then @result << @address
|
1177
1191
|
end
|
1178
1192
|
end
|
1179
1193
|
def reset
|
@@ -1191,14 +1205,18 @@ module RightAws
|
|
1191
1205
|
end
|
1192
1206
|
def tagend(name)
|
1193
1207
|
case name
|
1194
|
-
when 'zoneName'
|
1195
|
-
when 'zoneState'
|
1196
|
-
when 'item'
|
1208
|
+
when 'zoneName' then @zone[:zone_name] = @text
|
1209
|
+
when 'zoneState' then @zone[:zone_state] = @text
|
1210
|
+
when 'item' then @result << @zone
|
1197
1211
|
end
|
1198
1212
|
end
|
1199
1213
|
def reset
|
1200
1214
|
@result = []
|
1201
1215
|
end
|
1202
1216
|
end
|
1217
|
+
|
1218
|
+
|
1203
1219
|
|
1220
|
+
end
|
1221
|
+
|
1204
1222
|
end
|