right_aws-yodal 1.10.7 → 1.10.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/History.txt +46 -1
  2. data/Manifest.txt +4 -0
  3. data/README.txt +0 -0
  4. data/Rakefile +0 -0
  5. data/lib/acf/right_acf_interface.rb +105 -33
  6. data/lib/acf/right_acf_origin_access_identities.rb +230 -0
  7. data/lib/acf/right_acf_streaming_interface.rb +236 -0
  8. data/lib/acw/right_acw_interface.rb +3 -3
  9. data/lib/as/right_as_interface.rb +55 -46
  10. data/lib/awsbase/benchmark_fix.rb +0 -0
  11. data/lib/awsbase/right_awsbase.rb +71 -12
  12. data/lib/awsbase/support.rb +0 -0
  13. data/lib/ec2/right_ec2.rb +22 -244
  14. data/lib/ec2/right_ec2_ebs.rb +23 -22
  15. data/lib/ec2/right_ec2_images.rb +21 -21
  16. data/lib/ec2/right_ec2_instances.rb +49 -54
  17. data/lib/ec2/right_ec2_reserved_instances.rb +7 -4
  18. data/lib/ec2/right_ec2_security_groups.rb +277 -0
  19. data/lib/ec2/right_ec2_spot_instances.rb +399 -0
  20. data/lib/ec2/right_ec2_vpc.rb +4 -4
  21. data/lib/elb/right_elb_interface.rb +112 -23
  22. data/lib/rds/right_rds_interface.rb +4 -4
  23. data/lib/right_aws.rb +8 -4
  24. data/lib/s3/right_s3.rb +25 -1
  25. data/lib/s3/right_s3_interface.rb +6 -2
  26. data/lib/sdb/active_sdb.rb +202 -10
  27. data/lib/sdb/right_sdb_interface.rb +61 -11
  28. data/lib/sqs/right_sqs.rb +0 -0
  29. data/lib/sqs/right_sqs_gen2.rb +0 -0
  30. data/lib/sqs/right_sqs_gen2_interface.rb +5 -4
  31. data/lib/sqs/right_sqs_interface.rb +0 -0
  32. data/test/acf/test_helper.rb +0 -0
  33. data/test/acf/test_right_acf.rb +10 -18
  34. data/test/ec2/test_helper.rb +0 -0
  35. data/test/ec2/test_right_ec2.rb +0 -0
  36. data/test/http_connection.rb +0 -0
  37. data/test/s3/test_helper.rb +0 -0
  38. data/test/s3/test_right_s3.rb +10 -8
  39. data/test/s3/test_right_s3_stubbed.rb +6 -4
  40. data/test/sdb/test_active_sdb.rb +70 -12
  41. data/test/sdb/test_batch_put_attributes.rb +54 -0
  42. data/test/sdb/test_helper.rb +0 -0
  43. data/test/sdb/test_right_sdb.rb +13 -7
  44. data/test/sqs/test_helper.rb +0 -0
  45. data/test/sqs/test_right_sqs.rb +0 -0
  46. data/test/sqs/test_right_sqs_gen2.rb +21 -33
  47. data/test/test_credentials.rb +0 -0
  48. data/test/ts_right_aws.rb +0 -0
  49. metadata +16 -4
File without changes
@@ -23,7 +23,8 @@
23
23
 
24
24
  # Test
25
25
  module RightAws
26
- require 'md5'
26
+ # require 'md5'
27
+ require 'digest/md5'
27
28
  require 'pp'
28
29
 
29
30
  class AwsUtils #:nodoc:
@@ -32,6 +33,13 @@ module RightAws
32
33
  if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000
33
34
  @@digest256 = OpenSSL::Digest::Digest.new("sha256") rescue nil # Some installation may not support sha256
34
35
  end
36
+
37
+ def self.utc_iso8601(time)
38
+ if time.is_a?(Fixnum) then time = Time::at(time)
39
+ elsif time.is_a?(String) then time = Time::parse(time)
40
+ end
41
+ time.utc.strftime("%Y-%m-%dT%H:%M:%S.000Z")
42
+ end
35
43
 
36
44
  def self.sign(aws_secret_access_key, auth_string)
37
45
  Base64.encode64(OpenSSL::HMAC.digest(@@digest1, aws_secret_access_key, auth_string)).strip
@@ -47,7 +55,7 @@ module RightAws
47
55
 
