right_aws 2.1.0 → 3.0.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.
@@ -38,7 +38,8 @@ module RightAws
38
38
  instance[:aws_reason] = instance[:aws_reason].sub(/\(\d[^)]*GMT\) */, '')
39
39
  instance[:aws_owner] = reservation[:aws_owner]
40
40
  instance[:aws_reservation_id] = reservation[:aws_reservation_id]
41
- instance[:aws_groups] = reservation[:aws_groups]
41
+ # Security Groups
42
+ instance[:groups] = instance[:groups].right_blank? ? reservation[:aws_groups] : instance[:groups]
42
43
  result << instance
43
44
  end
44
45
  end
@@ -61,38 +62,45 @@ module RightAws
61
62
  #
62
63
  #
63
64
  # ec2.describe_instances #=>
64
- # [{:private_ip_address=>"10.240.7.99",
65
- # :aws_image_id=>"ami-c2a3f5d4",
66
- # :ip_address=>"174.129.134.109",
67
- # :dns_name=>"ec2-174-129-134-109.compute-1.amazonaws.com",
68
- # :aws_instance_type=>"m1.small",
69
- # :aws_owner=>"826693181925",
70
- # :root_device_name=>"/dev/sda1",
71
- # :instance_class=>"elastic",
72
- # :aws_state=>"running",
73
- # :private_dns_name=>"domU-12-31-39-04-00-95.compute-1.internal",
74
- # :aws_reason=>"",
75
- # :aws_launch_time=>"2009-11-18T14:03:25.000Z",
76
- # :aws_reservation_id=>"r-54d38542",
77
- # :aws_state_code=>16,
78
- # :ami_launch_index=>"0",
79
- # :aws_availability_zone=>"us-east-1a",
80
- # :aws_groups=>["default"],
81
- # :monitoring_state=>"disabled",
82
- # :aws_product_codes=>[],
83
- # :ssh_key_name=>"",
84
- # :block_device_mappings=>
85
- # [{:ebs_status=>"attached",
86
- # :ebs_delete_on_termination=>true,
87
- # :ebs_attach_time=>"2009-11-18T14:03:34.000Z",
88
- # :device_name=>"/dev/sda1",
89
- # :ebs_volume_id=>"vol-e600f98f"},
90
- # {:ebs_status=>"attached",
91
- # :ebs_delete_on_termination=>true,
92
- # :ebs_attach_time=>"2009-11-18T14:03:34.000Z",
93
- # :device_name=>"/dev/sdk",
94
- # :ebs_volume_id=>"vol-f900f990"}],
95
- # :aws_instance_id=>"i-8ce84ae4"} , ... ]
65
+ # [{:source_dest_check=>true,
66
+ # :subnet_id=>"subnet-da6cf9b3",
67
+ # :aws_kernel_id=>"aki-3932d150",
68
+ # :ami_launch_index=>"0",
69
+ # :tags=>{},
70
+ # :aws_reservation_id=>"r-7cd25c11",
71
+ # :aws_owner=>"826693181925",
72
+ # :state_reason_code=>"Client.UserInitiatedShutdown",
73
+ # :aws_instance_id=>"i-2d898e41",
74
+ # :hypervisor=>"xen",
75
+ # :root_device_name=>"/dev/sda1",
76
+ # :aws_ramdisk_id=>"ari-c515f6ac",
77
+ # :aws_instance_type=>"m1.large",
78
+ # :groups=>[{:group_name=>"2009-07-15-default", :group_id=>"sg-90c5d6fc"}],
79
+ # :block_device_mappings=>
80
+ # [{:device_name=>"/dev/sda1",
81
+ # :ebs_status=>"attached",
82
+ # :ebs_attach_time=>"2011-03-04T18:51:58.000Z",
83
+ # :ebs_delete_on_termination=>true,
84
+ # :ebs_volume_id=>"vol-38f2bd50"}],
85
+ # :state_reason_message=>
86
+ # "Client.UserInitiatedShutdown: User initiated shutdown",
87
+ # :aws_image_id=>"ami-a3638cca",
88
+ # :virtualization_type=>"paravirtual",
89
+ # :aws_launch_time=>"2011-03-04T18:13:59.000Z",
90
+ # :private_dns_name=>"",
91
+ # :aws_product_codes=>[],
92
+ # :aws_availability_zone=>"us-east-1a",
93
+ # :aws_state_code=>80,
94
+ # :architecture=>"x86_64",
95
+ # :dns_name=>"",
96
+ # :client_token=>"1299262447-684266-NNgyH-ouPTI-MzG6h-5AIRk",
97
+ # :root_device_type=>"ebs",
98
+ # :vpc_id=>"vpc-e16cf988",
99
+ # :monitoring_state=>"disabled",
100
+ # :ssh_key_name=>"default",
101
+ # :private_ip_address=>"192.168.0.52",
102
+ # :aws_reason=>"User initiated ",
103
+ # :aws_state=>"stopped"}, ...]
96
104
  #
