aws 2.4.5 → 2.5.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 (45) hide show
  1. data/README.markdown +9 -75
  2. data/lib/acf/acf_interface.rb +6 -4
  3. data/lib/aws.rb +2 -1
  4. data/lib/awsbase/awsbase.rb +98 -65
  5. data/lib/awsbase/errors.rb +9 -5
  6. data/lib/awsbase/parsers.rb +226 -226
  7. data/lib/awsbase/utils.rb +255 -207
  8. data/lib/ec2/ec2.rb +243 -105
  9. data/lib/ec2/mon_interface.rb +2 -1
  10. data/lib/iam/iam.rb +31 -25
  11. data/lib/right_aws.rb +1 -1
  12. data/lib/s3/bucket.rb +7 -8
  13. data/lib/s3/grantee.rb +238 -238
  14. data/lib/s3/key.rb +281 -281
  15. data/lib/s3/s3.rb +2 -1
  16. data/lib/s3/s3_interface.rb +45 -35
  17. data/lib/sdb/active_sdb.rb +19 -22
  18. data/lib/sdb/sdb_interface.rb +4 -5
  19. data/lib/ses/ses.rb +123 -0
  20. data/lib/sqs/sqs.rb +5 -0
  21. data/lib/sqs/sqs_interface.rb +3 -3
  22. metadata +53 -104
  23. data/lib/awsbase/support.rb +0 -142
  24. data/test/acf/test_acf.rb +0 -148
  25. data/test/acf/test_helper.rb +0 -2
  26. data/test/ec2/test_ec2.rb +0 -205
  27. data/test/ec2/test_helper.rb +0 -2
  28. data/test/ec2/test_mon.rb +0 -17
  29. data/test/elb/test_elb.rb +0 -51
  30. data/test/http_connection.rb +0 -87
  31. data/test/iam/test_iam.rb +0 -36
  32. data/test/rds/test_rds.rb +0 -181
  33. data/test/s3/s3_test_base.rb +0 -23
  34. data/test/s3/test_helper.rb +0 -3
  35. data/test/s3/test_s3.rb +0 -162
  36. data/test/s3/test_s3_class.rb +0 -179
  37. data/test/s3/test_s3_rights.rb +0 -139
  38. data/test/s3/test_s3_stubbed.rb +0 -97
  39. data/test/sdb/test_active_sdb.rb +0 -338
  40. data/test/sdb/test_helper.rb +0 -3
  41. data/test/sdb/test_sdb.rb +0 -220
  42. data/test/sqs/test_helper.rb +0 -2
  43. data/test/sqs/test_sqs.rb +0 -232
  44. data/test/test_credentials.rb +0 -54
  45. data/test/ts_right_aws.rb +0 -13
@@ -89,9 +89,10 @@ module Aws
89
89
  end
90
90
 
91
91
  @@bench = AwsBenchmarkingBlock.new
92
- def self.bench
92
+ def self.bench
93
93
  @@bench
94
94
  end
95
+
95
96
  def self.bench_xml
96
97
  @@bench.xml
97
98
  end
@@ -403,26 +404,6 @@ module Aws
403
404
  on_exception
404
405
  end
405
406
 
406
- def describe_availability_zones(options={})
407
- link = generate_request("DescribeAvailabilityZones", options={})
408
- request_info_xml_simple(self.class.connection_name, @params, link, @logger,
409
- :group_tags =>{"DBInstances" =>"DBInstance",
410
- "DBParameterGroups"=>"DBParameterGroup",
411
- "DBSecurityGroups" =>"DBSecurityGroup",
412
- "EC2SecurityGroups"=>"EC2SecurityGroup",
413
- "IPRanges" =>"IPRange"},
414
- :force_array =>["DBInstances",
415
- "DBParameterGroups",
416
- "DBSecurityGroups",
417
- "EC2SecurityGroups",
418
- "IPRanges"],
419
- :pull_out_array =>options[:pull_out_array],
420
- :pull_out_single=>options[:pull_out_single],
421
- :wrapper =>options[:wrapper])
422
- rescue Exception
423
- on_exception
424
- end
425
-
426
407
  # Retrieve information about EC2 instances. If +list+ is omitted then returns the
427
408
  # list of all instances.
428
409
  #
@@ -448,7 +429,7 @@ module Aws
448
429
  #
449
430
  def describe_instances(list=[])