48
56
  # Set a timestamp and a signature version
49
57
  def self.fix_service_params(service_hash, signature)
50
- service_hash["Timestamp"] ||= Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.000Z") unless service_hash["Expires"]
58
+ service_hash["Timestamp"] ||= utc_iso8601(Time.now) unless service_hash["Expires"]
51
59
  service_hash["SignatureVersion"] = signature
52
60
  service_hash
53
61
  end
@@ -124,7 +132,7 @@ module RightAws
124
132
  end
125
133
 
126
134
  def self.split_items_and_params(array)
127
- items = array.to_a.flatten.compact
135
+ items = Array(array).flatten.compact
128
136
  params = items.last.kind_of?(Hash) ? items.pop : {}
129
137
  [items, params]
130
138
  end
@@ -235,15 +243,13 @@ module RightAws
235
243
  @params[:service] ||= service_info[:default_service]
236
244
  @params[:protocol] ||= service_info[:default_protocol]
237
245
  end
238
- # @params[:multi_thread] ||= defined?(AWS_DAEMON)
239
- @params[:connections] ||= :shared # || :dedicated
240
246
  @params[:max_connections] ||= 10
241
247
  @params[:connection_lifetime] ||= 20*60
242
248
  @params[:api_version] ||= service_info[:default_api_version]
243
249
  @logger = @params[:logger]
244
250
  @logger = RAILS_DEFAULT_LOGGER if !@logger && defined?(RAILS_DEFAULT_LOGGER)
245
251
  @logger = Logger.new(STDOUT) if !@logger
246
- @logger.info "New #{self.class.name} using #{@params[:connections]} connections mode"
252
+ @logger.info "New #{self.class.name}"
247
253
  @error_handler = nil
248
254
  @cache = {}
249
255
  @signature_version = (params[:signature_version] || DEFAULT_SIGNATURE_VERSION).to_s
@@ -341,7 +347,7 @@ module RightAws
341
347
  when 'POST'
342
348
  request = Net::HTTP::Post.new(@params[:service])
343
349
  request.body = service_params