97
105
  # ec2.describe_instances("i-8ce84ae6", "i-8ce84ae8", "i-8ce84ae0")
98
106
  # ec2.describe_instances(:filters => { 'availability-zone' => 'us-east-1a', 'instance-type' => 'c1.medium' })
@@ -118,7 +126,7 @@ module RightAws
118
126
 
119
127
  # Launch new EC2 instances. Returns a list of launched instances or an exception.
120
128
  #
121
- # ec2.run_instances('ami-e444444d',1,1,['my_awesome_group'],'my_awesome_key', 'Woohoo!!!', 'public') #=>
129
+ # ec2.run_instances('ami-e444444d',1,1,['2009-07-15-default'],'my_awesome_key', 'Woohoo!!!', 'public') #=>
122
130
  # [{:aws_image_id => "ami-e444444d",
123
131
  # :aws_reason => "",
124
132
  # :aws_state_code => "0",
@@ -128,7 +136,7 @@ module RightAws
128
136
  # :aws_state => "pending",
129
137
  # :dns_name => "",
130
138
  # :ssh_key_name => "my_awesome_key",
131
- # :aws_groups => ["my_awesome_group"],
139
+ # :groups => [{:group_name=>"2009-07-15-default", :group_id=>"sg-90c5d6fc"}],
132
140
  # :private_dns_name => "",
133
141
  # :aws_instance_type => "m1.small",
134
142
  # :aws_launch_time => "2008-1-1T00:00:00.000Z"
@@ -138,7 +146,7 @@ module RightAws
138
146
  # :aws_availability_zone => "us-east-1b"
139
147
  # }]
140
148
  #
