dustMason-right_aws 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/History.txt +305 -0
  2. data/Manifest.txt +60 -0
  3. data/README.txt +165 -0
  4. data/Rakefile +112 -0
  5. data/lib/acf/right_acf_interface.rb +549 -0
  6. data/lib/acf/right_acf_invalidations.rb +144 -0
  7. data/lib/acf/right_acf_origin_access_identities.rb +230 -0
  8. data/lib/acf/right_acf_streaming_interface.rb +229 -0
  9. data/lib/acw/right_acw_interface.rb +248 -0
  10. data/lib/as/right_as_interface.rb +698 -0
  11. data/lib/awsbase/benchmark_fix.rb +39 -0
  12. data/lib/awsbase/right_awsbase.rb +1174 -0
  13. data/lib/awsbase/support.rb +35 -0
  14. data/lib/awsbase/version.rb +9 -0
  15. data/lib/ec2/right_ec2.rb +458 -0
  16. data/lib/ec2/right_ec2_ebs.rb +465 -0
  17. data/lib/ec2/right_ec2_images.rb +413 -0
  18. data/lib/ec2/right_ec2_instances.rb +785 -0
  19. data/lib/ec2/right_ec2_monitoring.rb +70 -0
  20. data/lib/ec2/right_ec2_placement_groups.rb +108 -0
  21. data/lib/ec2/right_ec2_reserved_instances.rb +174 -0
  22. data/lib/ec2/right_ec2_security_groups.rb +396 -0
  23. data/lib/ec2/right_ec2_spot_instances.rb +425 -0
  24. data/lib/ec2/right_ec2_tags.rb +139 -0
  25. data/lib/ec2/right_ec2_vpc.rb +583 -0
  26. data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
  27. data/lib/elb/right_elb_interface.rb +571 -0
  28. data/lib/iam/right_iam_access_keys.rb +71 -0
  29. data/lib/iam/right_iam_groups.rb +195 -0
  30. data/lib/iam/right_iam_interface.rb +341 -0
  31. data/lib/iam/right_iam_mfa_devices.rb +67 -0
  32. data/lib/iam/right_iam_users.rb +251 -0
  33. data/lib/rds/right_rds_interface.rb +1309 -0
  34. data/lib/right_aws.rb +88 -0
  35. data/lib/route_53/right_route_53_interface.rb +630 -0
  36. data/lib/s3/right_s3.rb +1123 -0
  37. data/lib/s3/right_s3_interface.rb +1198 -0
  38. data/lib/sdb/active_sdb.rb +1107 -0
  39. data/lib/sdb/right_sdb_interface.rb +753 -0
  40. data/lib/sns/right_sns.rb +205 -0
  41. data/lib/sns/right_sns_interface.rb +343 -0
  42. data/lib/sqs/right_sqs.rb +387 -0
  43. data/lib/sqs/right_sqs_gen2.rb +342 -0
  44. data/lib/sqs/right_sqs_gen2_interface.rb +523 -0
  45. data/lib/sqs/right_sqs_interface.rb +593 -0
  46. data/right_aws.gemspec +91 -0
  47. data/test/acf/test_helper.rb +2 -0
  48. data/test/acf/test_right_acf.rb +138 -0
  49. data/test/awsbase/test_helper.rb +2 -0
  50. data/test/awsbase/test_right_awsbase.rb +12 -0
  51. data/test/ec2/test_helper.rb +2 -0
  52. data/test/ec2/test_right_ec2.rb +108 -0
  53. data/test/http_connection.rb +87 -0
  54. data/test/rds/test_helper.rb +2 -0
  55. data/test/rds/test_right_rds.rb +120 -0
  56. data/test/s3/test_helper.rb +2 -0
  57. data/test/s3/test_right_s3.rb +421 -0
  58. data/test/s3/test_right_s3_stubbed.rb +97 -0
  59. data/test/sdb/test_active_sdb.rb +357 -0
  60. data/test/sdb/test_batch_put_attributes.rb +54 -0
  61. data/test/sdb/test_helper.rb +3 -0
  62. data/test/sdb/test_right_sdb.rb +253 -0
  63. data/test/sns/test_helper.rb +2 -0
  64. data/test/sns/test_right_sns.rb +73 -0
  65. data/test/sqs/test_helper.rb +2 -0
  66. data/test/sqs/test_right_sqs.rb +285 -0
  67. data/test/sqs/test_right_sqs_gen2.rb +264 -0
  68. data/test/test_credentials.rb +37 -0
  69. data/test/ts_right_aws.rb +14 -0
  70. metadata +244 -0
