aboisvert_aws 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +329 -0
- data/Manifest.txt +61 -0
- data/README.txt +163 -0
- data/Rakefile +130 -0
- data/lib/acf/right_acf_interface.rb +549 -0
- 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 +248 -0
- data/lib/as/right_as_interface.rb +698 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/right_awsbase.rb +1343 -0
- data/lib/awsbase/support.rb +35 -0
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +541 -0
- data/lib/ec2/right_ec2_ebs.rb +481 -0
- data/lib/ec2/right_ec2_images.rb +444 -0
- data/lib/ec2/right_ec2_instances.rb +788 -0
- data/lib/ec2/right_ec2_monitoring.rb +70 -0
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +184 -0
- data/lib/ec2/right_ec2_security_groups.rb +491 -0
- data/lib/ec2/right_ec2_spot_instances.rb +422 -0
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +590 -0
- data/lib/ec2/right_ec2_vpc2.rb +381 -0
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +573 -0
- data/lib/emr/right_emr_interface.rb +727 -0
- 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 +1384 -0
- data/lib/right_aws.rb +86 -0
- data/lib/route_53/right_route_53_interface.rb +640 -0
- data/lib/s3/right_s3.rb +1138 -0
- data/lib/s3/right_s3_interface.rb +1278 -0
- data/lib/sdb/active_sdb.rb +1107 -0
- data/lib/sdb/right_sdb_interface.rb +762 -0
- data/lib/sns/right_sns_interface.rb +286 -0
- data/lib/sqs/right_sqs.rb +387 -0
- data/lib/sqs/right_sqs_gen2.rb +342 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +523 -0
- data/lib/sqs/right_sqs_interface.rb +593 -0
- data/right_aws.gemspec +90 -0
- data/test/README.mdown +39 -0
- data/test/acf/test_helper.rb +2 -0
- data/test/acf/test_right_acf.rb +138 -0
- data/test/awsbase/test_helper.rb +2 -0
- data/test/awsbase/test_right_awsbase.rb +11 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_right_ec2.rb +107 -0
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/http_connection.rb +87 -0
- data/test/rds/test_helper.rb +2 -0
- data/test/rds/test_right_rds.rb +120 -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 +2 -0
- data/test/s3/test_right_s3.rb +528 -0
- data/test/s3/test_right_s3_stubbed.rb +97 -0
- data/test/sdb/test_active_sdb.rb +357 -0
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sdb/test_helper.rb +3 -0
- data/test/sdb/test_right_sdb.rb +253 -0
- data/test/sns/test_helper.rb +2 -0
- data/test/sns/test_right_sns.rb +153 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_right_sqs.rb +285 -0
- data/test/sqs/test_right_sqs_gen2.rb +264 -0
- data/test/test_credentials.rb +37 -0
- data/test/ts_right_aws.rb +15 -0
- metadata +257 -0
@@ -0,0 +1,481 @@
|
|
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 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 #=>
|
156
|
+
# [{:aws_volume_size=>2,
|
157
|
+
# :tags=>{},
|
158
|
+
# :aws_id=>"snap-d010f6b9",
|
159
|
+
# :owner_alias=>"amazon",
|
160
|
+
# :aws_progress=>"100%",
|
161
|
+
# :aws_status=>"completed",
|
162
|
+
# :aws_description=>
|
163
|
+
# "Windows 2003 R2 Installation Media [Deprecated] - Enterprise Edition 64-bit",
|
164
|
+
# :aws_owner=>"711940113766",
|
165
|
+
# :aws_volume_id=>"vol-351efb5c",
|
166
|
+
# :aws_started_at=>"2008-10-20T18:23:59.000Z"},
|
167
|
+
# {:aws_volume_size=>2,
|
168
|
+
# :tags=>{},
|
169
|
+
# :aws_id=>"snap-a310f6ca",
|
170
|
+
# :owner_alias=>"amazon",
|
171
|
+
# :aws_progress=>"100%",
|
172
|
+
# :aws_status=>"completed",
|
173
|
+
# :aws_description=>"Windows 2003 R2 Installation Media 64-bit",
|
174
|
+
# :aws_owner=>"711940113766",
|
175
|
+
# :aws_volume_id=>"vol-001efb69",
|
176
|
+
# :aws_started_at=>"2008-10-20T18:25:53.000Z"}, ... ]
|
177
|
+
#
|
178
|
+
# ec2.describe_snapshots("snap-e676e28a", "snap-e176e281")
|
179
|
+
#
|
180
|
+
# ec2.describe_snapshots(:restorable_by => ['123456781234'],
|
181
|
+
# :owner => ['self', 'amazon'],
|
182
|
+
# :filters => {'tag:MyTag' => 'MyValue'})
|
183
|
+
#
|
184
|
+
# P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeSnapshots.html
|
185
|
+
#
|
186
|
+
def describe_snapshots(*list_and_options)
|
187
|
+
describe_resources_with_list_and_options('DescribeSnapshots', 'SnapshotId', QEc2DescribeSnapshotsParser, list_and_options)
|
188
|
+
end
|
189
|
+
|
190
|
+
def describe_snapshots_by_restorable_by(*list_and_options)
|
191
|
+
describe_resources_with_list_and_options('DescribeSnapshots', 'RestorableBy', QEc2DescribeSnapshotsParser, list_and_options)
|
192
|
+
end
|
193
|
+
|
194
|
+
# Create a snapshot of specified volume.
|
195
|
+
#
|
196
|
+
# ec2.create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
|
197
|
+
# {:aws_volume_id=>"vol-e429db8d",
|
198
|
+
# :aws_started_at=>"2009-10-01T09:23:38.000Z",
|
199
|
+
# :aws_description=>"KD: WooHoo!!",
|
200
|
+
# :aws_owner=>"648770000000",
|
201
|
+
# :aws_progress=>"",
|
202
|
+
# :aws_status=>"pending",
|
203
|
+
# :aws_volume_size=>1,
|
204
|
+
# :aws_id=>"snap-3df54854"}
|
205
|
+
#
|
206
|
+
def create_snapshot(volume_id, description='')
|
207
|
+
link = generate_request("CreateSnapshot",
|
208
|
+
"VolumeId" => volume_id.to_s,
|
209
|
+
"Description" => description)
|
210
|
+
request_info(link, QEc2DescribeSnapshotsParser.new(:logger => @logger)).first
|
211
|
+
rescue Exception
|
212
|
+
on_exception
|
213
|
+
end
|
214
|
+
|
215
|
+
# Create a snapshot of specified volume, but with the normal retry algorithms disabled.
|
216
|
+
# This method will return immediately upon error. The user can specify connect and read timeouts (in s)
|
217
|
+
# for the connection to AWS. If the user does not specify timeouts, try_create_snapshot uses the default values
|
218
|
+
# in Rightscale::HttpConnection.
|
219
|
+
#
|
220
|
+
# ec2.try_create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
|
221
|
+
# {:aws_volume_id=>"vol-e429db8d",
|
222
|
+
# :aws_started_at=>"2009-10-01T09:23:38.000Z",
|
223
|
+
# :aws_description=>"KD: WooHoo!!",
|
224
|
+
# :aws_owner=>"648770000000",
|
225
|
+
# :aws_progress=>"",
|
226
|
+
# :aws_status=>"pending",
|
227
|
+
# :aws_volume_size=>1,
|
228
|
+
# :aws_id=>"snap-3df54854"}
|
229
|
+
#
|
230
|
+
def try_create_snapshot(volume_id, connect_timeout = nil, read_timeout = nil, description='')
|
231
|
+
# For safety in the ensure block...we don't want to restore values
|
232
|
+
# if we never read them in the first place
|
233
|
+
orig_reiteration_time = nil
|
234
|
+
orig_http_params = nil
|
235
|
+
|
236
|
+
orig_reiteration_time = RightAws::AWSErrorHandler::reiteration_time
|
237
|
+
RightAws::AWSErrorHandler::reiteration_time = 0
|
238
|
+
|
239
|
+
orig_http_params = Rightscale::HttpConnection::params()
|
240
|
+
new_http_params = orig_http_params.dup
|
241
|
+
new_http_params[:http_connection_retry_count] = 0
|
242
|
+
new_http_params[:http_connection_open_timeout] = connect_timeout if !connect_timeout.nil?
|
243
|
+
new_http_params[:http_connection_read_timeout] = read_timeout if !read_timeout.nil?
|
244
|
+
Rightscale::HttpConnection::params = new_http_params
|
245
|
+
|
246
|
+
link = generate_request("CreateSnapshot",
|
247
|
+
"VolumeId" => volume_id.to_s,
|
248
|
+
"Description" => description)
|
249
|
+
request_info(link, QEc2DescribeSnapshotsParser.new(:logger => @logger)).first
|
250
|
+
|
251
|
+
rescue Exception
|
252
|
+
on_exception
|
253
|
+
ensure
|
254
|
+
RightAws::AWSErrorHandler::reiteration_time = orig_reiteration_time if orig_reiteration_time
|
255
|
+
Rightscale::HttpConnection::params = orig_http_params if orig_http_params
|
256
|
+
end
|
257
|
+
|
258
|
+
# Describe snapshot attribute.
|
259
|
+
#
|
260
|
+
# ec2.describe_snapshot_attribute('snap-36fe435f') #=>
|
261
|
+
# {:create_volume_permission=>
|
262
|
+
# {:users=>["826690000000", "826690000001"], :groups=>['all']}}
|
263
|
+
#
|
264
|
+
def describe_snapshot_attribute(snapshot_id, attribute='createVolumePermission')
|
265
|
+
link = generate_request("DescribeSnapshotAttribute",
|
266
|
+
'SnapshotId'=> snapshot_id,
|
267
|
+
'Attribute' => attribute)
|
268
|
+
request_info(link, QEc2DescribeSnapshotAttributeParser.new(:logger => @logger))
|
269
|
+
rescue Exception
|
270
|
+
on_exception
|
271
|
+
end
|
272
|
+
|
273
|
+
# Reset permission settings for the specified snapshot.
|
274
|
+
#
|
275
|
+
# ec2.reset_snapshot_attribute('snap-cecd29a7') #=> true
|
276
|
+
#
|
277
|
+
def reset_snapshot_attribute(snapshot_id, attribute='createVolumePermission')
|
278
|
+
link = generate_request("ResetSnapshotAttribute",
|
279
|
+
'SnapshotId' => snapshot_id,
|
280
|
+
'Attribute' => attribute)
|
281
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
282
|
+
rescue Exception
|
283
|
+
on_exception
|
284
|
+
end
|
285
|
+
|
286
|
+
# Modify snapshot attribute.
|
287
|
+
#
|
288
|
+
# Attribute can take only 'createVolumePermission' value.
|
289
|
+
# Value is a Hash {:add_user_ids, :add_groups, :remove_user_ids, :remove_groups }.
|
290
|
+
#
|
291
|
+
def modify_snapshot_attribute(snapshot_id, attribute, value)
|
292
|
+
params = { 'SnapshotId' => snapshot_id }
|
293
|
+
case attribute.to_s
|
294
|
+
when 'createVolumePermission'
|
295
|
+
params.update(amazonize_list('CreateVolumePermission.Add.?.UserId', value[:add_user_ids]))
|
296
|
+
params.update(amazonize_list('CreateVolumePermission.Add.?.Group', value[:add_groups]))
|
297
|
+
params.update(amazonize_list('CreateVolumePermission.Remove.?.UserId', value[:remove_user_ids]))
|
298
|
+
params.update(amazonize_list('CreateVolumePermission.Remove.?.Group', value[:remove_groups]))
|
299
|
+
end
|
300
|
+
link = generate_request("ModifySnapshotAttribute", params)
|
301
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
302
|
+
rescue Exception
|
303
|
+
on_exception
|
304
|
+
end
|
305
|
+
|
306
|
+
# Grant create volume permission for a list of users.
|
307
|
+
#
|
308
|
+
# ec2.modify_snapshot_attribute_create_volume_permission_add_users('snap-36fe435f', '000000000000', '000000000001') #=> true
|
309
|
+
#
|
310
|
+
def modify_snapshot_attribute_create_volume_permission_add_users(snapshot_id, *user_ids)
|
311
|
+
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', :add_user_ids => user_ids.flatten )
|
312
|
+
end
|
313
|
+
|
314
|
+
# Revoke create volume permission for a list of users.
|
315
|
+
#
|
316
|
+
# ec2.modify_snapshot_attribute_create_volume_permission_remove_users('snap-36fe435f', '000000000000', '000000000001') #=> true
|
317
|
+
#
|
318
|
+
def modify_snapshot_attribute_create_volume_permission_remove_users(snapshot_id, *user_ids)
|
319
|
+
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', :remove_user_ids => user_ids.flatten )
|
320
|
+
end
|
321
|
+
|
322
|
+
# Grant create volume permission for user groups (currently only 'all' is supported).
|
323
|
+
#
|
324
|
+
# ec2.modify_snapshot_attribute_create_volume_permission_add_groups('snap-36fe435f') #=> true
|
325
|
+
#
|
326
|
+
def modify_snapshot_attribute_create_volume_permission_add_groups(snapshot_id, *groups)
|
327
|
+
groups.flatten!
|
328
|
+
groups = ['all'] if groups.right_blank?
|
329
|
+
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', :add_groups => groups )
|
330
|
+
end
|
331
|
+
|
332
|
+
# Remove create volume permission for user groups (currently only 'all' is supported).
|
333
|
+
#
|
334
|
+
# ec2.modify_snapshot_attribute_create_volume_permission_remove_groups('snap-36fe435f') #=> true
|
335
|
+
#
|
336
|
+
def modify_snapshot_attribute_create_volume_permission_remove_groups(snapshot_id, *groups)
|
337
|
+
groups.flatten!
|
338
|
+
groups = ['all'] if groups.right_blank?
|
339
|
+
modify_snapshot_attribute(snapshot_id, 'createVolumePermission', :remove_groups => groups )
|
340
|
+
end
|
341
|
+
|
342
|
+
# Delete the specified snapshot.
|
343
|
+
#
|
344
|
+
# ec2.delete_snapshot('snap-55a5403c') #=> true
|
345
|
+
#
|
346
|
+
def delete_snapshot(snapshot_id)
|
347
|
+
link = generate_request("DeleteSnapshot",
|
348
|
+
"SnapshotId" => snapshot_id.to_s)
|
349
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
350
|
+
rescue Exception
|
351
|
+
on_exception
|
352
|
+
end
|
353
|
+
|
354
|
+
#-----------------------------------------------------------------
|
355
|
+
# PARSERS: EBS - Volumes
|
356
|
+
#-----------------------------------------------------------------
|
357
|
+
|
358
|
+
class QEc2CreateVolumeParser < RightAWSParser #:nodoc:
|
359
|
+
def tagend(name)
|
360
|
+
case name
|
361
|
+
when 'volumeId' then @result[:aws_id] = @text
|
362
|
+
when 'status' then @result[:aws_status] = @text
|
363
|
+
when 'createTime' then @result[:aws_created_at] = @text
|
364
|
+
when 'size' then @result[:aws_size] = @text.to_i ###
|
365
|
+
when 'snapshotId' then @result[:snapshot_id] = @text.right_blank? ? nil : @text ###
|
366
|
+
when 'availabilityZone' then @result[:zone] = @text ###
|
367
|
+
end
|
368
|
+
end
|
369
|
+
def reset
|
370
|
+
@result = {}
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
class QEc2AttachAndDetachVolumeParser < RightAWSParser #:nodoc:
|
375
|
+
def tagend(name)
|
376
|
+
case name
|
377
|
+
when 'volumeId' then @result[:aws_id] = @text
|
378
|
+
when 'instanceId' then @result[:aws_instance_id] = @text
|
379
|
+
when 'device' then @result[:aws_device] = @text
|
380
|
+
when 'status' then @result[:aws_attachment_status] = @text
|
381
|
+
when 'attachTime' then @result[:aws_attached_at] = @text
|
382
|
+
end
|
383
|
+
end
|
384
|
+
def reset
|
385
|
+
@result = {}
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
class QEc2DescribeVolumesParser < RightAWSParser #:nodoc:
|
390
|
+
def tagstart(name, attributes)
|
391
|
+
case full_tag_name
|
392
|
+
when %r{volumeSet/item$} then @item = { :tags => {} }
|
393
|
+
when %r{/tagSet/item$} then @aws_tag = {}
|
394
|
+
end
|
395
|
+
end
|
396
|
+
def tagend(name)
|
397
|
+
case name
|
398
|
+
when 'size' then @item[:aws_size] = @text.to_i
|
399
|
+
when 'createTime' then @item[:aws_created_at] = @text
|
400
|
+
when 'instanceId' then @item[:aws_instance_id] = @text
|
401
|
+
when 'device' then @item[:aws_device] = @text
|
402
|
+
when 'attachTime' then @item[:aws_attached_at] = @text
|
403
|
+
when 'snapshotId' then @item[:snapshot_id] = @text.right_blank? ? nil : @text
|
404
|
+
when 'availabilityZone' then @item[:zone] = @text
|
405
|
+
when 'deleteOnTermination' then @item[:delete_on_termination] = (@text == 'true')
|
406
|
+
else
|
407
|
+
case full_tag_name
|
408
|
+
when %r{/volumeSet/item/volumeId$} then @item[:aws_id] = @text
|
409
|
+
when %r{/volumeSet/item/status$} then @item[:aws_status] = @text
|
410
|
+
when %r{/attachmentSet/item/status$} then @item[:aws_attachment_status] = @text
|
411
|
+
when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
|
412
|
+
when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
|
413
|
+
when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
|
414
|
+
when %r{/volumeSet/item$} then @result << @item
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
def reset
|
419
|
+
@result = []
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
#-----------------------------------------------------------------
|
424
|
+
# PARSERS: EBS - Snapshots
|
425
|
+
#-----------------------------------------------------------------
|
426
|
+
|
427
|
+
class QEc2DescribeSnapshotsParser < RightAWSParser #:nodoc:
|
428
|
+
def tagstart(name, attributes)
|
429
|
+
case full_tag_name
|
430
|
+
when %r{CreateSnapshotResponse$},
|
431
|
+
%r{/snapshotSet/item$} then @item = { :tags => {} }
|
432
|
+
when %r{/tagSet/item$} then @aws_tag = {}
|
433
|
+
end
|
434
|
+
end
|
435
|
+
def tagend(name)
|
436
|
+
case name
|
437
|
+
when 'volumeId' then @item[:aws_volume_id] = @text
|
438
|
+
when 'snapshotId' then @item[:aws_id] = @text
|
439
|
+
when 'status' then @item[:aws_status] = @text
|
440
|
+
when 'startTime' then @item[:aws_started_at] = @text
|
441
|
+
when 'progress' then @item[:aws_progress] = @text
|
442
|
+
when 'description' then @item[:aws_description] = @text
|
443
|
+
when 'ownerId' then @item[:aws_owner] = @text
|
444
|
+
when 'volumeSize' then @item[:aws_volume_size] = @text.to_i
|
445
|
+
when 'ownerAlias' then @item[:owner_alias] = @text
|
446
|
+
else
|
447
|
+
case full_tag_name
|
448
|
+
when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
|
449
|
+
when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
|
450
|
+
when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
|
451
|
+
when %r{CreateSnapshotResponse$},
|
452
|
+
%r{/snapshotSet/item$} then @result << @item
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
def reset
|
457
|
+
@result = []
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
class QEc2DescribeSnapshotAttributeParser < RightAWSParser #:nodoc:
|
462
|
+
def tagstart(name, attributes)
|
463
|
+
case name
|
464
|
+
when 'createVolumePermission' then @result[:create_volume_permission] = { :groups => [], :users => [] }
|
465
|
+
end
|
466
|
+
end
|
467
|
+
def tagend(name)
|
468
|
+
case full_tag_name
|
469
|
+
when "#{@create_volume_permission}/group" then @result[:create_volume_permission][:groups] << @text
|
470
|
+
when "#{@create_volume_permission}/userId" then @result[:create_volume_permission][:users] << @text
|
471
|
+
end
|
472
|
+
end
|
473
|
+
def reset
|
474
|
+
@create_volume_permission = "DescribeSnapshotAttributeResponse/createVolumePermission/item"
|
475
|
+
@result = {}
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
end
|
480
|
+
|
481
|
+
end
|