344
- request['Content-Type'] = 'application/x-www-form-urlencoded'
350
+ request['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'
345
351
  else
346
352
  raise "Unsupported HTTP verb #{verb.inspect}!"
347
353
  end
@@ -380,6 +386,21 @@ module RightAws
380
386
  @connections_storage[server_url][:connection]
381
387
  end
382
388
 
389
+ def destroy_connection(aws_service, request)
390
+ connections = get_connections_storage aws_service
391
+ url = get_server_url request
392
+ connections[url][:connection].finish('destroyed') if connections[url]
393
+ connections[url] = nil
394
+ end
395
+
396
+ def get_connections_storage(aws_service)
397
+ @connections_storage = (Thread.current[aws_service] ||= {})
398
+ end
399
+
400
+ def get_server_url(request)
401
+ "#{request[:protocol]}://#{request[:server]}:#{request[:port]}}"
402
+ end
403
+
383
404
  # All services uses this guy.
384
405
  def request_info_impl(aws_service, benchblock, request, parser, &block) #:nodoc:
385
406
  @connection = get_connection(aws_service, request)
@@ -437,6 +458,7 @@ module RightAws
437
458
  benchblock.xml.add! { parser.parse(response) }
438
459
  return parser.result
439
460
  else
461
+ destroy_connection aws_service, request
440
462
  @error_handler = AWSErrorHandler.new(self, parser, :errors_list => self.class.amazon_problems) unless @error_handler
441
463
  check_result = @error_handler.check(request)
442
464
  if check_result
@@ -498,11 +520,11 @@ module RightAws
498
520
  # "Filter.2.Value.2"=>"bb"}
499
521
  def amazonize_list(masks, list) #:nodoc:
500
522
  groups = {}
501
- list.to_a.each_with_index do |list_item, i|
502
- masks.to_a.each_with_index do |mask, mask_idx|
523
+ Array(list).each_with_index do |list_item, i|
524
+ Array(masks).each_with_index do |mask, mask_idx|
503
525
  key = mask[/\?/] ? mask.dup : mask.dup + '.?'
504
526
  key.sub!('?', (i+1).to_s)
505
- value = list_item.to_a[mask_idx]
527
+ value = Array(list_item)[mask_idx]
506
528
  if value.is_a?(Array)
507
529
  groups.merge!(amazonize_list(key, value))
508
530
  else
@@ -512,6 +534,32 @@ module RightAws
512
534
  end
513
535
  groups
514
536
  end
537
+
538
+ BLOCK_DEVICE_KEY_MAPPING = { # :nodoc:
539
+ :device_name => 'DeviceName',
540
+ :virtual_name => 'VirtualName',
541
+ :no_device => 'NoDevice',
542
+ :ebs_snapshot_id => 'Ebs.SnapshotId',
543
+ :ebs_volume_size => 'Ebs.VolumeSize',
544
+ :ebs_delete_on_termination => 'Ebs.DeleteOnTermination' }
545
+
546
+ def amazonize_block_device_mappings(block_device_mappings, key = 'BlockDeviceMapping') # :nodoc:
547
+ result = {}
548
+ unless block_device_mappings.blank?
549
+ block_device_mappings = [block_device_mappings] unless block_device_mappings.is_a?(Array)
550
+ block_device_mappings.each_with_index do |b, idx|
551
+ BLOCK_DEVICE_KEY_MAPPING.each do |local_name, remote_name|
552
+ value = b[local_name]
553
+ case local_name
554
+ when :no_device then value = value ? '' : nil # allow to pass :no_device as boolean
555
+ end
556
+ result["#{key}.#{idx+1}.#{remote_name}"] = value unless value.nil?
557
+ end
558
+ end
559
+ end
560
+ result
561
+ end
562
+
515
563
  end
516
564
 
517
565
 
@@ -847,8 +895,13 @@ module RightAws
847
895
  # Parse the xml text
848
896
  case @xml_lib
849
897
  when 'libxml'
850
- xml = XML::SaxParser.new
851
- xml.string = xml_text
898
+ if XML::Parser::VERSION >= '0.9.9'
899
+ # avoid warning on every usage
900
+ xml = XML::SaxParser.string(xml_text)
901
+ else
902
+ xml = XML::SaxParser.new
903
+ xml.string = xml_text
904
+ end
852
905
  # check libxml-ruby version
853
906
  if XML::Parser::VERSION >= '0.5.1.0'
854
907
  xml.callbacks = RightSaxParserCallback.new(self)
@@ -929,5 +982,11 @@ module RightAws
929
982
  end
930
983
  end
931
984
 
985
+ class RightBoolResponseParser < RightAWSParser #:nodoc:
986
+ def tagend(name)
987
+ @result = (@text=='true') if name == 'return'
988
+ end
989
+ end
990
+
932
991
  end
933
992
 
File without changes
@@ -68,7 +68,7 @@ module RightAws
68
68
  include RightAwsBaseInterface
69
69
 
70
70
  # Amazon EC2 API version being used
71
- API_VERSION = "2009-10-31"
71
+ API_VERSION = "2009-11-30"
72
72
  DEFAULT_HOST = "ec2.amazonaws.com"
73
73
  DEFAULT_PATH = '/'
74
74
  DEFAULT_PROTOCOL = 'https'
@@ -81,7 +81,7 @@ module RightAws
81
81
  # Amazon EC2 Instance Types : http://www.amazon.com/b?ie=UTF8&node=370375011
82
82
  # Default EC2 instance type (platform)
83
83
  DEFAULT_INSTANCE_TYPE = 'm1.small'
84
- INSTANCE_TYPES = ['m1.small','c1.medium','m1.large','m1.xlarge','c1.xlarge', 'm2.2xlarge', 'm2.4xlarge']
84
+ INSTANCE_TYPES = ['m1.small','c1.medium','m1.large','m1.xlarge','c1.xlarge', 'm2.xlarge', 'm2.2xlarge', 'm2.4xlarge']
85
85
 
86
86
  @@bench = AwsBenchmarkingBlock.new
87
87
  def self.bench_xml
@@ -123,6 +123,10 @@ module RightAws
123
123
  aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] ,
124
124
  aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
125
125
  params)
126
+ # Eucalyptus supports some yummy features but Amazon does not
127
+ if @params[:eucalyptus]
128
+ @params[:port_based_group_ingress] = true unless @params.has_key?(:port_based_group_ingress)
129
+ end
126
130
  end
127
131
 
128
132
  def generate_request(action, params={}) #:nodoc:
