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,35 @@
1
+ # These are ActiveSupport-;like extensions to do a few handy things in the gems
2
+ # Derived from ActiveSupport, so the AS copyright notice applies:
3
+ #
4
+ #
5
+ #
6
+ # Copyright (c) 2005 David Heinemeier Hansson
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining
9
+ # a copy of this software and associated documentation files (the
10
+ # "Software"), to deal in the Software without restriction, including
11
+ # without limitation the rights to use, copy, modify, merge, publish,
12
+ # distribute, sublicense, and/or sell copies of the Software, and to
13
+ # permit persons to whom the Software is furnished to do so, subject to
14
+ # the following conditions:
15
+ #
16
+ # The above copyright notice and this permission notice shall be
17
+ # included in all copies or substantial portions of the Software.
18
+ #
19
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ #++
27
+ #
28
+ #
29
+ class String #:nodoc:
30
+
31
+ def right_underscore
32
+ self.gsub(/[A-Z]/){|match| "#{$`=='' ? '' : '_'}#{match.downcase}" }
33
+ end
34
+
35
+ end
@@ -0,0 +1,9 @@
1
+ module RightAws #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 2 unless defined?(MAJOR)
4
+ MINOR = 1 unless defined?(MINOR)
5
+ TINY = 0 unless defined?(TINY)
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.') unless defined?(STRING)
8
+ end
9
+ end
@@ -0,0 +1,458 @@
1
+ #
2
+ # Copyright (c) 2007-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
+ # = RightAWS::EC2 -- RightScale Amazon EC2 interface
27
+ # The RightAws::EC2 class provides a complete interface to Amazon's
28
+ # Elastic Compute Cloud service, as well as the associated EBS (Elastic Block
29
+ # Store).
30
+ # For explanations of the semantics
31
+ # of each call, please refer to Amazon's documentation at
32
+ # http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=87
33
+ #
34
+ # Examples:
35
+ #
36
+ # Create an EC2 interface handle:
37
+ #
38
+ # @ec2 = RightAws::Ec2.new(aws_access_key_id,
39
+ # aws_secret_access_key)
40
+ # Create a new SSH key pair:
41
+ # @key = 'right_ec2_awesome_test_key'
42
+ # new_key = @ec2.create_key_pair(@key)
43
+ # keys = @ec2.describe_key_pairs
44
+ #
45
+ # Create a security group:
46
+ # @group = 'right_ec2_awesome_test_security_group'
47
+ # @ec2.create_security_group(@group,'My awesome test group')
48
+ # group = @ec2.describe_security_groups([@group])[0]
49
+ #
50
+ # Configure a security group:
51
+ # @ec2.authorize_security_group_named_ingress(@group, account_number, 'default')
52
+ # @ec2.authorize_security_group_IP_ingress(@group, 80,80,'udp','192.168.1.0/8')
53
+ #
54
+ # Describe the available images:
55
+ # images = @ec2.describe_images
56
+ #
57
+ # Launch an instance:
58
+ # ec2.run_instances('ami-9a9e7bf3', 1, 1, ['default'], @key, 'SomeImportantUserData', 'public')
59
+ #
60
+ #
61
+ # Describe running instances:
62
+ # @ec2.describe_instances
63
+ #
64
+ # Error handling: all operations raise an RightAws::AwsError in case
65
+ # of problems. Note that transient errors are automatically retried.
66
+
67
+ class Ec2 < RightAwsBase
68
+ include RightAwsBaseInterface
69
+
70
+ # Amazon EC2 API version being used
71
+ API_VERSION = "2010-08-31"
72
+ DEFAULT_HOST = "ec2.amazonaws.com"
73
+ DEFAULT_PATH = '/'
74
+ DEFAULT_PROTOCOL = 'https'
75
+ DEFAULT_PORT = 443
76
+
77
+ # Default addressing type (public=NAT, direct=no-NAT) used when launching instances.
78
+ DEFAULT_ADDRESSING_TYPE = 'public'
79
+ DNS_ADDRESSING_SET = ['public','direct']
80
+
81
+ # Amazon EC2 Instance Types : http://www.amazon.com/b?ie=UTF8&node=370375011
82
+ # Default EC2 instance type (platform)
83
+ DEFAULT_INSTANCE_TYPE = 'm1.small'
84
+ INSTANCE_TYPES = ['t1.micro','m1.small','c1.medium','m1.large','m1.xlarge',
85
+ 'c1.xlarge', 'm2.xlarge', 'm2.2xlarge', 'm2.4xlarge',
86
+ 'cc1.4xlarge', 'cg1.4xlarge']
87
+
88
+ @@bench = AwsBenchmarkingBlock.new
89
+ def self.bench_xml
90
+ @@bench.xml
91
+ end
92
+ def self.bench_ec2
93
+ @@bench.service
94
+ end
95
+
96
+ # Current API version (sometimes we have to check it outside the GEM).
97
+ @@api = ENV['EC2_API_VERSION'] || API_VERSION
98
+ def self.api
99
+ @@api
100
+ end
101
+
102
+ # Create a new handle to an EC2 account. All handles share the same per process or per thread
103
+ # HTTP connection to Amazon EC2. Each handle is for a specific account. The params have the
104
+ # following options:
105
+ # * <tt>:endpoint_url</tt> a fully qualified url to Amazon API endpoint (this overwrites: :server, :port, :service, :protocol and :region). Example: 'https://eu-west-1.ec2.amazonaws.com/'
106
+ # * <tt>:server</tt>: EC2 service host, default: DEFAULT_HOST
107
+ # * <tt>:region</tt>: EC2 region (North America by default)
108
+ # * <tt>:port</tt>: EC2 service port, default: DEFAULT_PORT
109
+ # * <tt>:protocol</tt>: 'http' or 'https', default: DEFAULT_PROTOCOL
110
+ # * <tt>:logger</tt>: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT
111
+ # * <tt>:signature_version</tt>: The signature version : '0','1' or '2'(default)
112
+ # * <tt>:cache</tt>: true/false: caching for: ec2_describe_images, describe_instances,
113
+ # describe_images_by_owner, describe_images_by_executable_by, describe_availability_zones,
114
+ # describe_security_groups, describe_key_pairs, describe_addresses,
115
+ # describe_volumes, describe_snapshots methods, default: false.
116
+ #
117
+ def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
118
+ init({ :name => 'EC2',
119
+ :default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,
120
+ :default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,
121
+ :default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH,
122
+ :default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL,
123
+ :default_api_version => @@api },
124
+ aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] ,
125
+ aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
126
+ params)
127
+ # Eucalyptus supports some yummy features but Amazon does not
128
+ #if @params[:eucalyptus]
129
+ # @params[:port_based_group_ingress] = true unless @params.has_key?(:port_based_group_ingress)
130
+ #end
131
+ end
132
+
133
+ def generate_request(action, params={}) #:nodoc:
134
+ generate_request_impl(:get, action, params )
135
+ end
136
+
137
+ # Sends request to Amazon and parses the response
138
+ # Raises AwsError if any banana happened
139
+ def request_info(request, parser) #:nodoc:
140
+ request_info_impl(:ec2_connection, @@bench, request, parser)
141
+ end
142
+
143
+ def describe_resources_with_list_and_options(remote_function_name, remote_item_name, parser_class, list_and_options, &block) # :nodoc:
144
+ # 'RemoteFunctionName' -> :remote_funtion_name
145
+ cache_name = remote_function_name.right_underscore.to_sym
146
+ list, options = AwsUtils::split_items_and_params(list_and_options)
147
+ request_hash = amazonize_list(remote_item_name, list)
148
+ request_hash.merge!(amazonize_list(['Filter.?.Name', 'Filter.?.Value.?'], options[:filters])) unless options[:filters].right_blank?
149
+ cache_for = (list.right_blank? && options[:filters].right_blank?) ? cache_name : nil
150
+ link = generate_request(remote_function_name, request_hash)
151
+ request_cache_or_info(cache_for, link, parser_class, @@bench, cache_for, &block)
152
+ rescue Exception
153
+ on_exception
154
+ end
155
+
156
+ #-----------------------------------------------------------------
157
+ # Keys
158
+ #-----------------------------------------------------------------
159
+
160
+ # Retrieve a list of SSH keys.
161
+ #
162
+ # Accepts a list of ssh keys and/or a set of filters as the last parameter.
163
+ #
164
+ # Filters: fingerprint, key-name
165
+ #
166
+ # Returns an array of keys or an exception. Each key is represented as a two-element hash.
167
+ #
168
+ # ec2.describe_key_pairs #=>
169
+ # [{:aws_fingerprint=> "01:02:03:f4:25:e6:97:e8:9b:02:1a:26:32:4e:58:6b:7a:8c:9f:03", :aws_key_name=>"key-1"},
170
+ # {:aws_fingerprint=> "1e:29:30:47:58:6d:7b:8c:9f:08:11:20:3c:44:52:69:74:80:97:08", :aws_key_name=>"key-2"},
171
+ # ..., {...} ]
172
+ #
173
+ # ec2.describe_key_pairs(:filters => {'fingerprint' => ["53:0b:73:c9:c8:18:98:6e:bc:98:9e:51:97:04:74:4b:07:f9:00:00",
174
+ # "9f:57:a5:bb:4b:e8:a7:f8:3c:fe:d6:db:41:f5:7e:97:b5:b2:00:00"]})
175
+ #
176
+ # P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html
177
+ #
178
+ def describe_key_pairs(*list_and_options)
179
+ describe_resources_with_list_and_options('DescribeKeyPairs', 'KeyName', QEc2DescribeKeyPairParser, list_and_options)
180
+ end
181
+
182
+ # Import new SSH key. Returns a hash of the key's data or an exception.
183
+ #
184
+ # ec2.import_key_pair('my_awesome_key', 'C:\keys\myfavoritekeypair_public.ppk') #=>
185
+ # {:aws_key_name => "my_awesome_key",
186
+ # :aws_fingerprint => "01:02:03:f4:25:e6:97:e8:9b:02:1a:26:32:4e:58:6b:7a:8c:9f:03"}
187
+ #
188
+ def import_key_pair(name, public_key_material)
189
+ link = generate_request("ImportKeyPair",
190
+ 'KeyName' => name.to_s,
191
+ 'PublicKeyMaterial' => Base64.encode64(public_key_material.to_s))
192
+ request_info(link, QEc2ImportKeyPairParser.new(:logger => @logger))
193
+ rescue Exception
194
+ on_exception
195
+ end
196
+
197
+ # Create new SSH key. Returns a hash of the key's data or an exception.
198
+ #
199
+ # ec2.create_key_pair('my_awesome_key') #=>
200
+ # {:aws_key_name => "my_awesome_key",
201
+ # :aws_fingerprint => "01:02:03:f4:25:e6:97:e8:9b:02:1a:26:32:4e:58:6b:7a:8c:9f:03",
202
+ # :aws_material => "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAK...Q8MDrCbuQ=\n-----END RSA PRIVATE KEY-----"}
203
+ #
204
+ def create_key_pair(name)
205
+ link = generate_request("CreateKeyPair",
206
+ 'KeyName' => name.to_s)
207
+ request_info(link, QEc2CreateKeyPairParser.new(:logger => @logger))
208
+ rescue Exception
209
+ on_exception
210
+ end
211
+
212
+ # Delete a key pair. Returns +true+ or an exception.
213
+ #
214
+ # ec2.delete_key_pair('my_awesome_key') #=> true
215
+ #
216
+ def delete_key_pair(name)
217
+ link = generate_request("DeleteKeyPair",
218
+ 'KeyName' => name.to_s)
219
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
220
+ rescue Exception
221
+ on_exception
222
+ end
223
+
224
+ #-----------------------------------------------------------------
225
+ # Elastic IPs
226
+ #-----------------------------------------------------------------
227
+
228
+ # Acquire a new elastic IP address for use with your account.
229
+ # Returns allocated IP address or an exception.
230
+ #
231
+ # ec2.allocate_address #=> '75.101.154.140'
232
+ #
233
+ def allocate_address
234
+ link = generate_request("AllocateAddress")
235
+ request_info(link, QEc2AllocateAddressParser.new(:logger => @logger))
236
+ rescue Exception
237
+ on_exception
238
+ end
239
+
240
+ # Associate an elastic IP address with an instance.
241
+ # Returns +true+ or an exception.
242
+ #
243
+ # ec2.associate_address('i-d630cbbf', '75.101.154.140') #=> true
244
+ #
245
+ def associate_address(instance_id, public_ip)
246
+ link = generate_request("AssociateAddress",
247
+ "InstanceId" => instance_id.to_s,
248
+ "PublicIp" => public_ip.to_s)
249
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
250
+ rescue Exception
251
+ on_exception
252
+ end
253
+
254
+ # List elastic IP addresses assigned to your account.
255
+ #
256
+ # Accepts a list of addresses and/or a set of filters as the last parameter.
257
+ #
258
+ # Filters: instance-id, public-ip
259
+ #
260
+ # Returns an array of 2 keys (:instance_id and :public_ip) hashes:
261
+ #
262
+ # ec2.describe_addresses #=> [{:instance_id=>"i-d630cbbf", :public_ip=>"75.101.154.140"},
263
+ # {:instance_id=>nil, :public_ip=>"75.101.154.141"}]
264
+ #
265
+ # ec2.describe_addresses('75.101.154.140') #=> [{:instance_id=>"i-d630cbbf", :public_ip=>"75.101.154.140"}]
266
+ #
267
+ # ec2.describe_addresses(:filters => { 'public-ip' => "75.101.154.140" })
268
+ #
269
+ # P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeAddresses.html
270
+ #
271
+ def describe_addresses(*list_and_options)
272
+ describe_resources_with_list_and_options('DescribeAddresses', 'PublicIp', QEc2DescribeAddressesParser, list_and_options)
273
+ end
274
+
275
+ # Disassociate the specified elastic IP address from the instance to which it is assigned.
276
+ # Returns +true+ or an exception.
277
+ #
278
+ # ec2.disassociate_address('75.101.154.140') #=> true
279
+ #
280
+ def disassociate_address(public_ip)
281
+ link = generate_request("DisassociateAddress",
282
+ "PublicIp" => public_ip.to_s)
283
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
284
+ rescue Exception
285
+ on_exception
286
+ end
287
+
288
+ # Release an elastic IP address associated with your account.
289
+ # Returns +true+ or an exception.
290
+ #
291
+ # ec2.release_address('75.101.154.140') #=> true
292
+ #
293
+ def release_address(public_ip)
294
+ link = generate_request("ReleaseAddress",
295
+ "PublicIp" => public_ip.to_s)
296
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
297
+ rescue Exception
298
+ on_exception
299
+ end
300
+
301
+ #-----------------------------------------------------------------
302
+ # Availability zones
303
+ #-----------------------------------------------------------------
304
+
305
+ # Describes availability zones that are currently available to the account and their states.
306
+ #
307
+ # Accepts a list of availability zones and/or a set of filters as the last parameter.
308
+ #
309
+ # Filters: message, region-name, state, zone-name
310
+ #
311
+ # Returns an array of 2 keys (:zone_name and :zone_state) hashes:
312
+ #
313
+ # ec2.describe_availability_zones #=> [{:region_name=>"us-east-1",
314
+ # :zone_name=>"us-east-1a",
315
+ # :zone_state=>"available"}, ... ]
316
+ #
317
+ # ec2.describe_availability_zones('us-east-1c') #=> [{:region_name=>"us-east-1",
318
+ # :zone_state=>"available",
319
+ # :zone_name=>"us-east-1c"}]
320
+ #
321
+ # P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeAvailabilityZones.html
322
+ #
323
+ def describe_availability_zones(*list_and_options)
324
+ describe_resources_with_list_and_options('DescribeAvailabilityZones', 'ZoneName', QEc2DescribeAvailabilityZonesParser, list_and_options)
325
+ end
326
+
327
+ #-----------------------------------------------------------------
328
+ # Regions
329
+ #-----------------------------------------------------------------
330
+
331
+ # Describe regions.
332
+ #
333
+ # Accepts a list of regions and/or a set of filters as the last parameter.
334
+ #
335
+ # Filters: endpoint, region-name
336
+ #
337
+ # ec2.describe_regions #=> ["eu-west-1", "us-east-1"]
338
+ #
339
+ # P.S. filters: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeRegions.html
340
+ #
341
+ def describe_regions(*list_and_options)
342
+ describe_resources_with_list_and_options('DescribeRegions', 'RegionName', QEc2DescribeRegionsParser, list_and_options)
343
+ end
344
+
345
+ #-----------------------------------------------------------------
346
+ # PARSERS: Key Pair
347
+ #-----------------------------------------------------------------
348
+
349
+ class QEc2DescribeKeyPairParser < RightAWSParser #:nodoc:
350
+ def tagstart(name, attributes)
351
+ @item = {} if name == 'item'
352
+ end
353
+ def tagend(name)
354
+ case name
355
+ when 'keyName' then @item[:aws_key_name] = @text
356
+ when 'keyFingerprint' then @item[:aws_fingerprint] = @text
357
+ when 'item' then @result << @item
358
+ end
359
+ end
360
+ def reset
361
+ @result = [];
362
+ end
363
+ end
364
+
365
+ class QEc2CreateKeyPairParser < RightAWSParser #:nodoc:
366
+ def tagstart(name, attributes)
367
+ @result = {} if name == 'CreateKeyPairResponse'
368
+ end
369
+ def tagend(name)
370
+ case name
371
+ when 'keyName' then @result[:aws_key_name] = @text
372
+ when 'keyFingerprint' then @result[:aws_fingerprint] = @text
373
+ when 'keyMaterial' then @result[:aws_material] = @text
374
+ end
375
+ end
376
+ end
377
+
378
+ class QEc2ImportKeyPairParser < RightAWSParser #:nodoc:
379
+ def tagstart(name, attributes)
380
+ @result = {} if name == 'ImportKeyPairResponse'
381
+ end
382
+ def tagend(name)
383
+ case name
384
+ when 'keyName' then @result[:aws_key_name] = @text
385
+ when 'keyFingerprint' then @result[:aws_fingerprint] = @text
386
+ end
387
+ end
388
+ end
389
+
390
+ #-----------------------------------------------------------------
391
+ # PARSERS: Elastic IPs
392
+ #-----------------------------------------------------------------
393
+
394
+ class QEc2AllocateAddressParser < RightAWSParser #:nodoc:
395
+ def tagend(name)
396
+ @result = @text if name == 'publicIp'
397
+ end
398
+ end
399
+
400
+ class QEc2DescribeAddressesParser < RightAWSParser #:nodoc:
401
+ def tagstart(name, attributes)
402
+ @address = {} if name == 'item'
403
+ end
404
+ def tagend(name)
405
+ case name
406
+ when 'instanceId' then @address[:instance_id] = @text.right_blank? ? nil : @text
407
+ when 'publicIp' then @address[:public_ip] = @text
408
+ when 'item' then @result << @address
409
+ end
410
+ end
411
+ def reset
412
+ @result = []
413
+ end
414
+ end
415
+
416
+ #-----------------------------------------------------------------
417
+ # PARSERS: AvailabilityZones
418
+ #-----------------------------------------------------------------
419
+
420
+ class QEc2DescribeAvailabilityZonesParser < RightAWSParser #:nodoc:
421
+ def tagstart(name, attributes)
422
+ case full_tag_name
423
+ when %r{/availabilityZoneInfo/item$} then @item = {}
424
+ end
425
+ end
426
+ def tagend(name)
427
+ case name
428
+ when 'regionName' then @item[:region_name] = @text
429
+ when 'zoneName' then @item[:zone_name] = @text
430
+ when 'zoneState' then @item[:zone_state] = @text
431
+ else
432
+ case full_tag_name
433
+ when %r{/messageSet/item/message$} then (@item[:messages] ||= []) << @text
434
+ when %r{/availabilityZoneInfo/item$} then @result << @item
435
+ end
436
+ end
437
+ end
438
+ def reset
439
+ @result = []
440
+ end
441
+ end
442
+
443
+ #-----------------------------------------------------------------
444
+ # PARSERS: Regions
445
+ #-----------------------------------------------------------------
446
+
447
+ class QEc2DescribeRegionsParser < RightAWSParser #:nodoc:
448
+ def tagend(name)
449
+ @result << @text if name == 'regionName'
450
+ end
451
+ def reset
452
+ @result = []
453
+ end
454
+ end
455
+
456
+ end
457
+
458
+ end