141
- def run_instances(image_id, min_count, max_count, group_ids, key_name, user_data='',
149
+ def run_instances(image_id, min_count, max_count, group_names, key_name, user_data='',
142
150
  addressing_type = nil, instance_type = nil,
143
151
  kernel_id = nil, ramdisk_id = nil, availability_zone = nil,
144
152
  monitoring_enabled = nil, subnet_id = nil, disable_api_termination = nil,
@@ -147,7 +155,7 @@ module RightAws
147
155
  launch_instances(image_id, { :min_count => min_count,
148
156
  :max_count => max_count,
149
157
  :user_data => user_data,
150
- :group_ids => group_ids,
158
+ :group_names => group_names,
151
159
  :key_name => key_name,
152
160
  :instance_type => instance_type,
153
161
  :addressing_type => addressing_type,
@@ -165,50 +173,74 @@ module RightAws
165
173
  end
166
174
 
167
175
  # Launch new EC2 instances.
176
+ #
168
177
  # Options: :image_id, :addressing_type, :min_count, max_count, :key_name, :kernel_id, :ramdisk_id,
169
178
  # :availability_zone, :monitoring_enabled, :subnet_id, :disable_api_termination, :instance_initiated_shutdown_behavior,
170
- # :block_device_mappings, :placement_group_name, :license_pool
179
+ # :block_device_mappings, :placement_group_name, :license_pool, :group_ids, :group_names, :private_ip_address
171
180
  #
172
181
  # Returns a list of launched instances or an exception.
173
182
  #
174
- # ec2.launch_instances( 'ami-c2a3f5d4',
183
+ # ec2.launch_instances( "ami-78779511",
175
184
  # :min_count => 1,
176
- # :group_ids => 'default',
185
+ # :group_names => ["default", "eugeg223123123"],
177
186
  # :user_data => 'Ohoho!',
178
187
  # :availability_zone => "us-east-1a",
179
- # :disable_api_termination => true,
188
+ # :disable_api_termination => false,
180
189
  # :instance_initiated_shutdown_behavior => 'terminate',
181
- # :block_device_mappings => [ {:ebs_snapshot_id=>"snap-7360871a",
190
+ # :block_device_mappings => [ {:ebs_snapshot_id=>"snap-e40fd188",
182
191
  # :ebs_delete_on_termination=>true,
183
192
  # :device_name => "/dev/sdk",
184
193
  # :virtual_name => "mystorage"} ] ) #=>
185
- # [{:aws_image_id=>"ami-c2a3f5d4",
186
- # :dns_name=>"",
187
- # :aws_instance_type=>"m1.small",
188
- # :aws_owner=>"826693181925",
189
- # :root_device_name=>"/dev/sda1",
190
- # :instance_class=>"elastic",
191
- # :state_reason_code=>0,
192
- # :aws_state=>"pending",
194
+ # [{:hypervisor=>"xen",
193
195
  # :private_dns_name=>"",
196
+ # :client_token=>"1309532374-551037-gcsBj-gEypk-piG06-ODfQm",
197
+ # :monitoring_state=>"disabled",
198
+ # :aws_availability_zone=>"us-east-1a",
199
+ # :root_device_name=>"/dev/sda1",
200
+ # :state_reason_code=>"pending",
201
+ # :dns_name=>"",
202
+ # :tags=>{},
194
203
  # :aws_reason=>"",
195
- # :aws_launch_time=>"2009-11-18T14:03:25.000Z",
196
- # :aws_reservation_id=>"r-54d38542",
204
+ # :virtualization_type=>"paravirtual",
197
205
  # :state_reason_message=>"pending",
198
- # :aws_state_code=>0,
206
+ # :aws_reservation_id=>"r-6fada703",
207
+ # :aws_ramdisk_id=>"ari-a51cf9cc",
199
208
  # :ami_launch_index=>"0",
200
- # :aws_availability_zone=>"us-east-1a",
201
- # :aws_groups=>["default"],
202
- # :monitoring_state=>"disabled",
203
- # :aws_product_codes=>[],
204
- # :ssh_key_name=>"",
205
- # :aws_instance_id=>"i-8ce84ae4"}]
209
+ # :groups=>
210
+ # [{:group_id=>"sg-a0b85dc9", :group_name=>"default"},
211
+ # {:group_id=>"sg-70733019", :group_name=>"eugeg223123123"}],
212
+ # :aws_owner=>"826693181925",
213
+ # :aws_instance_type=>"m1.small",
214
+ # :aws_state=>"pending",
215
+ # :root_device_type=>"ebs",
216
+ # :aws_image_id=>"ami-78779511",
217
+ # :aws_kernel_id=>"aki-a71cf9ce",
218
+ # :aws_launch_time=>"2011-07-01T14:59:35.000Z",
219
+ # :aws_state_code=>0,
220
+ # :aws_instance_id=>"i-4f202621",
221
+ # :aws_product_codes=>[]}]
206
222
  #
207
223
  def launch_instances(image_id, options={})
208
- options[:image_id] = image_id
209
- options[:min_count] ||= 1
210
- options[:max_count] ||= options[:min_count]
211
- params = prepare_instance_launch_params(options)
224
+ options[:user_data] = options[:user_data].to_s
225
+ params = map_api_keys_and_values( options,
226
+ :key_name, :addressing_type, :kernel_id,
227
+ :ramdisk_id, :subnet_id, :instance_initiated_shutdown_behavior,
228
+ :private_ip_address, :additional_info, :license_pool,
229
+ :image_id => { :value => image_id },
230
+ :min_count => { :value => options[:min_count] || 1 },
231
+ :max_count => { :value => options[:max_count] || options[:min_count] || 1 },
232
+ :placement_tenancy => 'Placement.Tenancy',
233
+ :placement_group_name => 'Placement.GroupName',
234
+ :availability_zone => 'Placement.AvailabilityZone',
235
+ :group_names => { :amazonize_list => 'SecurityGroup' },
236
+ :group_ids => { :amazonize_list => 'SecurityGroupId' },
237
+ :block_device_mappings => { :amazonize_bdm => 'BlockDeviceMapping' },
238
+ :instance_type => { :value => options[:instance_type] || DEFAULT_INSTANCE_TYPE },
239
+ :disable_api_termination => { :value => Proc.new{ !options[:disable_api_termination].nil? && options[:disable_api_termination].to_s }},
240
+ :client_token => { :value => !@params[:eucalyptus] && (options[:client_token] || AwsUtils::generate_unique_token)},
241
+ :user_data => { :value => Proc.new { !options[:user_data].empty? && Base64.encode64(options[:user_data]).delete("\n") }},
242
+ :monitoring_enabled => { :name => 'Monitoring.Enabled',
243
+ :value => Proc.new{ options[:monitoring_enabled] && options[:monitoring_enabled].to_s }})
212
244
  # Log debug information
213
245
  @logger.info("Launching instance of image #{image_id}. Options: #{params.inspect}")
214
246
  link = generate_request("RunInstances", params)
@@ -218,39 +250,6 @@ module RightAws
218
250
  on_exception
219
251
  end
220
252
 
221
- def prepare_instance_launch_params(options={}) # :nodoc:
222
- params = amazonize_list('SecurityGroup', Array(options[:group_ids]))
223
- params['InstanceType'] = options[:instance_type] || DEFAULT_INSTANCE_TYPE
224
- params['ImageId'] = options[:image_id] unless options[:image_id].right_blank?
225
- params['AddressingType'] = options[:addressing_type] unless options[:addressing_type].right_blank?
226
- params['MinCount'] = options[:min_count] unless options[:min_count].right_blank?
227
- params['MaxCount'] = options[:max_count] unless options[:max_count].right_blank?
228
- params['KeyName'] = options[:key_name] unless options[:key_name].right_blank?
229
- params['KernelId'] = options[:kernel_id] unless options[:kernel_id].right_blank?
230
- params['RamdiskId'] = options[:ramdisk_id] unless options[:ramdisk_id].right_blank?
231
- params['Placement.AvailabilityZone'] = options[:availability_zone] unless options[:availability_zone].right_blank?
232
- params['Monitoring.Enabled'] = options[:monitoring_enabled].to_s if options[:monitoring_enabled]
233
- params['SubnetId'] = options[:subnet_id] unless options[:subnet_id].right_blank?
234
- params['AdditionalInfo'] = options[:additional_info] unless options[:additional_info].right_blank?
235
- params['DisableApiTermination'] = options[:disable_api_termination].to_s unless options[:disable_api_termination].nil?
236
- params['InstanceInitiatedShutdownBehavior'] = options[:instance_initiated_shutdown_behavior] unless options[:instance_initiated_shutdown_behavior].right_blank?
237
- params['Placement.GroupName'] = options[:placement_group_name] unless options[:placement_group_name].right_blank?
238
- params['License.Pool'] = options[:license_pool] unless options[:license_pool].right_blank?
239
- params['ClientToken'] = options[:client_token] || AwsUtils::generate_unique_token
240
- params.merge!(amazonize_block_device_mappings(options[:block_device_mappings]))
241
- # KD: https://github.com/rightscale/right_aws/issues#issue/11
242
- # Do not modify user data and pass it as is: one may pass there a hex-binary data
243
- options[:user_data] = options[:user_data].to_s
244
- unless options[:user_data].empty?
245
- # Do not use CGI::escape(encode64(...)) as it is done in Amazons EC2 library.
246
- # Amazon 169.254.169.254 does not like escaped symbols!
247
- # And it doesn't like "\n" inside of encoded string! Grrr....
248
- # Otherwise, some of UserData symbols will be lost...
249
- params['UserData'] = Base64.encode64(options[:user_data]).delete("\n")
250
- end
251
- params
252
- end
253
-
254
253
  # Start instances.
255
254
  #
256
255
  # ec2.start_instances("i-36e84a5e") #=>
@@ -268,6 +267,8 @@ module RightAws
268
267
 
269
268
  # Stop instances.
270
269
  #
270
+ # Options: :force => true|false
271
+ #
271
272
  # ec2.stop_instances("i-36e84a5e") #=>
272
273
  # [{:aws_prev_state_code=>16,
273
274
  # :aws_prev_state_name=>"running",
@@ -275,9 +276,12 @@ module RightAws
275
276
  # :aws_current_state_code=>64,
276
277
  # :aws_current_state_name=>"stopping"}]
277
278
  #
278
- def stop_instances(*instance_aws_ids)
279
- instance_aws_ids = instance_aws_ids.flatten
280
- link = generate_request("StopInstances", amazonize_list('InstanceId', instance_aws_ids))
279
+ def stop_instances(*instance_aws_ids_and_options)
280
+ list, options = AwsUtils::split_items_and_params(instance_aws_ids_and_options)
281
+ request_hash = {}
282
+ request_hash['Force'] = true if options[:force]
283
+ request_hash.merge!(amazonize_list('InstanceId', list))
284
+ link = generate_request("StopInstances", request_hash)
281
285
  request_info(link, QEc2TerminateInstancesParser.new(:logger => @logger))
282
286
  end
283
287
 
@@ -324,52 +328,38 @@ module RightAws
324
328
  on_exception
325
329
  end
326
330
 
327
- INSTANCE_ATTRIBUTE_MAPPING = {
328
- "instance_type" => "instanceType",
329
- "kernel" => "kernel",
330
- "ramdisk" => "ramdisk",
331
- "user_data" => "userData",
332
- "disable_api_termination" => "disableApiTermination",
333
- "instance_initiated_shutdown_behavior" => "instanceInitiatedShutdownBehavior",
334
- "root_device_name" => "rootDeviceName",
335
- "block_device_mapping" => "blockDeviceMapping"
336
- }
337
-
338
331
  # Describe instance attribute.
339
- # Attributes: :instance_type, :kernel, :ramdisk, :user_data, :disable_api_termination, :instance_initiated_shutdown_behavior, :root_device_name, :block_device_mapping
340
332
  #
341
- # ec2.describe_instance_attribute(instance, "BlockDeviceMapping") #=>
333
+ # Attributes: 'instanceType', 'kernel', 'ramdisk', 'userData', 'rootDeviceName', 'disableApiTermination',
334
+ # 'instanceInitiatedShutdownBehavior', 'sourceDestCheck', 'blockDeviceMapping', 'groupSet'
335
+ #
336
+ # ec2.describe_instance_attribute(instance, "blockDeviceMapping") #=>
342
337
  # [{:ebs_delete_on_termination=>true,
343
338
  # :ebs_volume_id=>"vol-683dc401",
344
339
  # :device_name=>"/dev/sda1"}]
345
340
  #
346
- # ec2.describe_instance_attribute(instance, "InstanceType") #=> "m1.small"
341
+ # ec2.describe_instance_attribute(instance, "instanceType") #=> "m1.small"
347
342
  #
348
- # ec2.describe_instance_attribute(instance, "InstanceInitiatedShutdownBehavior") #=> "stop"
343
+ # ec2.describe_instance_attribute(instance, "instanceInitiatedShutdownBehavior") #=> "stop"
349
344
  #
350
345
  def describe_instance_attribute(instance_id, attribute)
351
- attribute = INSTANCE_ATTRIBUTE_MAPPING[attribute.to_s] || attribute.to_s
352
346
  link = generate_request('DescribeInstanceAttribute',
353
347
  'InstanceId' => instance_id,
354
348
  'Attribute' => attribute)
355
349
  value = request_info(link, QEc2DescribeInstanceAttributeParser.new(:logger => @logger))
356
- case attribute
357
- when "userData"
358
- Base64.decode64(value)
359
- else
360
- value
361
- end
350
+ value = Base64.decode64(value) if attribute == "userData" && !value.right_blank?
351
+ value
362
352
  rescue Exception
363
353
  on_exception
364
354
  end
365
355
 
366
356
  # Describe instance attribute.
367
- # Attributes: :kernel, :ramdisk
368
357
  #
369
- # ec2.reset_instance_attribute(instance, :kernel) #=> true
358
+ # Attributes: 'kernel', 'ramdisk', 'sourceDestCheck'
359
+ #
360
+ # ec2.reset_instance_attribute(instance, 'kernel') #=> true
370
361
  #
371
362
  def reset_instance_attribute(instance_id, attribute)
372
- attribute = INSTANCE_ATTRIBUTE_MAPPING[attribute.to_s] || attribute.to_s
373
363
  link = generate_request('ResetInstanceAttribute',
374
364
  'InstanceId' => instance_id,
375
365
  'Attribute' => attribute )
@@ -379,23 +369,21 @@ module RightAws
379
369
  end
380
370
 
381
371
  # Modify instance attribute.
382
- # Attributes: :instance_type, :kernel, :ramdisk, :user_data, :disable_api_termination, :instance_initiated_shutdown_behavior, :root_device_name, :block_device_mapping
383
372
  #
384
- # ec2.modify_instance_attribute(instance, :instance_initiated_shutdown_behavior, "stop") #=> true
373
+ # Attributes: 'InstanceType', 'Kernel', 'Ramdisk', 'UserData', 'DisableApiTermination',
374
+ # 'InstanceInitiatedShutdownBehavior', 'SourceDestCheck', 'GroupId'
375
+ #
376
+ # ec2.modify_instance_attribute(instance, 'instanceInitiatedShutdownBehavior", "stop") #=> true
385
377
  #
386
378
  def modify_instance_attribute(instance_id, attribute, value)
387
- attribute = INSTANCE_ATTRIBUTE_MAPPING[attribute.to_s] || attribute.to_s
388
- params = { 'InstanceId' => instance_id,
389
- 'Attribute' => attribute }
379
+ request_hash = {'InstanceId' => instance_id}
380
+ attribute = attribute.to_s.right_underscore.right_camelize
390
381
  case attribute
391
- when "blockDeviceMapping"
392
- params.merge!(amazonize_block_device_mappings(value))
393
- when "userData"
394
- params['Value'] = Base64.encode64(value).delete("\n")
395
- else
396
- params['Value'] = value
382
+ when 'UserData' then request_hash["#{attribute}.Value"] = Base64.encode64(value).delete("\n")
383
+ when 'GroupId' then request_hash.merge!(amazonize_list('GroupId', value))
384
+ else request_hash["#{attribute}.Value"] = value
397
385
  end
398
- link = generate_request('ModifyInstanceAttribute', params)
386
+ link = generate_request('ModifyInstanceAttribute', request_hash)
399
387
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
400
388
  rescue Exception
401
389
  on_exception
@@ -551,21 +539,16 @@ module RightAws
551
539
 
552
540
  class QEc2DescribeInstancesParser < RightAWSParser #:nodoc:
553
541
  def tagstart(name, attributes)
554
- # DescribeInstances property
555
542
  case full_tag_name
556
- when 'DescribeInstancesResponse/reservationSet/item',
557
- 'RunInstancesResponse'
543
+ when %r{(RunInstancesResponse|DescribeInstancesResponse/reservationSet/item)$}
558
544
  @reservation = { :aws_groups => [],
559
545
  :instances_set => [] }
546
+ when %r{(/groupSet/item|instancesSet/item/placement)$}
547
+ @group = {}
560
548
  when %r{instancesSet/item$}
561
549
  # the optional params (sometimes are missing and we dont want them to be nil)
562
- @item = { :aws_reason => '',
563
- :dns_name => '',
564
- :private_dns_name => '',
565
- :ami_launch_index => '',
566
- :ssh_key_name => '',
567
- :aws_state => '',
568
- :aws_product_codes => [],
550
+ @item = { :aws_product_codes => [],
551
+ :groups => [],
569
552
  :tags => {} }
570
553
  when %r{blockDeviceMapping/item$}
571
554
  @item[:block_device_mappings] ||= []
@@ -578,7 +561,6 @@ module RightAws
578
561
  case name
579
562
  when 'reservationId' then @reservation[:aws_reservation_id] = @text
580
563
  when 'ownerId' then @reservation[:aws_owner] = @text
581
- when 'groupId' then @reservation[:aws_groups] << @text
582
564
  when 'instanceId' then @item[:aws_instance_id] = @text
583
565
  when 'imageId' then @item[:aws_image_id] = @text
584
566
  when 'privateDnsName' then @item[:private_dns_name] = @text
@@ -604,11 +586,25 @@ module RightAws
604
586
  when 'instanceLifecycle' then @item[:instance_lifecycle] = @text
605
587
  when 'spotInstanceRequestId' then @item[:spot_instance_request_id] = @text
606
588
  when 'requesterId' then @item[:requester_id] = @text
607
- when 'groupName' then @item[:placement_group_name] = @text
608
589
  when 'virtualizationType' then @item[:virtualization_type] = @text
609
- when 'clientToken' then @item[:client_token] = @text
590
+ when 'clientToken' then @item[:client_token] = @text
591
+ when 'sourceDestCheck' then @item[:source_dest_check] = @text == 'true' ? true : false
592
+ when 'tenancy' then @item[:placement_tenancy] = @text
593
+ when 'hypervisor' then @item[:hypervisor] = @text
610
594
  else
611
595
  case full_tag_name
596
+ # EC2 Groups
597
+ when %r{(RunInstancesResponse|/reservationSet/item)/groupSet/item/groupId$} then @group[:group_id] = @text
598
+ when %r{(RunInstancesResponse|/reservationSet/item)/groupSet/item/groupName$} then @group[:group_name] = @text
599
+ when %r{(RunInstancesResponse|/reservationSet/item)/groupSet/item$} then @reservation[:aws_groups] << @group
600
+ # VPC Groups
601
+ # KD: It seems that these groups are always present when the groups above present for non VPC instances only
602
+ when %r{/instancesSet/item/groupSet/item/groupId$} then @group[:group_id] = @text
603
+ when %r{/instancesSet/item/groupSet/item/groupName$} then @group[:group_name] = @text
604
+ when %r{/instancesSet/item/groupSet/item$} then @item[:groups] << @group
605
+ # Placement Group Name
606
+ when %r{/placement/groupName$} then @group[:placement_group_name]= @text
607
+ # Codes
612
608
  when %r{/stateReason/code$} then @item[:state_reason_code] = @text
613
609
  when %r{/stateReason/message$} then @item[:state_reason_message] = @text
614
610
  when %r{/instanceState/code$} then @item[:aws_state_code] = @text.to_i
@@ -629,9 +625,7 @@ module RightAws
629
625
  when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
630
626
  when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
631
627
  when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
632
- when 'DescribeInstancesResponse/reservationSet/item',
633
- 'RunInstancesResponse'
634
- @result << @reservation
628
+ when %r{(RunInstancesResponse|DescribeInstancesResponse/reservationSet/item)$} then @result << @reservation
635
629
  end
636
630
  end
637
631
  end
@@ -668,6 +662,8 @@ module RightAws
668
662
  class QEc2DescribeInstanceAttributeParser < RightAWSParser #:nodoc:
669
663
  def tagstart(name, attributes)
670
664
  case full_tag_name
665
+ when %r{groupSet$} then @result = []
666
+ when %r{groupSet/item$} then @group = {}
671
667
  when %r{blockDeviceMapping$} then @result = []
672
668
  when %r{blockDeviceMapping/item$} then @block_device_mapping = {}
673
669
  end
@@ -675,12 +671,19 @@ module RightAws
675
671
  def tagend(name)
676
672
  case full_tag_name
677
673
  when %r{/instanceType/value$} then @result = @text
678
- when %r{/kernel$} then @result = @text
679
- when %r{/ramdisk$} then @result = @text
680
- when %r{/userData$} then @result = @text
674
+ when %r{/kernel/value$} then @result = @text
675
+ when %r{/ramdisk/value$} then @result = @text
676
+ when %r{/userData/value$} then @result = @text
681
677
  when %r{/rootDeviceName/value$} then @result = @text
682
678
  when %r{/disableApiTermination/value} then @result = @text == 'true' ? true : false
683
679
  when %r{/instanceInitiatedShutdownBehavior/value$} then @result = @text
680
+ when %r{/sourceDestCheck/value$} then @result = @text == 'true' ? true : false
681
+ when %r{/groupSet/item} # no trailing $
682
+ case name
683
+ when 'groupId' then @group[:group_id] = @text
684
+ when 'groupName' then @group[:group_name] = @text
685
+ when 'item' then @result << @group
686
+ end
684
687
  when %r{/blockDeviceMapping/item} # no trailing $
685
688
  case name
686
689
  when 'deviceName' then @block_device_mapping[:device_name] = @text