@@ -135,153 +139,6 @@ module RightAws
135
139
  request_info_impl(:ec2_connection, @@bench, request, parser)
136
140
  end
137
141
 
138
- #-----------------------------------------------------------------
139
- # Security groups
140
- #-----------------------------------------------------------------
141
-
142
- # Retrieve Security Group information. If +list+ is omitted the returns the whole list of groups.
143
- #
144
- # ec2.describe_security_groups #=>
145
- # [{:aws_group_name => "default-1",
146
- # :aws_owner => "000000000888",
147
- # :aws_description => "Default allowing SSH, HTTP, and HTTPS ingress",
148
- # :aws_perms =>
149
- # [{:owner => "000000000888", :group => "default"},
150
- # {:owner => "000000000888", :group => "default-1"},
151
- # {:to_port => "-1", :protocol => "icmp", :from_port => "-1", :cidr_ips => "0.0.0.0/0"},
152
- # {:to_port => "22", :protocol => "tcp", :from_port => "22", :cidr_ips => "0.0.0.0/0"},
153
- # {:to_port => "80", :protocol => "tcp", :from_port => "80", :cidr_ips => "0.0.0.0/0"},
154
- # {:to_port => "443", :protocol => "tcp", :from_port => "443", :cidr_ips => "0.0.0.0/0"}]},
155
- # ..., {...}]
156
- #
157
- def describe_security_groups(list=[])
158
- link = generate_request("DescribeSecurityGroups", amazonize_list('GroupName',list.to_a))
159
- request_cache_or_info( :describe_security_groups, link, QEc2DescribeSecurityGroupsParser, @@bench, list.blank?) do |parser|
160
- result = []
161
- parser.result.each do |item|
162
- perms = []
163
- item.ipPermissions.each do |perm|
164
- perm.groups.each do |ngroup|
165
- perms << {:group => ngroup.groupName,
166
- :owner => ngroup.userId}
167
- end
168
- perm.ipRanges.each do |cidr_ip|
169
- perms << {:from_port => perm.fromPort,
170
- :to_port => perm.toPort,
171
- :protocol => perm.ipProtocol,
172
- :cidr_ips => cidr_ip}
173
- end
174
- end
175
-
176
- # delete duplication
177
- perms.each_index do |i|
178
- (0...i).each do |j|
179
- if perms[i] == perms[j] then perms[i] = nil; break; end
180
- end
181
- end
182
- perms.compact!
183
-
184
- result << {:aws_owner => item.ownerId,
185
- :aws_group_name => item.groupName,
186
- :aws_description => item.groupDescription,
187
- :aws_perms => perms}
188
-
189
- end
190
- result
191
- end
192
- rescue Exception
193
- on_exception
194
- end
195
-
196
- # Create new Security Group. Returns +true+ or an exception.
197
- #
198
- # ec2.create_security_group('default-1',"Default allowing SSH, HTTP, and HTTPS ingress") #=> true
199
- #
200
- def create_security_group(name, description)
201
- # EC2 doesn't like an empty description...
202
- description = " " if description.blank?
203
- link = generate_request("CreateSecurityGroup",
204
- 'GroupName' => name.to_s,
205
- 'GroupDescription' => description.to_s)
206
- request_info(link, RightBoolResponseParser.new(:logger => @logger))
207
- rescue Exception
208
- on_exception
209
- end
210
-
211
- # Remove Security Group. Returns +true+ or an exception.
212
- #
213
- # ec2.delete_security_group('default-1') #=> true
214
- #
215
- def delete_security_group(name)
216
- link = generate_request("DeleteSecurityGroup",
217
- 'GroupName' => name.to_s)
218
- request_info(link, RightBoolResponseParser.new(:logger => @logger))
219
- rescue Exception
220
- on_exception
221
- end
222
-
223
- # Authorize named ingress for security group. Allows instances that are member of someone
224
- # else's security group to open connections to instances in my group.
225
- #
226
- # ec2.authorize_security_group_named_ingress('my_awesome_group', '7011-0219-8268', 'their_group_name') #=> true
227
- #
228
- def authorize_security_group_named_ingress(name, owner, group)
229
- link = generate_request("AuthorizeSecurityGroupIngress",
230
- 'GroupName' => name.to_s,
231
- 'SourceSecurityGroupName' => group.to_s,
232
- 'SourceSecurityGroupOwnerId' => owner.to_s.gsub(/-/,''))
233
- request_info(link, RightBoolResponseParser.new(:logger => @logger))
234
- rescue Exception
235
- on_exception
236
- end
237
-
238
- # Revoke named ingress for security group.
239
- #
240
- # ec2.revoke_security_group_named_ingress('my_awesome_group', aws_user_id, 'another_group_name') #=> true
241
- #
242
- def revoke_security_group_named_ingress(name, owner, group)
243
- link = generate_request("RevokeSecurityGroupIngress",
244
- 'GroupName' => name.to_s,
245
- 'SourceSecurityGroupName' => group.to_s,
246
- 'SourceSecurityGroupOwnerId' => owner.to_s.gsub(/-/,''))
247
- request_info(link, RightBoolResponseParser.new(:logger => @logger))
248
- rescue Exception
249
- on_exception
250
- end
251
-
252
- # Add permission to a security group. Returns +true+ or an exception. +protocol+ is one of :'tcp'|'udp'|'icmp'.
253
- #
254
- # ec2.authorize_security_group_IP_ingress('my_awesome_group', 80, 82, 'udp', '192.168.1.0/8') #=> true
255
- # ec2.authorize_security_group_IP_ingress('my_awesome_group', -1, -1, 'icmp') #=> true
256
- #
257
- def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
258
- link = generate_request("AuthorizeSecurityGroupIngress",
259
- 'GroupName' => name.to_s,
260
- 'IpProtocol' => protocol.to_s,
261
- 'FromPort' => from_port.to_s,
262
- 'ToPort' => to_port.to_s,
263
- 'CidrIp' => cidr_ip.to_s)
264
- request_info(link, RightBoolResponseParser.new(:logger => @logger))
265
- rescue Exception
266
- on_exception
267
- end
268
-
269
- # Remove permission from a security group. Returns +true+ or an exception. +protocol+ is one of :'tcp'|'udp'|'icmp' ('tcp' is default).
270
- #
271
- # ec2.revoke_security_group_IP_ingress('my_awesome_group', 80, 82, 'udp', '192.168.1.0/8') #=> true
272
- #
273
- def revoke_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
274
- link = generate_request("RevokeSecurityGroupIngress",
275
- 'GroupName' => name.to_s,
276
- 'IpProtocol' => protocol.to_s,
277
- 'FromPort' => from_port.to_s,
278
- 'ToPort' => to_port.to_s,
279
- 'CidrIp' => cidr_ip.to_s)
280
- request_info(link, RightBoolResponseParser.new(:logger => @logger))
281
- rescue Exception
282
- on_exception
283
- end
284
-
285
142
  #-----------------------------------------------------------------