450
431
  link = generate_request("DescribeInstances", hash_params('InstanceId', list.to_a))
451
- request_cache_or_info(:describe_instances, link, QEc2DescribeInstancesParser, @@bench, list.blank?) do |parser|
432
+ request_cache_or_info(:describe_instances, link, QEc2DescribeInstancesParser, @@bench, list.nil? || list.empty?) do |parser|
452
433
  get_desc_instances(parser.result)
453
434
  end
454
435
  rescue Exception
@@ -560,23 +541,36 @@ module Aws
560
541
  'AddressingType' => options[:addressing_type] || DEFAULT_ADDRESSING_TYPE,
561
542
  'InstanceType' => options[:instance_type] || DEFAULT_INSTANCE_TYPE})
562
543
  # optional params
563
- params['KeyName'] = options[:key_name] unless options[:key_name].blank?
564
- params['KernelId'] = options[:kernel_id] unless options[:kernel_id].blank?
565
- params['RamdiskId'] = options[:ramdisk_id] unless options[:ramdisk_id].blank?
566
- params['Placement.AvailabilityZone'] = options[:availability_zone] unless options[:availability_zone].blank?
567
- params['BlockDeviceMappings'] = options[:block_device_mappings] unless options[:block_device_mappings].blank?
568
- params['Monitoring.Enabled'] = options[:monitoring_enabled] unless options[:monitoring_enabled].blank?
569
- params['SubnetId'] = options[:subnet_id] unless options[:subnet_id].blank?
570
- params['AdditionalInfo'] = options[:additional_info] unless options[:additional_info].blank?
544
+ params['KeyName'] = options[:key_name] unless Aws::Utils.blank?(options[:key_name])
545
+ params['KernelId'] = options[:kernel_id] unless Aws::Utils.blank?(options[:kernel_id])
546
+ params['RamdiskId'] = options[:ramdisk_id] unless Aws::Utils.blank?(options[:ramdisk_id])
547
+ params['Placement.AvailabilityZone'] = options[:availability_zone] unless Aws::Utils.blank?(options[:availability_zone])
548
+ params['BlockDeviceMappings'] = options[:block_device_mappings] unless Aws::Utils.blank?(options[:block_device_mappings])
549
+ params['Monitoring.Enabled'] = options[:monitoring_enabled] unless Aws::Utils.blank?(options[:monitoring_enabled])
550
+ params['SubnetId'] = options[:subnet_id] unless Aws::Utils.blank?(options[:subnet_id])
551
+ params['AdditionalInfo'] = options[:additional_info] unless Aws::Utils.blank?(options[:additional_info])
571
552
  params['DisableApiTermination'] = options[:disable_api_termination].to_s unless options[:disable_api_termination].nil?
572
- params['InstanceInitiatedShutdownBehavior'] = options[:instance_initiated_shutdown_behavior] unless options[:instance_initiated_shutdown_behavior].blank?
573
- unless options[:user_data].blank?
553
+ params['InstanceInitiatedShutdownBehavior'] = options[:instance_initiated_shutdown_behavior] unless Aws::Utils.blank?(options[:instance_initiated_shutdown_behavior])
554
+ unless Aws::Utils.blank?(options[:user_data])
574
555
  options[:user_data].strip!
575
556
  # Do not use CGI::escape(encode64(...)) as it is done in Amazons EC2 library.
576
557
  # Amazon 169.254.169.254 does not like escaped symbols!
577
558
  # And it doesn't like "\n" inside of encoded string! Grrr....
578
559
  # Otherwise, some of UserData symbols will be lost...
579
- params['UserData'] = Base64.encode64(options[:user_data]).delete("\n").strip unless options[:user_data].blank?
560
+ params['UserData'] = Base64.encode64(options[:user_data]).delete("\n").strip unless Aws::Utils.blank?(options[:user_data])
561
+ end
562
+ unless options[:block_device_mappings].blank?
563
+ options[:block_device_mappings].size.times do |n|
564
+ if options[:block_device_mappings][n][:virtual_name]
565
+ params["BlockDeviceMapping.#{n+1}.VirtualName"] = options[:block_device_mappings][n][:virtual_name]
566
+ end
567
+ if options[:block_device_mappings][n][:device_name]
568
+ params["BlockDeviceMapping.#{n+1}.DeviceName"] = options[:block_device_mappings][n][:device_name]
569
+ end
570
+ if options[:block_device_mappings][n][:ebs_snapshot_id]
571
+ params["BlockDeviceMapping.#{n+1}.Ebs.SnapshotId"] = options[:block_device_mappings][n][:ebs_snapshot_id]
572
+ end
573
+ end
580
574
  end
