icehouse-right_aws 1.11.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +93 -15
- data/Manifest.txt +15 -1
- data/README.txt +0 -4
- data/Rakefile +34 -17
- data/lib/acf/right_acf_interface.rb +260 -124
- data/lib/acf/right_acf_invalidations.rb +144 -0
- data/lib/acf/right_acf_origin_access_identities.rb +230 -0
- data/lib/acf/right_acf_streaming_interface.rb +229 -0
- data/lib/acw/right_acw_interface.rb +4 -5
- data/lib/as/right_as_interface.rb +59 -51
- data/lib/awsbase/benchmark_fix.rb +0 -0
- data/lib/awsbase/right_awsbase.rb +351 -104
- data/lib/awsbase/support.rb +2 -82
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +97 -246
- data/lib/ec2/right_ec2_ebs.rb +88 -68
- data/lib/ec2/right_ec2_images.rb +90 -50
- data/lib/ec2/right_ec2_instances.rb +118 -89
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +51 -44
- data/lib/ec2/right_ec2_security_groups.rb +396 -0
- data/lib/ec2/right_ec2_spot_instances.rb +425 -0
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +152 -140
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +205 -39
- data/lib/iam/right_iam_access_keys.rb +71 -0
- data/lib/iam/right_iam_groups.rb +195 -0
- data/lib/iam/right_iam_interface.rb +341 -0
- data/lib/iam/right_iam_mfa_devices.rb +67 -0
- data/lib/iam/right_iam_users.rb +251 -0
- data/lib/rds/right_rds_interface.rb +591 -205
- data/lib/right_aws.rb +16 -12
- data/lib/route_53/right_route_53_interface.rb +640 -0
- data/lib/s3/right_s3.rb +34 -13
- data/lib/s3/right_s3_interface.rb +17 -14
- data/lib/sdb/active_sdb.rb +215 -38
- data/lib/sdb/right_sdb_interface.rb +93 -12
- data/lib/sqs/right_sqs.rb +1 -2
- data/lib/sqs/right_sqs_gen2.rb +0 -1
- data/lib/sqs/right_sqs_gen2_interface.rb +9 -9
- data/lib/sqs/right_sqs_interface.rb +6 -7
- data/right_aws.gemspec +91 -0
- data/test/README.mdown +39 -0
- data/test/acf/test_helper.rb +0 -0
- data/test/acf/test_right_acf.rb +10 -18
- data/test/awsbase/test_helper.rb +0 -0
- data/test/awsbase/test_right_awsbase.rb +0 -1
- data/test/ec2/test_helper.rb +0 -0
- data/test/ec2/test_right_ec2.rb +0 -1
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/http_connection.rb +0 -0
- data/test/route_53/fixtures/a_record.xml +18 -0
- data/test/route_53/fixtures/alias_record.xml +18 -0
- data/test/route_53/test_helper.rb +2 -0
- data/test/route_53/test_right_route_53.rb +141 -0
- data/test/s3/test_helper.rb +0 -0
- data/test/s3/test_right_s3.rb +11 -9
- data/test/s3/test_right_s3_stubbed.rb +6 -4
- data/test/sdb/test_active_sdb.rb +71 -13
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sdb/test_helper.rb +0 -0
- data/test/sdb/test_right_sdb.rb +13 -7
- data/test/sqs/test_helper.rb +0 -0
- data/test/sqs/test_right_sqs.rb +0 -6
- data/test/sqs/test_right_sqs_gen2.rb +22 -34
- data/test/test_credentials.rb +0 -0
- data/test/ts_right_aws.rb +0 -0
- metadata +146 -16
- data/VERSION +0 -1
data/lib/ec2/right_ec2_ebs.rb
CHANGED
@@ -29,7 +29,12 @@ module RightAws
|
|
29
29
|
# EBS: Volumes
|
30
30
|
#-----------------------------------------------------------------
|
31
31
|
|
32
|
-
# Describe
|
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
|
33
38
|
#
|
34
39
|
# ec2.describe_volumes #=>
|
35
40
|
# [{:aws_size => 94,
|
@@ -37,10 +42,10 @@ module RightAws
|
|
37
42
|
# :aws_attachment_status => "attached",
|
38
43
|
# :zone => "merlot",
|
39
44
|
# :snapshot_id => nil,
|
40
|
-
# :aws_attached_at =>
|
45
|
+
# :aws_attached_at => "2008-06-18T08:19:28.000Z",
|
41
46
|
# :aws_status => "in-use",
|
42
47
|
# :aws_id => "vol-60957009",
|
43
|
-
# :aws_created_at =>
|
48
|
+
# :aws_created_at => "2008-06-18T08:19:20.000Z",
|
44
49
|
# :aws_instance_id => "i-c014c0a9"},
|
45
50
|
# {:aws_size => 1,
|
46
51
|
# :zone => "merlot",
|
@@ -49,12 +54,12 @@ module RightAws
|
|
49
54
|
# :aws_id => "vol-58957031",
|
50
55
|
# :aws_created_at => Wed Jun 18 08:19:21 UTC 2008,}, ... ]
|
51
56
|
#
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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)
|
58
63
|
end
|
59
64
|
|
60
65
|
# Create new EBS volume based on previously created snapshot.
|
@@ -65,14 +70,14 @@ module RightAws
|
|
65
70
|
# :aws_status => "creating",
|
66
71
|
# :aws_id => "vol-fc9f7a95",
|
67
72
|
# :zone => "merlot",
|
68
|
-
# :aws_created_at =>
|
73
|
+
# :aws_created_at => "2008-06-24T18:13:32.000Z",
|
69
74
|
# :aws_size => 94}
|
70
75
|
#
|
71
76
|
def create_volume(snapshot_id, size, zone)
|
72
77
|
hash = { "Size" => size.to_s,
|
73
78
|
"AvailabilityZone" => zone.to_s }
|
74
79
|
# Get rig of empty snapshot: e8s guys do not like it
|
75
|
-
hash["SnapshotId"] = snapshot_id.to_s unless snapshot_id.
|
80
|
+
hash["SnapshotId"] = snapshot_id.to_s unless snapshot_id.right_blank?
|
76
81
|
link = generate_request("CreateVolume", hash )
|
77
82
|
request_info(link, QEc2CreateVolumeParser.new(:logger => @logger))
|
78
83
|
rescue Exception
|
@@ -123,8 +128,8 @@ module RightAws
|
|
123
128
|
#
|
124
129
|
def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
|
125
130
|
hash = { "VolumeId" => volume_id.to_s }
|
126
|
-
hash["InstanceId"] = instance_id.to_s unless instance_id.
|
127
|
-
hash["Device"] = device.to_s unless device.
|
131
|
+
hash["InstanceId"] = instance_id.to_s unless instance_id.right_blank?
|
132
|
+
hash["Device"] = device.to_s unless device.right_blank?
|
128
133
|
hash["Force"] = 'true' if force
|
129
134
|
#
|
130
135
|
link = generate_request("DetachVolume", hash)
|
@@ -138,13 +143,20 @@ module RightAws
|
|
138
143
|
# EBS: Snapshots
|
139
144
|
#-----------------------------------------------------------------
|
140
145
|
|
141
|
-
# Describe
|
146
|
+
# Describe EBS snapshots.
|
142
147
|
#
|
143
|
-
#
|
148
|
+
# Accepts a list of snapshots and/or options: :restorable_by, :owner and :filters
|
149
|
+
#
|
150
|
+
# Options: :restorable_by => Array or String, :owner => Array or String, :filters => Hash
|
151
|
+
#
|
152
|
+
# Filters: description, owner-alias, owner-id, progress, snapshot-id, start-time, status, tag-key,
|
153
|
+
# tag-value, tag:key, volume-id, volume-size
|
154
|
+
#
|
155
|
+
# ec2.describe_snapshots #=>
|
144
156
|
# [ {:aws_volume_id=>"vol-545fac3d",
|
145
157
|
# :aws_description=>"Wikipedia XML Backups (Linux)",
|
146
158
|
# :aws_progress=>"100%",
|
147
|
-
# :aws_started_at=>
|
159
|
+
# :aws_started_at=>"2009-09-28T23:49:50.000Z",
|
148
160
|
# :aws_owner=>"amazon",
|
149
161
|
# :aws_id=>"snap-8041f2e9",
|
150
162
|
# :aws_volume_size=>500,
|
@@ -152,25 +164,29 @@ module RightAws
|
|
152
164
|
# {:aws_volume_id=>"vol-185fac71",
|
153
165
|
# :aws_description=>"Sloan Digital Sky Survey DR6 Subset (Linux)",
|
154
166
|
# :aws_progress=>"100%",
|
155
|
-
# :aws_started_at=>
|
167
|
+
# :aws_started_at=>"2009-09-28T23:56:10.000Z",
|
156
168
|
# :aws_owner=>"amazon",
|
157
169
|
# :aws_id=>"snap-3740f35e",
|
158
170
|
# :aws_volume_size=>180,
|
159
171
|
# :aws_status=>"completed"}, ...]
|
160
172
|
#
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
173
|
+
# ec2.describe_snapshots("snap-e676e28a", "snap-e176e281")
|
174
|
+
#
|
175
|
+
# ec2.describe_snapshots(:restorable_by => ['123456781234'],
|
176
|
+
# :owner => ['self', 'amazon'],
|
177
|
+
# :filters => {'tag:MyTag' => 'MyValue'})
|
178
|
+
#
|
179
|
+
# P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeSnapshots.html
|
180
|
+
#
|
181
|
+
def describe_snapshots(*list_and_options)
|
182
|
+
describe_resources_with_list_and_options('DescribeSnapshots', 'SnapshotId', QEc2DescribeSnapshotsParser, list_and_options)
|
167
183
|
end
|
168
184
|
|
169
185
|
# Create a snapshot of specified volume.
|
170
186
|
#
|
171
187
|
# ec2.create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
|
172
188
|
# {:aws_volume_id=>"vol-e429db8d",
|
173
|
-
# :aws_started_at=>
|
189
|
+
# :aws_started_at=>"2009-10-01T09:23:38.000Z",
|
174
190
|
# :aws_description=>"KD: WooHoo!!",
|
175
191
|
# :aws_owner=>"648770000000",
|
176
192
|
# :aws_progress=>"",
|
@@ -194,7 +210,7 @@ module RightAws
|
|
194
210
|
#
|
195
211
|
# ec2.try_create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
|
196
212
|
# {:aws_volume_id=>"vol-e429db8d",
|
197
|
-
# :aws_started_at=>
|
213
|
+
# :aws_started_at=>"2009-10-01T09:23:38.000Z",
|
198
214
|
# :aws_description=>"KD: WooHoo!!",
|
199
215
|
# :aws_owner=>"648770000000",
|
200
216
|
# :aws_progress=>"",
|
@@ -270,8 +286,8 @@ module RightAws
|
|
270
286
|
params = {'SnapshotId' => snapshot_id,
|
271
287
|
'Attribute' => attribute,
|
272
288
|
'OperationType' => operation_type}
|
273
|
-
params.update(amazonize_list('UserId', vars[:user_id]
|
274
|
-
params.update(amazonize_list('UserGroup', vars[:user_group]
|
289
|
+
params.update(amazonize_list('UserId', Array(vars[:user_id]))) if vars[:user_id]
|
290
|
+
params.update(amazonize_list('UserGroup', Array(vars[:user_group]))) if vars[:user_group]
|
275
291
|
link = generate_request("ModifySnapshotAttribute", params)
|
276
292
|
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
277
293
|
rescue Exception
|
@@ -300,7 +316,7 @@ module RightAws
|
|
300
316
|
#
|
301
317
|
def modify_snapshot_attribute_create_volume_permission_add_groups(snapshot_id, *user_group)
|
302
318
|
user_group.flatten!
|
303
|
-
user_group = ['all'] if user_group.
|
319
|
+
user_group = ['all'] if user_group.right_blank?
|
304
320
|
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'add', :user_group => user_group )
|
305
321
|
end
|
306
322
|
|
@@ -310,7 +326,7 @@ module RightAws
|
|
310
326
|
#
|
311
327
|
def modify_snapshot_attribute_create_volume_permission_remove_groups(snapshot_id, *user_group)
|
312
328
|
user_group.flatten!
|
313
|
-
user_group = ['all'] if user_group.
|
329
|
+
user_group = ['all'] if user_group.right_blank?
|
314
330
|
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', 'remove', :user_group => user_group )
|
315
331
|
end
|
316
332
|
|
@@ -335,9 +351,9 @@ module RightAws
|
|
335
351
|
case name
|
336
352
|
when 'volumeId' then @result[:aws_id] = @text
|
337
353
|
when 'status' then @result[:aws_status] = @text
|
338
|
-
when 'createTime' then @result[:aws_created_at] =
|
354
|
+
when 'createTime' then @result[:aws_created_at] = @text
|
339
355
|
when 'size' then @result[:aws_size] = @text.to_i ###
|
340
|
-
when 'snapshotId' then @result[:snapshot_id] = @text.
|
356
|
+
when 'snapshotId' then @result[:snapshot_id] = @text.right_blank? ? nil : @text ###
|
341
357
|
when 'availabilityZone' then @result[:zone] = @text ###
|
342
358
|
end
|
343
359
|
end
|
@@ -353,7 +369,7 @@ module RightAws
|
|
353
369
|
when 'instanceId' then @result[:aws_instance_id] = @text
|
354
370
|
when 'device' then @result[:aws_device] = @text
|
355
371
|
when 'status' then @result[:aws_attachment_status] = @text
|
356
|
-
when 'attachTime' then @result[:aws_attached_at] =
|
372
|
+
when 'attachTime' then @result[:aws_attached_at] = @text
|
357
373
|
end
|
358
374
|
end
|
359
375
|
def reset
|
@@ -363,34 +379,30 @@ module RightAws
|
|
363
379
|
|
364
380
|
class QEc2DescribeVolumesParser < RightAWSParser #:nodoc:
|
365
381
|
def tagstart(name, attributes)
|
366
|
-
case
|
367
|
-
when
|
368
|
-
|
369
|
-
when 'DescribeVolumesResponse/volumeSet' then @volume = {}
|
370
|
-
end
|
382
|
+
case full_tag_name
|
383
|
+
when %r{volumeSet/item$} then @item = { :tags => {} }
|
384
|
+
when %r{/tagSet/item$} then @aws_tag = {}
|
371
385
|
end
|
372
386
|
end
|
373
387
|
def tagend(name)
|
374
388
|
case name
|
375
|
-
when '
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
when '
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
case @xmlpath
|
393
|
-
when 'DescribeVolumesResponse/volumeSet' then @result << @volume
|
389
|
+
when 'size' then @item[:aws_size] = @text.to_i
|
390
|
+
when 'createTime' then @item[:aws_created_at] = @text
|
391
|
+
when 'instanceId' then @item[:aws_instance_id] = @text
|
392
|
+
when 'device' then @item[:aws_device] = @text
|
393
|
+
when 'attachTime' then @item[:aws_attached_at] = @text
|
394
|
+
when 'snapshotId' then @item[:snapshot_id] = @text.right_blank? ? nil : @text
|
395
|
+
when 'availabilityZone' then @item[:zone] = @text
|
396
|
+
when 'deleteOnTermination' then @item[:delete_on_termination] = (@text == 'true')
|
397
|
+
else
|
398
|
+
case full_tag_name
|
399
|
+
when %r{/volumeSet/item/volumeId$} then @item[:aws_id] = @text
|
400
|
+
when %r{/volumeSet/item/status$} then @item[:aws_status] = @text
|
401
|
+
when %r{/attachmentSet/item/status$} then @item[:aws_attachment_status] = @text
|
402
|
+
when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
|
403
|
+
when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
|
404
|
+
when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
|
405
|
+
when %r{/volumeSet/item$} then @result << @item
|
394
406
|
end
|
395
407
|
end
|
396
408
|
end
|
@@ -405,25 +417,33 @@ module RightAws
|
|
405
417
|
|
406
418
|
class QEc2DescribeSnapshotsParser < RightAWSParser #:nodoc:
|
407
419
|
def tagstart(name, attributes)
|
408
|
-
case
|
409
|
-
when
|
420
|
+
case full_tag_name
|
421
|
+
when %r{CreateSnapshotResponse$},
|
422
|
+
%r{/snapshotSet/item$} then @item = { :tags => {} }
|
423
|
+
when %r{/tagSet/item$} then @aws_tag = {}
|
410
424
|
end
|
411
425
|
end
|
412
426
|
def tagend(name)
|
413
427
|
case name
|
414
|
-
when 'volumeId' then @
|
415
|
-
when 'snapshotId' then @
|
416
|
-
when 'status' then @
|
417
|
-
when 'startTime' then @
|
418
|
-
when 'progress' then @
|
419
|
-
when 'description' then @
|
420
|
-
when 'ownerId' then @
|
421
|
-
when 'volumeSize' then @
|
422
|
-
|
428
|
+
when 'volumeId' then @item[:aws_volume_id] = @text
|
429
|
+
when 'snapshotId' then @item[:aws_id] = @text
|
430
|
+
when 'status' then @item[:aws_status] = @text
|
431
|
+
when 'startTime' then @item[:aws_started_at] = @text
|
432
|
+
when 'progress' then @item[:aws_progress] = @text
|
433
|
+
when 'description' then @item[:aws_description] = @text
|
434
|
+
when 'ownerId' then @item[:aws_owner] = @text
|
435
|
+
when 'volumeSize' then @item[:aws_volume_size] = @text.to_i
|
436
|
+
else
|
437
|
+
case full_tag_name
|
438
|
+
when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
|
439
|
+
when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
|
440
|
+
when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
|
441
|
+
when %r{CreateSnapshotResponse$},
|
442
|
+
%r{/snapshotSet/item$} then @result << @item
|
443
|
+
end
|
423
444
|
end
|
424
445
|
end
|
425
446
|
def reset
|
426
|
-
@each = ['item', 'CreateSnapshotResponse']
|
427
447
|
@result = []
|
428
448
|
end
|
429
449
|
end
|
data/lib/ec2/right_ec2_images.rb
CHANGED
@@ -35,32 +35,28 @@ module RightAws
|
|
35
35
|
# 'Owner' => ['self', ..., 'userN'],
|
36
36
|
# 'ExecutableBy' => ['self', 'all', ..., 'userN']
|
37
37
|
# }
|
38
|
-
def ec2_describe_images(params={},
|
38
|
+
def ec2_describe_images(params={}, options={}, cache_for=nil) #:nodoc:
|
39
39
|
request_hash = {}
|
40
|
-
params.each
|
41
|
-
|
42
|
-
end
|
43
|
-
request_hash['ImageType'] = image_type if image_type
|
40
|
+
params.each { |list_by, list| request_hash.merge! amazonize_list(list_by, Array(list)) }
|
41
|
+
request_hash.merge!(amazonize_list(['Filter.?.Name', 'Filter.?.Value.?'], options[:filters])) unless options[:filters].right_blank?
|
44
42
|
link = generate_request("DescribeImages", request_hash)
|
45
43
|
request_cache_or_info cache_for, link, QEc2DescribeImagesParser, @@bench, cache_for
|
46
44
|
rescue Exception
|
47
45
|
on_exception
|
48
46
|
end
|
49
47
|
|
50
|
-
# Retrieve a list of images.
|
51
|
-
#
|
48
|
+
# Retrieve a list of images.
|
49
|
+
#
|
50
|
+
# Accepts a list of images and/or a set of filters as the last parameter.
|
51
|
+
#
|
52
|
+
# Filters: architecture, block-device-mapping.delete-on-termination block-device-mapping.device-name,
|
53
|
+
# block-device-mapping.snapshot-id, block-device-mapping.volume-size, description, image-id, image-type,
|
54
|
+
# is-public, kernel-id, manifest-location, name, owner-alias, owner-id, platform, product-code,
|
55
|
+
# ramdisk-id, root-device-name, root-device-type, state, state-reason-code, state-reason-message,
|
56
|
+
# tag-key, tag-value, tag:key, virtualization-type
|
52
57
|
#
|
53
58
|
# ec2.describe_images #=>
|
54
|
-
# [{:
|
55
|
-
# :aws_image_type=>"machine",
|
56
|
-
# :root_device_name=>"/dev/sda1",
|
57
|
-
# :image_class=>"static",
|
58
|
-
# :aws_owner=>"826693181925",
|
59
|
-
# :aws_location=>"bucket_for_k_dzreyev/image_bundles/kd__CentOS_1_10_2009_10_21_13_30_43_MSD/image.manifest.xml",
|
60
|
-
# :aws_state=>"available",
|
61
|
-
# :aws_is_public=>false,
|
62
|
-
# :aws_architecture=>"i386"},
|
63
|
-
# {:description=>"EBS backed Fedora core 8 i386",
|
59
|
+
# [{:description=>"EBS backed Fedora core 8 i386",
|
64
60
|
# :aws_architecture=>"i386",
|
65
61
|
# :aws_id=>"ami-c2a3f5d4",
|
66
62
|
# :aws_image_type=>"machine",
|
@@ -75,43 +71,79 @@ module RightAws
|
|
75
71
|
# :device_name=>"/dev/sda1"}],
|
76
72
|
# :name=>"EBS backed FC8 i386",
|
77
73
|
# :aws_is_public=>true}, ... ]
|
78
|
-
#
|
79
|
-
# If +list+ param is set, then retrieve information about the listed images only:
|
80
74
|
#
|
81
|
-
# ec2.describe_images(
|
75
|
+
# ec2.describe_images(:filters => { 'image-type' => 'kernel', 'state' => 'available', 'tag:MyTag' => 'MyValue'})
|
76
|
+
#
|
77
|
+
# ec2.describe_images("ari-fda54b94", "ami-2ee80247", "aki-00896a69",
|
78
|
+
# :filters => { 'image-type' => 'kernel', 'state' => 'available' }) #=>
|
79
|
+
# [{:root_device_type=>"instance-store",
|
80
|
+
# :aws_id=>"aki-00896a69",
|
81
|
+
# :aws_image_type=>"kernel",
|
82
|
+
# :aws_location=>
|
83
|
+
# "karmic-kernel-zul/ubuntu-kernel-2.6.31-300-ec2-i386-20091002-test-04.manifest.xml",
|
84
|
+
# :virtualization_type=>"paravirtual",
|
85
|
+
# :aws_state=>"available",
|
86
|
+
# :aws_owner=>"099720109477",
|
87
|
+
# :tags=>{},
|
88
|
+
# :aws_is_public=>true,
|
89
|
+
# :aws_architecture=>"i386"}]
|
90
|
+
#
|
91
|
+
# P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImages.html
|
82
92
|
#
|
83
|
-
def describe_images(
|
84
|
-
list =
|
85
|
-
cache_for
|
86
|
-
ec2_describe_images({
|
93
|
+
def describe_images(*list_and_options)
|
94
|
+
list, options = AwsUtils::split_items_and_params(list_and_options)
|
95
|
+
cache_for = (list.right_blank? && options[:filters].right_blank?) ? :describe_images : nil
|
96
|
+
ec2_describe_images( {'ImageId'=>list}, options, cache_for)
|
87
97
|
end
|
88
98
|
|
89
|
-
#
|
99
|
+
# Retrieve a list of images by image owner.
|
100
|
+
#
|
101
|
+
# Accepts a list of images and/or a set of filters as the last parameter.
|
102
|
+
#
|
103
|
+
# Filters: architecture, block-device-mapping.delete-on-termination block-device-mapping.device-name,
|
104
|
+
# block-device-mapping.snapshot-id, block-device-mapping.volume-size, description, image-id, image-type,
|
105
|
+
# is-public, kernel-id, manifest-location, name, owner-alias, owner-id, platform, product-code,
|
106
|
+
# ramdisk-id, root-device-name, root-device-type, state, state-reason-code, state-reason-message,
|
107
|
+
# tag-key, tag-value, tag:key, virtualization-type
|
90
108
|
#
|
91
109
|
# ec2.describe_images_by_owner('522821470517')
|
92
|
-
# ec2.describe_images_by_owner('self')
|
110
|
+
# ec2.describe_images_by_owner('self', :filters => { 'block-device-mapping.delete-on-termination' => 'false' })
|
93
111
|
#
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
112
|
+
# P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImages.html
|
113
|
+
#
|
114
|
+
def describe_images_by_owner(*list_and_options)
|
115
|
+
list, options = AwsUtils::split_items_and_params(list_and_options)
|
116
|
+
list = ['self'] if list.right_blank?
|
117
|
+
cache_for = (list==['self'] && options[:filters].right_blank?) ? :describe_images_by_owner : nil
|
118
|
+
ec2_describe_images( {'Owner'=>list}, options, cache_for)
|
98
119
|
end
|
99
120
|
|
100
|
-
#
|
121
|
+
# Retrieve a list of images by image executable by.
|
122
|
+
#
|
123
|
+
# Accepts a list of images and/or a set of filters as the last parameter.
|
124
|
+
#
|
125
|
+
# Filters: architecture, block-device-mapping.delete-on-termination block-device-mapping.device-name,
|
126
|
+
# block-device-mapping.snapshot-id, block-device-mapping.volume-size, description, image-id, image-type,
|
127
|
+
# is-public, kernel-id, manifest-location, name, owner-alias, owner-id, platform, product-code,
|
128
|
+
# ramdisk-id, root-device-name, root-device-type, state, state-reason-code, state-reason-message,
|
129
|
+
# tag-key, tag-value, tag:key, virtualization-type
|
101
130
|
#
|
102
131
|
# ec2.describe_images_by_executable_by('522821470517')
|
103
132
|
# ec2.describe_images_by_executable_by('self')
|
104
|
-
# ec2.describe_images_by_executable_by('all')
|
133
|
+
# ec2.describe_images_by_executable_by('all', :filters => { 'architecture' => 'i386' })
|
134
|
+
#
|
135
|
+
# P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImages.html
|
105
136
|
#
|
106
|
-
def describe_images_by_executable_by(
|
107
|
-
list =
|
108
|
-
|
109
|
-
|
137
|
+
def describe_images_by_executable_by(*list_and_options)
|
138
|
+
list, options = AwsUtils::split_items_and_params(list_and_options)
|
139
|
+
list = ['self'] if list.right_blank?
|
140
|
+
cache_for = (list==['self'] && options[:filters].right_blank?) ? :describe_images_by_executable_by : nil
|
141
|
+
ec2_describe_images( {'ExecutableBy'=>list}, options, cache_for)
|
110
142
|
end
|
111
143
|
|
112
|
-
|
113
144
|
# Register new image at Amazon.
|
114
|
-
# Options: :image_location, :name, :description, :architecture, :kernel_id, :ramdisk_id,
|
145
|
+
# Options: :image_location, :name, :description, :architecture, :kernel_id, :ramdisk_id,
|
146
|
+
# :root_device_name, :block_device_mappings, :virtualizationt_type(hvm|paravirtual)
|
115
147
|
#
|
116
148
|
# Returns new image id.
|
117
149
|
#
|
@@ -148,6 +180,7 @@ module RightAws
|
|
148
180
|
params['KernelId'] = options[:kernel_id] if options[:kernel_id]
|
149
181
|
params['RamdiskId'] = options[:ramdisk_id] if options[:ramdisk_id]
|
150
182
|
params['RootDeviceName'] = options[:root_device_name] if options[:root_device_name]
|
183
|
+
params['VirtualizationType'] = options[:virtualization_type] if options[:virtualization_type]
|
151
184
|
# params['SnapshotId'] = options[:snapshot_id] if options[:snapshot_id]
|
152
185
|
params.merge!(amazonize_block_device_mappings(options[:block_device_mappings]))
|
153
186
|
link = generate_request("RegisterImage", params)
|
@@ -209,9 +242,9 @@ module RightAws
|
|
209
242
|
params = {'ImageId' => image_id,
|
210
243
|
'Attribute' => attribute}
|
211
244
|
params['OperationType'] = operation_type if operation_type
|
212
|
-
params.update(amazonize_list('UserId', vars[:user_id]
|
213
|
-
params.update(amazonize_list('UserGroup', vars[:user_group]
|
214
|
-
params.update(amazonize_list('ProductCode', vars[:product_code]))
|
245
|
+
params.update(amazonize_list('UserId', vars[:user_id])) if vars[:user_id]
|
246
|
+
params.update(amazonize_list('UserGroup', vars[:user_group])) if vars[:user_group]
|
247
|
+
params.update(amazonize_list('ProductCode', vars[:product_code])) if vars[:product_code]
|
215
248
|
link = generate_request("ModifyImageAttribute", params)
|
216
249
|
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
217
250
|
rescue Exception
|
@@ -224,7 +257,7 @@ module RightAws
|
|
224
257
|
#
|
225
258
|
# ec2.modify_image_launch_perm_add_users('ami-e444444d',['000000000777','000000000778']) #=> true
|
226
259
|
def modify_image_launch_perm_add_users(image_id, user_id=[])
|
227
|
-
modify_image_attribute(image_id, 'launchPermission', 'add', :user_id => user_id
|
260
|
+
modify_image_attribute(image_id, 'launchPermission', 'add', :user_id => user_id)
|
228
261
|
end
|
229
262
|
|
230
263
|
# Revokes image launch permissions for users. +user_id+ is a list of users AWS accounts ids. Returns +true+ or an exception.
|
@@ -232,7 +265,7 @@ module RightAws
|
|
232
265
|
# ec2.modify_image_launch_perm_remove_users('ami-e444444d',['000000000777','000000000778']) #=> true
|
233
266
|
#
|
234
267
|
def modify_image_launch_perm_remove_users(image_id, user_id=[])
|
235
|
-
modify_image_attribute(image_id, 'launchPermission', 'remove', :user_id => user_id
|
268
|
+
modify_image_attribute(image_id, 'launchPermission', 'remove', :user_id => user_id)
|
236
269
|
end
|
237
270
|
|
238
271
|
# Add image launch permissions for users groups (currently only 'all' is supported, which gives public launch permissions).
|
@@ -241,7 +274,7 @@ module RightAws
|
|
241
274
|
# ec2.modify_image_launch_perm_add_groups('ami-e444444d') #=> true
|
242
275
|
#
|
243
276
|
def modify_image_launch_perm_add_groups(image_id, user_group=['all'])
|
244
|
-
modify_image_attribute(image_id, 'launchPermission', 'add', :user_group => user_group
|
277
|
+
modify_image_attribute(image_id, 'launchPermission', 'add', :user_group => user_group)
|
245
278
|
end
|
246
279
|
|
247
280
|
# Remove image launch permissions for users groups (currently only 'all' is supported, which gives public launch permissions).
|
@@ -249,7 +282,7 @@ module RightAws
|
|
249
282
|
# ec2.modify_image_launch_perm_remove_groups('ami-e444444d') #=> true
|
250
283
|
#
|
251
284
|
def modify_image_launch_perm_remove_groups(image_id, user_group=['all'])
|
252
|
-
modify_image_attribute(image_id, 'launchPermission', 'remove', :user_group => user_group
|
285
|
+
modify_image_attribute(image_id, 'launchPermission', 'remove', :user_group => user_group)
|
253
286
|
end
|
254
287
|
|
255
288
|
# Add product code to image
|
@@ -257,7 +290,7 @@ module RightAws
|
|
257
290
|
# ec2.modify_image_product_code('ami-e444444d','0ABCDEF') #=> true
|
258
291
|
#
|
259
292
|
def modify_image_product_code(image_id, product_code=[])
|
260
|
-
modify_image_attribute(image_id, 'productCodes', nil, :product_code => product_code
|
293
|
+
modify_image_attribute(image_id, 'productCodes', nil, :product_code => product_code)
|
261
294
|
end
|
262
295
|
|
263
296
|
# Create a new image.
|
@@ -269,8 +302,8 @@ module RightAws
|
|
269
302
|
#
|
270
303
|
def create_image(instance_aws_id, options={})
|
271
304
|
params = { 'InstanceId' => instance_aws_id }
|
272
|
-
params['Name'] = options[:name] unless options[:name].
|
273
|
-
params['Description'] = options[:description] unless options[:description].
|
305
|
+
params['Name'] = options[:name] unless options[:name].right_blank?
|
306
|
+
params['Description'] = options[:description] unless options[:description].right_blank?
|
274
307
|
params['NoReboot'] = options[:no_reboot].to_s unless options[:no_reboot].nil?
|
275
308
|
link = generate_request("CreateImage", params)
|
276
309
|
request_info(link, QEc2RegisterImageParser.new(:logger => @logger))
|
@@ -283,10 +316,13 @@ module RightAws
|
|
283
316
|
class QEc2DescribeImagesParser < RightAWSParser #:nodoc:
|
284
317
|
def tagstart(name, attributes)
|
285
318
|
case full_tag_name
|
286
|
-
when %r{/imagesSet/item$}
|
319
|
+
when %r{/imagesSet/item$}
|
320
|
+
@item = { :tags => {} }
|
287
321
|
when %r{/blockDeviceMapping/item$}
|
288
322
|
@item[:block_device_mappings] ||= []
|
289
323
|
@block_device_mapping = {}
|
324
|
+
when %r{/tagSet/item$}
|
325
|
+
@aws_tag = {}
|
290
326
|
end
|
291
327
|
end
|
292
328
|
def tagend(name)
|
@@ -308,6 +344,7 @@ module RightAws
|
|
308
344
|
when 'rootDeviceType' then @item[:root_device_type] = @text
|
309
345
|
when 'rootDeviceName' then @item[:root_device_name] = @text
|
310
346
|
when 'imageClass' then @item[:image_class] = @text
|
347
|
+
when 'virtualizationType' then @item[:virtualization_type] = @text
|
311
348
|
else
|
312
349
|
case full_tag_name
|
313
350
|
when %r{/stateReason/code$} then @item[:state_reason_code] = @text.to_i
|
@@ -321,7 +358,10 @@ module RightAws
|
|
321
358
|
when 'deleteOnTermination' then @block_device_mapping[:ebs_delete_on_termination] = @text == 'true' ? true : false
|
322
359
|
when 'item' then @item[:block_device_mappings] << @block_device_mapping
|
323
360
|
end
|
324
|
-
when %r{/
|
361
|
+
when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
|
362
|
+
when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
|
363
|
+
when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
|
364
|
+
when %r{/imagesSet/item$} then @result << @item
|
325
365
|
end
|
326
366
|
end
|
327
367
|
end
|