286
143
  # Keys
287
144
  #-----------------------------------------------------------------
@@ -294,9 +151,10 @@ module RightAws
294
151
  # {: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"},
295
152
  # ..., {...} ]
296
153
  #
297
- def describe_key_pairs(list=[])
298
- link = generate_request("DescribeKeyPairs", amazonize_list('KeyName',list.to_a))
299
- request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, @@bench, list.blank?
154
+ def describe_key_pairs(*key_pairs)
155
+ key_pairs = key_pairs.flatten
156
+ link = generate_request("DescribeKeyPairs", amazonize_list('KeyName', key_pairs))
157
+ request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, @@bench, key_pairs.blank?
300
158
  rescue Exception
301
159
  on_exception
302
160
  end
@@ -366,10 +224,10 @@ module RightAws
366
224
  #
367
225
  # ec2.describe_addresses('75.101.154.140') #=> [{:instance_id=>"i-d630cbbf", :public_ip=>"75.101.154.140"}]
368
226
  #
369
- def describe_addresses(list=[])
370
- link = generate_request("DescribeAddresses",
371
- amazonize_list('PublicIp',list.to_a))
372
- request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, list.blank?
227
+ def describe_addresses(*addresses)
228
+ addresses = addresses.flatten
229
+ link = generate_request("DescribeAddresses", amazonize_list('PublicIp', addresses))
230
+ request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, addresses.blank?
373
231
  rescue Exception
374
232
  on_exception
375
233
  end
@@ -415,10 +273,10 @@ module RightAws
415
273
  # :zone_state=>"available",
416
274
  # :zone_name=>"us-east-1c"}]
417
275
  #