@@ -0,0 +1,465 @@
1
+ #
2
+ # Copyright (c) 2009 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
+ module RightAws
25
+
26
+ class Ec2
27
+
28
+ #-----------------------------------------------------------------
29
+ # EBS: Volumes
30
+ #-----------------------------------------------------------------
31
+
32
+ # Describe EBS volumes.
33
+ #
34
+ # Accepts a list of volumes and/or a set of filters as the last parameter.
35
+ #
36
+ # Filters: attachement.attach-time, attachment.delete-on-termination, attachement.device, attachment.instance-id,
37
+ # attachment.status, availability-zone, create-time, size, snapshot-id, status, tag-key, tag-value, tag:key, volume-id
38
+ #
39
+ # ec2.describe_volumes #=>
40
+ # [{:aws_size => 94,
41
+ # :aws_device => "/dev/sdc",
42
+ # :aws_attachment_status => "attached",
43
+ # :zone => "merlot",
44
+ # :snapshot_id => nil,
45
+ # :aws_attached_at => "2008-06-18T08:19:28.000Z",
46
+ # :aws_status => "in-use",
47
+ # :aws_id => "vol-60957009",
48
+ # :aws_created_at => "2008-06-18T08:19:20.000Z",
49
+ # :aws_instance_id => "i-c014c0a9"},
50
+ # {:aws_size => 1,
51
+ # :zone => "merlot",
52
+ # :snapshot_id => nil,
53
+ # :aws_status => "available",
54
+ # :aws_id => "vol-58957031",
55
+ # :aws_created_at => Wed Jun 18 08:19:21 UTC 2008,}, ... ]
56
+ #
57
+ # ec2.describe_volumes(:filters => { 'availability-zone' => 'us-east-1a', 'size' => '10' })
58
+ #
59
+ # P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeVolumes.html
60
+ #
61
+ def describe_volumes(*list_and_options)
62
+ describe_resources_with_list_and_options('DescribeVolumes', 'VolumeId', QEc2DescribeVolumesParser, list_and_options)
63
+ end
64
+
65
+ # Create new EBS volume based on previously created snapshot.
66
+ # +Size+ in Gigabytes.
67
+ #
68
+ # ec2.create_volume('snap-000000', 10, zone) #=>
69
+ # {:snapshot_id => "snap-e21df98b",
70
+ # :aws_status => "creating",
71
+ # :aws_id => "vol-fc9f7a95",
72
+ # :zone => "merlot",
73
+ # :aws_created_at => "2008-06-24T18:13:32.000Z",
74
+ # :aws_size => 94}
75
+ #
76
+ def create_volume(snapshot_id, size, zone)
77
+ hash = { "Size" => size.to_s,
78
+ "AvailabilityZone" => zone.to_s }
79
+ # Get rig of empty snapshot: e8s guys do not like it
80
+ hash["SnapshotId"] = snapshot_id.to_s unless snapshot_id.right_blank?
81
+ link = generate_request("CreateVolume", hash )
82
+ request_info(link, QEc2CreateVolumeParser.new(:logger => @logger))
83
+ rescue Exception
84
+ on_exception
85
+ end
86
+
87
+ # Delete the specified EBS volume.
88
+ # This does not deletes any snapshots created from this volume.
89
+ #
90
+ # ec2.delete_volume('vol-b48a6fdd') #=> true
91
+ #
92
+ def delete_volume(volume_id)
93
+ link = generate_request("DeleteVolume",
94
+ "VolumeId" => volume_id.to_s)
95
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
96
+ rescue Exception
97
+ on_exception
98
+ end
99
+
100
+ # Attach the specified EBS volume to a specified instance, exposing the
101
+ # volume using the specified device name.
102
+ #
103
+ # ec2.attach_volume('vol-898a6fe0', 'i-7c905415', '/dev/sdh') #=>
104
+ # { :aws_instance_id => "i-7c905415",
105
+ # :aws_device => "/dev/sdh",
106
+ # :aws_status => "attaching",
107
+ # :aws_attached_at => "2008-03-28T14:14:39.000Z",
108
+ # :aws_id => "vol-898a6fe0" }
109
+ #
110
+ def attach_volume(volume_id, instance_id, device)
111
+ link = generate_request("AttachVolume",
112
+ "VolumeId" => volume_id.to_s,
113
+ "InstanceId" => instance_id.to_s,
114
+ "Device" => device.to_s)
115
+ request_info(link, QEc2AttachAndDetachVolumeParser.new(:logger => @logger))
116
+ rescue Exception
117
+ on_exception
118
+ end
119
+
120
+ # Detach the specified EBS volume from the instance to which it is attached.
121
+ #
122
+ # ec2.detach_volume('vol-898a6fe0') #=>
123
+ # { :aws_instance_id => "i-7c905415",
124
+ # :aws_device => "/dev/sdh",
125
+ # :aws_status => "detaching",
126
+ # :aws_attached_at => "2008-03-28T14:38:34.000Z",
127
+ # :aws_id => "vol-898a6fe0"}
128
+ #
129
+ def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
130
+ hash = { "VolumeId" => volume_id.to_s }
131
+ hash["InstanceId"] = instance_id.to_s unless instance_id.right_blank?
132
+ hash["Device"] = device.to_s unless device.right_blank?
133
+ hash["Force"] = 'true' if force
134
+ #
135
+ link = generate_request("DetachVolume", hash)
136
+ request_info(link, QEc2AttachAndDetachVolumeParser.new(:logger => @logger))
137
+ rescue Exception
138
+ on_exception
139
+ end
140
+
141
+
142
+ #-----------------------------------------------------------------
143
+ # EBS: Snapshots
144
+ #-----------------------------------------------------------------
145
+
146
+ # Describe EBS snapshots.
147
+ #
148
+ # Accepts a list of snapshots and/or a set of filters as the last parameter.
149
+ #
150
+ # Filters: description, owner-alias, owner-id, progress, snapshot-id, start-time, status, tag-key,
151
+ # tag-value, tag:key, volume-id, volume-size
152
+ #
153
+ # ec2.describe_snapshots #=>
154
+ # [ {:aws_volume_id=>"vol-545fac3d",
155
+ # :aws_description=>"Wikipedia XML Backups (Linux)",
156
+ # :aws_progress=>"100%",
157
+ # :aws_started_at=>"2009-09-28T23:49:50.000Z",
158
+ # :aws_owner=>"amazon",
159
+ # :aws_id=>"snap-8041f2e9",
160
+ # :aws_volume_size=>500,
161
+ # :aws_status=>"completed"},
162
+ # {:aws_volume_id=>"vol-185fac71",
163
+ # :aws_description=>"Sloan Digital Sky Survey DR6 Subset (Linux)",
164
+ # :aws_progress=>"100%",
165
+ # :aws_started_at=>"2009-09-28T23:56:10.000Z",
166
+ # :aws_owner=>"amazon",
167
+ # :aws_id=>"snap-3740f35e",
168
+ # :aws_volume_size=>180,
169
+ # :aws_status=>"completed"}, ...]
170
+ #
171
+ # ec2.describe_snapshots(:filters => {'tag:MyTag' => 'MyValue'))
172
+ #
173
+ # P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeSnapshots.html
174
+ #
175
+ def describe_snapshots(*list_and_options)
176
+ describe_resources_with_list_and_options('DescribeSnapshots', 'SnapshotId', QEc2DescribeSnapshotsParser, list_and_options)
177
+ end
178
+
179
+ # Create a snapshot of specified volume.
180
+ #
181
+ # ec2.create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
182
+ # {:aws_volume_id=>"vol-e429db8d",
183
+ # :aws_started_at=>"2009-10-01T09:23:38.000Z",
184
+ # :aws_description=>"KD: WooHoo!!",
185
+ # :aws_owner=>"648770000000",
186
+ # :aws_progress=>"",
187
+ # :aws_status=>"pending",
188
+ # :aws_volume_size=>1,
189
+ # :aws_id=>"snap-3df54854"}
190
+ #
191
+ def create_snapshot(volume_id, description='')
192
+ link = generate_request("CreateSnapshot",
193
+ "VolumeId" => volume_id.to_s,
194
+ "Description" => description)
195
+ request_info(link, QEc2DescribeSnapshotsParser.new(:logger => @logger)).first
196
+ rescue Exception
197
+ on_exception
198
+ end
199
+
200
+ # Create a snapshot of specified volume, but with the normal retry algorithms disabled.
201
+ # This method will return immediately upon error. The user can specify connect and read timeouts (in s)
202
+ # for the connection to AWS. If the user does not specify timeouts, try_create_snapshot uses the default values
203
+ # in Rightscale::HttpConnection.
204
+ #
205
+ # ec2.try_create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
206
+ # {:aws_volume_id=>"vol-e429db8d",
207
+ # :aws_started_at=>"2009-10-01T09:23:38.000Z",
208
+ # :aws_description=>"KD: WooHoo!!",
209
+ # :aws_owner=>"648770000000",
210
+ # :aws_progress=>"",
211
+ # :aws_status=>"pending",
212
+ # :aws_volume_size=>1,
213
+ # :aws_id=>"snap-3df54854"}
214
+ #
215
+ def try_create_snapshot(volume_id, connect_timeout = nil, read_timeout = nil, description='')
216
+ # For safety in the ensure block...we don't want to restore values
217
+ # if we never read them in the first place
218
+ orig_reiteration_time = nil
219
+ orig_http_params = nil
220
+
221
+ orig_reiteration_time = RightAws::AWSErrorHandler::reiteration_time
222
+ RightAws::AWSErrorHandler::reiteration_time = 0
223
+
224
+ orig_http_params = Rightscale::HttpConnection::params()
225
+ new_http_params = orig_http_params.dup
226
+ new_http_params[:http_connection_retry_count] = 0
227
+ new_http_params[:http_connection_open_timeout] = connect_timeout if !connect_timeout.nil?
228
+ new_http_params[:http_connection_read_timeout] = read_timeout if !read_timeout.nil?
229
+ Rightscale::HttpConnection::params = new_http_params
230
+
231
+ link = generate_request("CreateSnapshot",
232
+ "VolumeId" => volume_id.to_s,
233
+ "Description" => description)
234
+ request_info(link, QEc2DescribeSnapshotsParser.new(:logger => @logger)).first
235
+
236
+ rescue Exception
237
+ on_exception
238
+ ensure
239
+ RightAws::AWSErrorHandler::reiteration_time = orig_reiteration_time if orig_reiteration_time
240
+ Rightscale::HttpConnection::params = orig_http_params if orig_http_params
241
+ end
242
+
243
+ # Describe snapshot attribute.
244
+ #
245
+ # ec2.describe_snapshot_attribute('snap-36fe435f') #=>
246
+ # {:create_volume_permission=>
247
+ # {:users=>["826690000000", "826690000001"], :groups=>['all']}}
248
+ #
249
+ def describe_snapshot_attribute(snapshot_id, attribute='createVolumePermission')
250
+ link = generate_request("DescribeSnapshotAttribute",
251
+ 'SnapshotId'=> snapshot_id,
252
+ 'Attribute' => attribute)
253
+ request_info(link, QEc2DescribeSnapshotAttributeParser.new(:logger => @logger))
254
+ rescue Exception
255
+ on_exception
256
+ end
257
+
258
+ # Reset permission settings for the specified snapshot.
259
+ #
260
+ # ec2.reset_snapshot_attribute('snap-cecd29a7') #=> true
261
+ #
262
+ def reset_snapshot_attribute(snapshot_id, attribute='createVolumePermission')
263
+ link = generate_request("ResetSnapshotAttribute",
264
+ 'SnapshotId' => snapshot_id,
265
+ 'Attribute' => attribute)
266
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
267
+ rescue Exception
268
+ on_exception
269
+ end
270
+
271
+ # Modify snapshot attribute.
272
+ #
273
+ # attribute : currently, only 'createVolumePermission' is supported.
274
+ # operation_type : currently, only 'add' & 'remove' are supported.
275
+ # vars:
276
+ # :user_group : currently, only 'all' is supported.
277
+ # :user_id : an array of user ids
278
+ #
279
+ def modify_snapshot_attribute(snapshot_id, attribute='createVolumePermission', operation_type='add', vars = {})
280
+ params = {'SnapshotId' => snapshot_id,
281
+ 'Attribute' => attribute,
282
+ 'OperationType' => operation_type}
283
+ params.update(amazonize_list('UserId', Array(vars[:user_id]))) if vars[:user_id]
284
+ params.update(amazonize_list('UserGroup', Array(vars[:user_group]))) if vars[:user_group]
285
+ link = generate_request("ModifySnapshotAttribute", params)
286
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
287
+ rescue Exception
288
+ on_exception
289
+ end
290
+
291
+ # Grant create volume permission for a list of users.
292
+ #
293
+ # ec2.modify_snapshot_attribute_create_volume_permission_add_users('snap-36fe435f', '000000000000', '000000000001') #=> true
294
+ #
295
+ def modify_snapshot_attribute_create_volume_permission_add_users(snapshot_id, *user_id)
296
+ modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'add', :user_id => user_id.flatten )
297
+ end
298
+
299
+ # Revoke create volume permission for a list of users.
300
+ #
301
+ # ec2.modify_snapshot_attribute_create_volume_permission_remove_users('snap-36fe435f', '000000000000', '000000000001') #=> true
302
+ #
303
+ def modify_snapshot_attribute_create_volume_permission_remove_users(snapshot_id, *user_id)
304
+ modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'remove', :user_id => user_id.flatten )
305
+ end
306
+
307
+ # Grant create volume permission for user groups (currently only 'all' is supported).
308
+ #
309
+ # ec2.modify_snapshot_attribute_create_volume_permission_add_groups('snap-36fe435f') #=> true
310
+ #
311
+ def modify_snapshot_attribute_create_volume_permission_add_groups(snapshot_id, *user_group)
312
+ user_group.flatten!
313
+ user_group = ['all'] if user_group.right_blank?
314
+ modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'add', :user_group => user_group )
315
+ end
316
+
317
+ # Remove create volume permission for user groups (currently only 'all' is supported).
318
+ #
319
+ # ec2.modify_snapshot_attribute_create_volume_permission_remove_groups('snap-36fe435f') #=> true
320
+ #
321
+ def modify_snapshot_attribute_create_volume_permission_remove_groups(snapshot_id, *user_group)
322
+ user_group.flatten!
323
+ user_group = ['all'] if user_group.right_blank?
324
+ modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'remove', :user_group => user_group )
325
+ end
326
+
327
+ # Delete the specified snapshot.
328
+ #
329
+ # ec2.delete_snapshot('snap-55a5403c') #=> true
330
+ #
331
+ def delete_snapshot(snapshot_id)
332
+ link = generate_request("DeleteSnapshot",
333
+ "SnapshotId" => snapshot_id.to_s)
334
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
335
+ rescue Exception
336
+ on_exception
337
+ end
338
+
339
+ #-----------------------------------------------------------------
340
+ # PARSERS: EBS - Volumes
341
+ #-----------------------------------------------------------------
342
+
343
+ class QEc2CreateVolumeParser < RightAWSParser #:nodoc:
344
+ def tagend(name)
345
+ case name
346
+ when 'volumeId' then @result[:aws_id] = @text
347
+ when 'status' then @result[:aws_status] = @text
348
+ when 'createTime' then @result[:aws_created_at] = @text
349
+ when 'size' then @result[:aws_size] = @text.to_i ###
350
+ when 'snapshotId' then @result[:snapshot_id] = @text.right_blank? ? nil : @text ###
351
+ when 'availabilityZone' then @result[:zone] = @text ###
352
+ end
353
+ end
354
+ def reset
355
+ @result = {}
356
+ end
357
+ end
358
+
359
+ class QEc2AttachAndDetachVolumeParser < RightAWSParser #:nodoc:
360
+ def tagend(name)
361
+ case name
362
+ when 'volumeId' then @result[:aws_id] = @text
363
+ when 'instanceId' then @result[:aws_instance_id] = @text
364
+ when 'device' then @result[:aws_device] = @text
365
+ when 'status' then @result[:aws_attachment_status] = @text
366
+ when 'attachTime' then @result[:aws_attached_at] = @text
367
+ end
368
+ end
369
+ def reset
370
+ @result = {}
371
+ end
372
+ end
373
+
374
+ class QEc2DescribeVolumesParser < RightAWSParser #:nodoc:
375
+ def tagstart(name, attributes)
376
+ case full_tag_name
377
+ when %r{volumeSet/item$} then @item = { :tags => {} }
378
+ when %r{/tagSet/item$} then @aws_tag = {}
379
+ end
380
+ end
381
+ def tagend(name)
382
+ case name
383
+ when 'size' then @item[:aws_size] = @text.to_i
384
+ when 'createTime' then @item[:aws_created_at] = @text
385
+ when 'instanceId' then @item[:aws_instance_id] = @text
386
+ when 'device' then @item[:aws_device] = @text
387
+ when 'attachTime' then @item[:aws_attached_at] = @text
388
+ when 'snapshotId' then @item[:snapshot_id] = @text.right_blank? ? nil : @text
389
+ when 'availabilityZone' then @item[:zone] = @text
390
+ when 'deleteOnTermination' then @item[:delete_on_termination] = (@text == 'true')
391
+ else
392
+ case full_tag_name
393
+ when %r{/volumeSet/item/volumeId$} then @item[:aws_id] = @text
394
+ when %r{/volumeSet/item/status$} then @item[:aws_status] = @text
395
+ when %r{/attachmentSet/item/status$} then @item[:aws_attachment_status] = @text
396
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
397
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
398
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
399
+ when %r{/volumeSet/item$} then @result << @item
400
+ end
401
+ end
402
+ end
403
+ def reset
404
+ @result = []
405
+ end
406
+ end
407
+
408
+ #-----------------------------------------------------------------
409
+ # PARSERS: EBS - Snapshots
410
+ #-----------------------------------------------------------------
411
+
412
+ class QEc2DescribeSnapshotsParser < RightAWSParser #:nodoc:
413
+ def tagstart(name, attributes)
414
+ case full_tag_name
415
+ when %r{CreateSnapshotResponse$},
416
+ %r{/snapshotSet/item$} then @item = { :tags => {} }
417
+ when %r{/tagSet/item$} then @aws_tag = {}
418
+ end
419
+ end
420
+ def tagend(name)
421
+ case name
422
+ when 'volumeId' then @item[:aws_volume_id] = @text
423
+ when 'snapshotId' then @item[:aws_id] = @text
424
+ when 'status' then @item[:aws_status] = @text
425
+ when 'startTime' then @item[:aws_started_at] = @text
426
+ when 'progress' then @item[:aws_progress] = @text
427
+ when 'description' then @item[:aws_description] = @text
428
+ when 'ownerId' then @item[:aws_owner] = @text
429
+ when 'volumeSize' then @item[:aws_volume_size] = @text.to_i
430
+ else
431
+ case full_tag_name
432
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
433
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
434
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
435
+ when %r{CreateSnapshotResponse$},
436
+ %r{/snapshotSet/item$} then @result << @item
437
+ end
438
+ end
439
+ end
440
+ def reset
441
+ @result = []
442
+ end
443
+ end
444
+
445
+ class QEc2DescribeSnapshotAttributeParser < RightAWSParser #:nodoc:
446
+ def tagstart(name, attributes)
447
+ case name
448
+ when 'createVolumePermission' then @result[:create_volume_permission] = { :groups => [], :users => [] }
449
+ end
450
+ end
451
+ def tagend(name)
452
+ case full_tag_name
453
+ when "#{@create_volume_permission}/group" then @result[:create_volume_permission][:groups] << @text
454
+ when "#{@create_volume_permission}/userId" then @result[:create_volume_permission][:users] << @text
455
+ end
456
+ end
457
+ def reset
458
+ @create_volume_permission = "DescribeSnapshotAttributeResponse/createVolumePermission/item"
459
+ @result = {}
460
+ end
461
+ end
462
+
463
+ end
464
+
465
+ end