581
575
  link = generate_request("RunInstances", params)
582
576
  #debugger
@@ -613,7 +607,49 @@ module Aws
613
607
  rescue Exception
614
608
  on_exception
615
609
  end
616
-
610
+
611
+ # Stop EBS-backed EC2 instances. Returns a list of instance state changes or an exception.
612
+ #
613
+ # ec2.stop_instances(['i-f222222d', 'i-f222222e']) #=>
614
+ # [{:aws_instance_id => "i-f222222d",
615
+ # :aws_current_state_code => 64,
616
+ # :aws_current_state => "stopping",
617
+ # :aws_prev_state_code => 16,
618
+ # :aws_prev_state => "running"},
619
+ # {:aws_instance_id => "i-f222222e",
620
+ # :aws_current_state_code => 64,
621
+ # :aws_current_state => "stopping",
622
+ # :aws_prev_state_code => 16,
623
+ # :aws_prev_state => "running"}]
624
+ #
625
+ def stop_instances(list=[])
626
+ link = generate_request("StopInstances", hash_params('InstanceId', list.to_a))
627
+ request_info(link, QEc2StopInstancesParser.new(:logger => @logger))
628
+ rescue Exception
629
+ on_exception
630
+ end
631
+
632
+ # Start EBS-backed EC2 instances. Returns a list of instance state changes or an exception.
633
+ #
634
+ # ec2.start_instances(['i-f222222d', 'i-f222222e']) #=>
635
+ # [{:aws_instance_id => "i-f222222d",
636
+ # :aws_current_state_code => 0,
637
+ # :aws_current_state => "pending",
638
+ # :aws_prev_state_code => 80,
639
+ # :aws_prev_state => "stopped"},
640
+ # {:aws_instance_id => "i-f222222e",
641
+ # :aws_current_state_code => 0,
642
+ # :aws_current_state => "pending",
643
+ # :aws_prev_state_code => 80,
644
+ # :aws_prev_state => "stopped"}]
645
+ #
646
+ def start_instances(list=[])
647
+ link = generate_request("StartInstances", hash_params('InstanceId', list.to_a))
648
+ request_info(link, QEc2StartInstancesParser.new(:logger => @logger))
649
+ rescue Exception
650
+ on_exception
651
+ end
652
+
617
653
  # Retreive EC2 instance OS logs. Returns a hash of data or an exception.
618
654
  #
619
655
  # ec2.get_console_output('i-f222222d') =>
@@ -702,7 +738,7 @@ module Aws
702
738
  {'acl' => s3_upload_policy},
703
739
  ['starts-with', '$key', s3_prefix]]}.to_json
704
740
  policy64 = Base64.encode64(policy).gsub("\n", "")
705
- signed_policy64 = AwsUtils.sign(s3_owner_aws_secret_access_key, policy64)
741
+ signed_policy64 = Utils.sign(s3_owner_aws_secret_access_key, policy64)
706
742
  # fill request params