418
- def describe_availability_zones(list=[])
419
- link = generate_request("DescribeAvailabilityZones",
420
- amazonize_list('ZoneName',list.to_a))
421
- request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, list.blank?
276
+ def describe_availability_zones(*availability_zones)
277
+ availability_zones = availability_zones.flatten
278
+ link = generate_request("DescribeAvailabilityZones", amazonize_list('ZoneName', availability_zones))
279
+ request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, availability_zones.blank?
422
280
  rescue Exception
423
281
  on_exception
424
282
  end
@@ -431,24 +289,14 @@ module RightAws
431
289
  #
432
290
  # ec2.describe_regions #=> ["eu-west-1", "us-east-1"]
433
291
  #
434
- def describe_regions(list=[])
435
- link = generate_request("DescribeRegions",
436
- amazonize_list('RegionName',list.to_a))
437
- request_cache_or_info :describe_regions, link, QEc2DescribeRegionsParser, @@bench, list.blank?
292
+ def describe_regions(*regions)
293
+ regions = regions.flatten
294
+ link = generate_request("DescribeRegions", amazonize_list('RegionName', regions))
295
+ request_cache_or_info :describe_regions, link, QEc2DescribeRegionsParser, @@bench, regions.blank?
438
296
  rescue Exception
439
297
  on_exception
440
298
  end
441
299
 
442
- #-----------------------------------------------------------------
443
- # PARSERS: Boolean Response Parser
444
- #-----------------------------------------------------------------
445
-
446
- class RightBoolResponseParser < RightAWSParser #:nodoc:
447
- def tagend(name)
448
- @result = @text=='true' ? true : false if name == 'return'
449
- end
450
- end
451
-
452
300
  #-----------------------------------------------------------------
453
301
  # PARSERS: Key Pair
454
302
  #-----------------------------------------------------------------
@@ -482,76 +330,6 @@ module RightAws
482
330
  end
483
331
  end
484
332
 
485
- #-----------------------------------------------------------------
486
- # PARSERS: Security Groups
487
- #-----------------------------------------------------------------
488
-
489
- class QEc2UserIdGroupPairType #:nodoc:
490
- attr_accessor :userId
491
- attr_accessor :groupName
492
- end
493
-
494
- class QEc2IpPermissionType #:nodoc:
495
- attr_accessor :ipProtocol
496
- attr_accessor :fromPort
497
- attr_accessor :toPort
498
- attr_accessor :groups
499
- attr_accessor :ipRanges
500
- end
501
-
502
- class QEc2SecurityGroupItemType #:nodoc:
503
- attr_accessor :groupName
504
- attr_accessor :groupDescription
505
- attr_accessor :ownerId
506
- attr_accessor :ipPermissions
507
- end
508
-
509
- class QEc2DescribeSecurityGroupsParser < RightAWSParser #:nodoc:
510
- def tagstart(name, attributes)
511
- case name
512
- when 'item'
513
- if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo'
514
- @group = QEc2SecurityGroupItemType.new
515
- @group.ipPermissions = []
516
- elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions'
517
- @perm = QEc2IpPermissionType.new
518
- @perm.ipRanges = []
519
- @perm.groups = []
520
- elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups'
521
- @sgroup = QEc2UserIdGroupPairType.new
522
- end
523
- end
524
- end
525
- def tagend(name)
526
- case name
527
- when 'ownerId' then @group.ownerId = @text
528
- when 'groupDescription' then @group.groupDescription = @text
529
- when 'groupName'
530
- if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item'
531
- @group.groupName = @text
532
- elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups/item'
533
- @sgroup.groupName = @text
534
- end
535
- when 'ipProtocol' then @perm.ipProtocol = @text
536
- when 'fromPort' then @perm.fromPort = @text
537
- when 'toPort' then @perm.toPort = @text
538
- when 'userId' then @sgroup.userId = @text
539
- when 'cidrIp' then @perm.ipRanges << @text
540
- when 'item'
541
- if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups'
542
- @perm.groups << @sgroup
543
- elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions'
544
- @group.ipPermissions << @perm
545
- elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo'
546
- @result << @group
547
- end
548
- end
549
- end
550
- def reset
551
- @result = []
552
- end
553
- end
554
-
555
333
  #-----------------------------------------------------------------
556
334
  # PARSERS: Elastic IPs
557
335
  #-----------------------------------------------------------------