707
743
  params = {'InstanceId' => instance_id,
708
744
  'Storage.S3.AWSAccessKeyId' => s3_owner_aws_access_key_id,
@@ -768,50 +804,50 @@ module Aws
768
804
  # ec2.describe_security_groups #=>
769
805
  # [{:aws_group_name => "default-1",
770
806
  # :aws_owner => "000000000888",
771
- # :aws_description => "Default allowing SSH, HTTP, and HTTPS ingress",
807
+ # :aws_description => "a default security group",
772
808
  # :aws_perms =>
773
- # [{:owner => "000000000888", :group => "default"},
774
- # {:owner => "000000000888", :group => "default-1"},
775
- # {:to_port => "-1", :protocol => "icmp", :from_port => "-1", :cidr_ips => "0.0.0.0/0"},
776
- # {:to_port => "22", :protocol => "tcp", :from_port => "22", :cidr_ips => "0.0.0.0/0"},
777
- # {:to_port => "80", :protocol => "tcp", :from_port => "80", :cidr_ips => "0.0.0.0/0"},
778
- # {:to_port => "443", :protocol => "tcp", :from_port => "443", :cidr_ips => "0.0.0.0/0"}]},
779
- # ..., {...}]
809
+ # [ {:protocol => "tcp", :from_port=>"1000", :to_port=>"2000",
810
+ # :ip_ranges=>[{cidr_ip=>"10.1.2.3/32"}, {cidr_ip=>"192.168.1.10/24"}],
811
+ # :groups => [{:owner=>"123456789012", :group_name="default"}] },
812
+ #
813
+ # {:protocol ="icmp", :from_port="-1", :to_port=>"-1",
814
+ # :ip_ranges=>[{:cidr_ip=>"0.0.0.0/0"}],
815
+ # :groups=>[] },
816
+ #
817
+ # {:protocol=>"udp", :from_port=>"0", :to_port=>"65535",
818
+ # :ip_ranges=>[],
819
+ # :groups=>[{:owner=>"123456789012", :group_name=>"newgroup"}, {:owner=>"123456789012", :group_name=>"default"}],
820
+ #
821
+ # {:protocol=>"tcp", :from_port="22", :to_port=>"22",
822
+ # :ip_ranges=>[{:cidr_ip=>"0.0.0.0/0"}],
823
+ # :groups=>[{:owner=>"", :group_name=>"default"}] },
824
+ #
825
+ # ..., {...}
826
+ # ]
780
827
  #
781
828
  def describe_security_groups(list=[])
782
829
  link = generate_request("DescribeSecurityGroups", hash_params('GroupName', list.to_a))
783
- request_cache_or_info(:describe_security_groups, link, QEc2DescribeSecurityGroupsParser, @@bench, list.blank?) do |parser|
784
- result = []
785
- parser.result.each do |item|
786
- perms = []
787
- item.ipPermissions.each do |perm|
788
- perm.groups.each do |ngroup|
789
- perms << {:group => ngroup.groupName,
790
- :owner => ngroup.userId}
791
- end
792
- perm.ipRanges.each do |cidr_ip|
793
- perms << {:from_port => perm.fromPort,
794
- :to_port => perm.toPort,
795
- :protocol => perm.ipProtocol,
796
- :cidr_ips => cidr_ip}
797
- end
830
+ request_cache_or_info(:describe_security_groups, link, QEc2DescribeSecurityGroupsParser, @@bench, list.nil? || list.empty?) do |parser|
831
+ result = []
832
+ parser.result.each do |item|
833
+ perms = []
834
+ item.ipPermissions.each do |perm|
835
+ current = {:from_port => perm.fromPort,
836
+ :to_port => perm.toPort,
837
+ :protocol => perm.ipProtocol,
838
+ :groups => [], :ip_ranges => []}
839
+ perm.groups.each do |ngroup|
840
+ current[:groups] << {:group_name => ngroup.groupName, :owner => ngroup.userId}
798
841
  end
799
-
800
- # delete duplication
801
- perms.each_index do |i|
802
- (0...i).each do |j|
803
- if perms[i] == perms[j] then
804
- perms[i] = nil; break;
805
- end
806
- end
842
+ perm.ipRanges.each do |cidr_ip|
843
+ current[:ip_ranges] << {:cidr_ip => cidr_ip.cidrIp}
807
844
  end
808
- perms.compact!
809
-
810
- result << {:aws_owner => item.ownerId,
811
- :aws_group_name => item.groupName,
812
- :aws_description => item.groupDescription,
813
- :aws_perms => perms}
814
-
845
+ perms << current
846
+ end
847
+ result << {:aws_owner => item.ownerId,
848
+ :aws_group_name => item.groupName,
849
+ :aws_description => item.groupDescription,
850
+ :aws_perms => perms}
815
851
  end
816
852
  result
817
853
  end
@@ -825,7 +861,7 @@ module Aws
825
861
  #
826
862
  def create_security_group(name, description)
827
863
  # EC2 doesn't like an empty description...
828
- description = " " if description.blank?
864
+ description = " " if Aws::Utils.blank?(description)
829
865
  link = generate_request("CreateSecurityGroup",
830
866
  'GroupName' => name.to_s,
831
867
  'GroupDescription' => description.to_s)
@@ -922,7 +958,7 @@ module Aws
922
958
  #
923
959
  def describe_key_pairs(list=[])
924
960
  link = generate_request("DescribeKeyPairs", hash_params('KeyName', list.to_a))
925
- request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, @@bench, list.blank?
961
+ request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, @@bench, list.nil? || list.empty?
926
962
  rescue Exception
927
963
  on_exception
928
964
  end
@@ -995,7 +1031,7 @@ module Aws
995
1031
  def describe_addresses(list=[])
996
1032
  link = generate_request("DescribeAddresses",
997
1033
  hash_params('PublicIp', list.to_a))
998
- request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, list.blank?
1034
+ request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, list.nil? || list.empty?
999
1035
  rescue Exception
1000
1036
  on_exception
1001
1037
  end
@@ -1044,11 +1080,33 @@ module Aws
1044
1080
  def describe_availability_zones(list=[])
1045
1081
  link = generate_request("DescribeAvailabilityZones",
1046
1082
  hash_params('ZoneName', list.to_a))
1047
- request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, list.blank?
1083
+ request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, list.nil? || list.empty?
1048
1084
  rescue Exception
1049
1085
  on_exception
1050
1086
  end
1051
1087
 
1088
+ # This is using the new way, but not sure it's backwrads compatible
1089
+ def describe_availability_zones2(options={})
1090
+ link = generate_request("DescribeAvailabilityZones", options={})
1091
+ request_info_xml_simple(self.class.connection_name, @params, link, @logger,
1092
+ :group_tags =>{"DBInstances" =>"DBInstance",
1093
+ "DBParameterGroups"=>"DBParameterGroup",
1094
+ "DBSecurityGroups" =>"DBSecurityGroup",
1095
+ "EC2SecurityGroups"=>"EC2SecurityGroup",
1096
+ "IPRanges" =>"IPRange"},
1097
+ :force_array =>["DBInstances",
1098
+ "DBParameterGroups",
1099
+ "DBSecurityGroups",
1100
+ "EC2SecurityGroups",
1101
+ "IPRanges"],
1102
+ :pull_out_array =>options[:pull_out_array],
1103
+ :pull_out_single=>options[:pull_out_single],
1104
+ :wrapper =>options[:wrapper])
1105
+ rescue Exception
1106
+ on_exception
1107
+ end
1108
+
1109
+
1052
1110
  #-----------------------------------------------------------------
1053
1111
  # Regions
1054
1112
  #-----------------------------------------------------------------
@@ -1060,7 +1118,7 @@ module Aws
1060
1118
  def describe_regions(list=[])
1061
1119
  link = generate_request("DescribeRegions",
1062
1120
  hash_params('RegionName', list.to_a))
1063
- request_cache_or_info :describe_regions, link, QEc2DescribeRegionsParser, @@bench, list.blank?
1121
+ request_cache_or_info :describe_regions, link, QEc2DescribeRegionsParser, @@bench, list.nil? || list.empty?
1064
1122
  rescue Exception
1065
1123
  on_exception
1066
1124
  end
@@ -1093,7 +1151,7 @@ module Aws
1093
1151
  def describe_volumes(list=[])
1094
1152
  link = generate_request("DescribeVolumes",
1095
1153
  hash_params('VolumeId', list.to_a))
1096
- request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, @@bench, list.blank?
1154
+ request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, @@bench, list.nil? || list.empty?
1097
1155
  rescue Exception
1098
1156
  on_exception
1099
1157
  end
@@ -1178,8 +1236,8 @@ module Aws
1178
1236
  #
1179
1237
  def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
1180
1238
  hash = {"VolumeId" => volume_id.to_s}
1181
- hash["InstanceId"] = instance_id.to_s unless instance_id.blank?
1182
- hash["Device"] = device.to_s unless device.blank?
1239
+ hash["InstanceId"] = instance_id.to_s unless Aws::Utils.blank?(instance_id)
1240
+ hash["Device"] = device.to_s unless Aws::Utils.blank?(device)
1183
1241
  hash["Force"] = 'true' if force
1184
1242
  #
1185
1243
  link = generate_request("DetachVolume", hash)
@@ -1210,7 +1268,7 @@ module Aws
1210
1268
  def describe_snapshots(list=[])
1211
1269
  link = generate_request("DescribeSnapshots",
1212
1270
  hash_params('SnapshotId', list.to_a))
1213
- request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, @@bench, list.blank?
1271
+ request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, @@bench, list.nil? || list.empty?
1214
1272
  rescue Exception
1215
1273
  on_exception
1216
1274
  end
@@ -1224,9 +1282,8 @@ module Aws
1224
1282
  # :aws_status => "pending",
1225
1283
  # :aws_id => "snap-d56783bc"}
1226
1284
  #
1227
- def create_snapshot(volume_id)
1228
- link = generate_request("CreateSnapshot",
1229
- "VolumeId" => volume_id.to_s)
1285
+ def create_snapshot(volume_id, options={})
1286
+ link = generate_request("CreateSnapshot", options.merge({"VolumeId" => volume_id.to_s}))
1230
1287
  request_info(link, QEc2CreateSnapshotParser.new(:logger => @logger))
1231
1288
  rescue Exception
1232
1289
  on_exception
@@ -1397,6 +1454,10 @@ module Aws
1397
1454
  attr_accessor :groupName
1398
1455
  end
1399
1456
 
1457
+ class QEc2IpRangeItemType #:nodoc:
1458
+ attr_accessor :cidrIp
1459
+ end
1460
+
1400
1461
  class QEc2IpPermissionType #:nodoc:
1401
1462
  attr_accessor :ipProtocol
1402
1463
  attr_accessor :fromPort
@@ -1426,35 +1487,32 @@ module Aws
1426
1487
  @perm.groups = []
1427
1488
  elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups'
1428
1489
  @sgroup = QEc2UserIdGroupPairType.new
1490
+ elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/ipRanges'
1491
+ @sIpRange = QEc2IpRangeItemType.new
1429
1492
  end
1430
1493
  end
1431
1494
  end
1432
1495
 
1433
1496
  def tagend(name)
1434
1497
  case name
1435
- when 'ownerId' then
1436
- @group.ownerId = @text
1437
- when 'groupDescription' then
1438
- @group.groupDescription = @text
1498
+ when 'ownerId' then @group.ownerId = @text
1499
+ when 'groupDescription' then @group.groupDescription = @text
1439
1500
  when 'groupName'
1440
1501
  if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item'
1441
- @group.groupName = @text
1502
+ @group.groupName = @text
1442
1503
  elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups/item'
1443
1504
  @sgroup.groupName = @text
1444
1505
  end
1445
- when 'ipProtocol' then
1446
- @perm.ipProtocol = @text
1447
- when 'fromPort' then
1448
- @perm.fromPort = @text
1449
- when 'toPort' then
1450
- @perm.toPort = @text
1451
- when 'userId' then
1452
- @sgroup.userId = @text
1453
- when 'cidrIp' then
1454
- @perm.ipRanges << @text
1506
+ when 'ipProtocol' then @perm.ipProtocol = @text
1507
+ when 'fromPort' then @perm.fromPort = @text
1508
+ when 'toPort' then @perm.toPort = @text
1509
+ when 'userId' then @sgroup.userId = @text
1510
+ when 'cidrIp' then @sIpRange.cidrIp = @text
1455
1511
  when 'item'
1456
1512
  if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups'
1457
1513
  @perm.groups << @sgroup
1514
+ elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/ipRanges'
1515
+ @perm.ipRanges << @sIpRange
1458
1516
  elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions'
1459
1517
  @group.ipPermissions << @perm
1460
1518
  elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo'
@@ -1745,6 +1803,69 @@ module Aws
1745
1803
  @result = []
1746
1804
  end
1747
1805
  end
1806
+
1807
+ class QEc2StopInstancesParser < AwsParser #:nodoc:
1808
+ def tagstart(name, attributes)
1809
+ @instance = {} if name == 'item'
1810
+ end
1811
+
1812
+ def tagend(name)
1813
+ case name
1814
+ when 'instanceId' then
1815
+ @instance[:aws_instance_id] = @text
1816
+ when 'code'
1817
+ if @xmlpath == 'StopInstancesResponse/instancesSet/item/currentState'
1818
+ @instance[:aws_current_state_code] = @text.to_i
1819
+ elsif @xmlpath == 'StopInstancesResponse/instancesSet/item/previousState'
1820
+ @instance[:aws_prev_state_code] = @text.to_i
1821
+ end
1822
+ when 'name'
1823
+ if @xmlpath == 'StopInstancesResponse/instancesSet/item/currentState'
1824
+ @instance[:aws_current_state] = @text
1825
+ elsif @xmlpath == 'StopInstancesResponse/instancesSet/item/previousState'
1826
+ @instance[:aws_prev_state] = @text
1827
+ end
1828
+ when 'item' then
1829
+ @result << @instance
1830
+ end
1831
+ end
1832
+
1833
+ def reset
1834
+ @result = []
1835
+ end
1836
+ end
1837
+
1838
+ class QEc2StartInstancesParser < AwsParser #:nodoc:
1839
+ def tagstart(name, attributes)
1840
+ @instance = {} if name == 'item'
1841
+ end
1842
+
1843
+ def tagend(name)
1844
+ case name
1845
+ when 'instanceId' then
1846
+ @instance[:aws_instance_id] = @text
1847
+ when 'code'
1848
+ if @xmlpath == 'StartInstancesResponse/instancesSet/item/currentState'
1849
+ @instance[:aws_current_state_code] = @text.to_i
1850
+ elsif @xmlpath == 'StartInstancesResponse/instancesSet/item/previousState'
1851
+ @instance[:aws_prev_state_code] = @text.to_i
1852
+ end
1853
+ when 'name'
1854
+ if @xmlpath == 'StartInstancesResponse/instancesSet/item/currentState'
1855
+ @instance[:aws_current_state] = @text
1856
+ elsif @xmlpath == 'StartInstancesResponse/instancesSet/item/previousState'
1857
+ @instance[:aws_prev_state] = @text
1858
+ end
1859
+ when 'item' then
1860
+ @result << @instance
1861
+ end
1862
+ end
1863
+
1864
+ def reset
1865
+ @result = []
1866
+ end
1867
+ end
1868
+
1748
1869
 
1749
1870
  #-----------------------------------------------------------------
1750
1871
  # PARSERS: Console
@@ -1859,7 +1980,7 @@ module Aws
1859
1980
  def tagend(name)
1860
1981
  case name
1861
1982
  when 'instanceId' then
1862
- @address[:instance_id] = @text.blank? ? nil : @text
1983
+ @address[:instance_id] = Aws::Utils.blank?(@text) ? nil : @text
1863
1984
  when 'publicIp' then
1864
1985
  @address[:public_ip] = @text
1865
1986
  when 'item' then
@@ -1929,7 +2050,7 @@ module Aws
1929
2050
  when 'size' then
1930
2051
  @result[:aws_size] = @text.to_i ###
1931
2052
  when 'snapshotId' then
1932
- @result[:snapshot_id] = @text.blank? ? nil : @text ###
2053
+ @result[:snapshot_id] = Aws::Utils.blank?(@text) ? nil : @text ###
1933
2054
  when 'availabilityZone' then
1934
2055
  @result[:zone] = @text ###
1935
2056
  end
@@ -1997,7 +2118,7 @@ module Aws
1997
2118
  when 'attachTime' then
1998
2119
  @volume[:aws_attached_at] = Time.parse(@text)
1999
2120
  when 'snapshotId' then
2000
- @volume[:snapshot_id] = @text.blank? ? nil : @text
2121
+ @volume[:snapshot_id] = Aws::Utils.blank?(@text) ? nil : @text
2001
2122
  when 'availabilityZone' then
2002
2123
  @volume[:zone] = @text
2003
2124
  when 'item'
@@ -2018,8 +2139,19 @@ module Aws
2018
2139
  #-----------------------------------------------------------------
2019
2140
 
2020
2141
  class QEc2DescribeSnapshotsParser < AwsParser #:nodoc:
2142
+
2143
+ def initialize (params={})
2144
+ @inside_tagset = false
2145
+ super(params)
2146
+ end
2147
+
2021
2148
  def tagstart(name, attributes)
2022
- @snapshot = {} if name == 'item'
2149
+ case name
2150
+ when 'tagSet'
2151
+ @inside_tagset = true
2152
+ when 'item'
2153
+ @snapshot = {} unless @inside_tagset
2154
+ end
2023
2155
  end
2024
2156
 
2025
2157
  def tagend(name)
@@ -2040,8 +2172,14 @@ module Aws
2040
2172
  @snapshot[:aws_owner] = @text
2041
2173
  when 'volumeSize' then
2042
2174
  @snapshot[:aws_volume_size] = @text.to_i
2175
+ when 'tagSet' then
2176
+ @inside_tagset = false
2177
+ when 'key' then
2178
+ @key = ('aws_tag_' + @text).to_sym
2179
+ when 'value' then
2180
+ @snapshot[@key] = @text
2043
2181
  when 'item' then
2044
- @result << @snapshot
2182
+ @result << @snapshot unless @inside_tagset
2045
2183
  end
2046
2184
  end
2047
2185