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
@@ -0,0 +1,236 @@
1
+ #
2
+ # Copyright (c) 2008 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
+ module RightAws
24
+
25
+ class AcfInterface
26
+
27
+ def streaming_distribution_config_to_xml(config) # :nodoc:
28
+ distribution_config_to_xml(config, 'StreamingDistributionConfig')
29
+ end
30
+
31
+ #-----------------------------------------------------------------
32
+ # API Calls:
33
+ #-----------------------------------------------------------------
34
+
35
+ # List all streaming distributions.
36
+ # Returns an array of distributions or RightAws::AwsError exception.
37
+ #
38
+ # acf.list_streaming_distributions #=>
39
+ # [{:status=>"Deployed",
40
+ # :aws_id=>"E3CWE2Z9USOS6B",
41
+ # :enabled=>true,
42
+ # :domain_name=>"s2jz1ourvss1fj.cloudfront.net",
43
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
44
+ # :last_modified_time=>"2010-04-19T08:53:32.574Z",
45
+ # :comment=>"Woo-Hoo!",
46
+ # :cnames=>["stream.web.my-awesome-site.net"]},
47
+ # ...
48
+ # {:status=>"Deployed",
49
+ # :aws_id=>"E3NPQZY4LKAYQ8",
50
+ # :enabled=>true,
51
+ # :domain_name=>"sw9nrsq9pudk3.cloudfront.net",
52
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
53
+ # :last_modified_time=>"2010-04-19T08:59:09.600Z",
54
+ # :comment=>"Woo-Hoo!",
55
+ # :cnames=>["stream-6.web.my-awesome-site.net"]}]
56
+ #
57
+ def list_streaming_distributions
58
+ result = []
59
+ incrementally_list_streaming_distributions do |response|
60
+ result += response[:distributions]
61
+ true
62
+ end
63
+ result
64
+ end
65
+
66
+ # Incrementally list streaming distributions.
67
+ #
68
+ # Optional params: +:marker+ and +:max_items+.
69
+ #
70
+ # # get first streaming distribution
71
+ # incrementally_list_distributions(:max_items => 1) #=>
72
+ # {:marker=>"",
73
+ # :next_marker=>"E3CWE2Z9USOS6B",
74
+ # :distributions=>
75
+ # [{:status=>"Deployed",
76
+ # :cnames=>["stream.web.my-awesome-site.net"],
77
+ # :aws_id=>"E3CWE2Z9USOS6B",
78
+ # :enabled=>true,
79
+ # :last_modified_time=>"2010-04-19T08:53:32.574Z",
80
+ # :domain_name=>"s2jz1ourvss1fj.cloudfront.net",
81
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
82
+ # :comment=>"Woo-Hoo!"}],
83
+ # :max_items=>1,
84
+ # :is_truncated=>true}
85
+ #
86
+ # # get max 100 streaming distributions (the list will be restricted by a default MaxItems value ==100 )
87
+ # incrementally_list_streaming_distributions
88
+ #
89
+ # # list streaming distributions by 10
90
+ # incrementally_list_streaming_distributions(:max_items => 10) do |response|
91
+ # puts response.inspect # a list of 10 distributions
92
+ # true # return false if the listing should be broken otherwise use true
93
+ # end
94
+ #
95
+ def incrementally_list_streaming_distributions(params={}, &block)
96
+ opts = {}
97
+ opts['MaxItems'] = params[:max_items] if params[:max_items]
98
+ opts['Marker'] = params[:marker] if params[:marker]
99
+ last_response = nil
100
+ loop do
101
+ link = generate_request('GET', 'streaming-distribution', opts)
102
+ last_response = request_info(link, AcfDistributionListParser.new(:logger => @logger))
103
+ opts['Marker'] = last_response[:next_marker]
104
+ break unless block && block.call(last_response) && !last_response[:next_marker].blank?
105
+ end
106
+ last_response
107
+ end
108
+
109
+ # Create a new streaming distribution.
110
+ # Returns the just created distribution or RightAws::AwsError exception.
111
+ #
112
+ # acf.create_streaming_distribution('bucket-for-konstantin-00.s3.amazonaws.com', 'Woo-Hoo!', true,
113
+ # ['stream-1.web.my-awesome-site.net']) #=>
114
+ # {:status=>"InProgress",
115
+ # :caller_reference=>"201004191254412191173215",
116
+ # :cnames=>["stream-1.web.my-awesome-site.net"],
117
+ # :aws_id=>"E1M5LERJLU636F",
118
+ # :e_tag=>"E2588L5QL4BLXH",
119
+ # :enabled=>true,
120
+ # :domain_name=>"s1di8imd85wgld.cloudfront.net",
121
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
122
+ # :last_modified_time=>Mon Apr 19 08:54:42 UTC 2010,
123
+ # :location=>
124
+ # "https://cloudfront.amazonaws.com/streaming-distribution/E1M5LERJLU636F",
125
+ # :comment=>"Woo-Hoo!"}
126
+ #
127
+ def create_streaming_distribution(origin, comment='', enabled=true, cnames=[], caller_reference=nil)
128
+ config = { :origin => origin,
129
+ :comment => comment,
130
+ :enabled => enabled,
131
+ :cnames => Array(cnames),
132
+ :caller_reference => caller_reference }
133
+ create_streaming_distribution_by_config(config)
134
+ end
135
+
136
+ def create_streaming_distribution_by_config(config)
137
+ config[:caller_reference] ||= generate_call_reference
138
+ link = generate_request('POST', 'streaming-distribution', {}, streaming_distribution_config_to_xml(config))
139
+ merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
140
+ end
141
+
142
+ # Get a streaming distribution's information.
143
+ # Returns a distribution's information or RightAws::AwsError exception.
144
+ #
145
+ # acf.get_streaming_distribution('E3CWE2Z9USOS6B') #=>
146
+ # {:status=>"Deployed",
147
+ # :e_tag=>"EXTZ2SXAQT39K",
148
+ # :cnames=>["stream.web.my-awesome-site.net"],
149
+ # :aws_id=>"E3CWE2Z9USOS6B",
150
+ # :enabled=>true,
151
+ # :domain_name=>"s2jz1ourvss1fj.cloudfront.net",
152
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
153
+ # :last_modified_time=>"2010-04-19T08:53:32.574Z",
154
+ # :comment=>"Woo-Hoo!",
155
+ # :caller_reference=>"201004191253311625537161"}
156
+ #
157
+ # acf.get_streaming_distribution('E1M5LERJLU636F') #=>
158
+ # {:trusted_signers=>["self", "648772220000", "120288270000"],
159
+ # :status=>"InProgress",
160
+ # :e_tag=>"E2K6XD13RCJQ6E",
161
+ # :cnames=>["stream-1.web.my-awesome-site.net"],
162
+ # :active_trusted_signers=>
163
+ # [{:key_pair_ids=>["APKAIK74BJWCLXZUMEJA"],
164
+ # :aws_account_number=>"120288270000"},
165
+ # {:aws_account_number=>"self"},
166
+ # {:aws_account_number=>"648772220000"}],
167
+ # :aws_id=>"E1M5LERJLU636F",
168
+ # :enabled=>false,
169
+ # :domain_name=>"s1di8imd85wgld.cloudfront.net",
170
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
171
+ # :last_modified_time=>"2010-04-19T09:14:07.160Z",
172
+ # :comment=>"Olah-lah!",
173
+ # :origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
174
+ # :caller_reference=>"201004191254412191173215"}
175
+ #
176
+ def get_streaming_distribution(aws_id)
177
+ link = generate_request('GET', "streaming-distribution/#{aws_id}")
178
+ merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
179
+ end
180
+
181
+ # Get a streaming distribution's configuration.
182
+ # Returns a distribution's configuration or RightAws::AwsError exception.
183
+ #
184
+ # acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
185
+ # {:trusted_signers=>["self", "648772220000", "120288270000"],
186
+ # :e_tag=>"E2K6XD13RCJQ6E",
187
+ # :cnames=>["stream-1.web.my-awesome-site.net"],
188
+ # :enabled=>false,
189
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
190
+ # :comment=>"Olah-lah!",
191
+ # :origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
192
+ # :caller_reference=>"201004191254412191173215"}
193
+ #
194
+ def get_streaming_distribution_config(aws_id)
195
+ link = generate_request('GET', "streaming-distribution/#{aws_id}/config")
196
+ merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
197
+ end
198
+
199
+ # Set a streaming distribution's configuration
200
+ # (the :origin and the :caller_reference cannot be changed).
201
+ # Returns +true+ on success or RightAws::AwsError exception.
202
+ #
203
+ # acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
204
+ # {:e_tag=>"E2588L5QL4BLXH",
205
+ # :cnames=>["stream-1.web.my-awesome-site.net"],
206
+ # :enabled=>true,
207
+ # :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
208
+ # :comment=>"Woo-Hoo!",
209
+ # :caller_reference=>"201004191254412191173215"}
210
+ #
211
+ # config[:comment] = 'Olah-lah!'
212
+ # config[:enabled] = false
213
+ # config[:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
214
+ # config[:trusted_signers] = ['self', '648772220000', '120288270000']
215
+ #
216
+ # acf.set_distribution_config('E2REJM3VUN5RSI', config) #=> true
217
+ #
218
+ def set_streaming_distribution_config(aws_id, config)
219
+ link = generate_request('PUT', "streaming-distribution/#{aws_id}/config", {}, streaming_distribution_config_to_xml(config),
220
+ 'If-Match' => config[:e_tag])
221
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
222
+ end
223
+
224
+ # Delete a streaming distribution. The enabled distribution cannot be deleted.
225
+ # Returns +true+ on success or RightAws::AwsError exception.
226
+ #
227
+ # acf.delete_streaming_distribution('E1M5LERJLU636F', 'E2588L5QL4BLXH') #=> true
228
+ #
229
+ def delete_streaming_distribution(aws_id, e_tag)
230
+ link = generate_request('DELETE', "streaming-distribution/#{aws_id}", {}, nil,
231
+ 'If-Match' => e_tag)
232
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
233
+ end
234
+
235
+ end
236
+ end
@@ -144,7 +144,7 @@ module RightAws
144
144
  # Period (60 sec by default)
145
145
  period = (options[:period] && options[:period].to_i) || 60
146
146
  # Statistics ('Average' by default)
147
- statistics = options[:statistics].to_a.flatten
147
+ statistics = Array(options[:statistics]).flatten
148
148
  statistics = statistics.blank? ? ['Average'] : statistics.map{|statistic| statistic.to_s.capitalize }
149
149
  # Times (5.min.ago up to now by default)
150
150
  start_time = options[:start_time] || (Time.now.utc - 5*60)
@@ -167,7 +167,7 @@ module RightAws
167
167
  # dimentions
168
168
  dim = []
169
169
  dimentions.each do |key, values|
170
- values.to_a.each { |value| dim << [key, value] }
170
+ Array(values).each { |value| dim << [key, value] }
171
171
  end
172
172
  request_hash.merge!(amazonize_list(['Dimensions.member.?.Name', 'Dimensions.member.?.Value'], dim))
173
173
  #
@@ -199,7 +199,7 @@ module RightAws
199
199
  end
200
200
  def tagend(name)
201
201
  case name
202
- when 'Timestamp' then @item[:timestamp] = Time.parse(@text)
202
+ when 'Timestamp' then @item[:timestamp] = @text
203
203
  when 'Unit' then @item[:unit] = @text
204
204
  when 'CustomUnit' then @item[:custom_unit] = @text
205
205
  when 'Samples' then @item[:samples] = @text.to_f
@@ -51,7 +51,7 @@ module RightAws
51
51
  # as.create_or_update_scaling_trigger('kd.tr.1', 'CentOS.5.1-c-array',
52
52
  # :measure_name => 'CPUUtilization',
53
53
  # :statistic => :average,
54
- # :dimentions => {
54
+ # :dimensions => {
55
55
  # 'AutoScalingGroupName' => 'CentOS.5.1-c-array',
56
56
  # 'Namespace' => 'AWS',
57
57
  # 'Service' => 'EC2' },
@@ -153,8 +153,8 @@ module RightAws
153
153
  options[:min_size] ||= 1
154
154
  options[:max_size] ||= 20
155
155
  options[:cooldown] ||= 0
156
- request_hash = amazonize_list('AvailabilityZones.member', availability_zones.to_a)
157
- request_hash.merge!( amazonize_list('LoadBalancerNames', options[:load_balancer_names].to_a) )
156
+ request_hash = amazonize_list('AvailabilityZones.member', availability_zones)
157
+ request_hash.merge!( amazonize_list('LoadBalancerNames', options[:load_balancer_names]) )
158
158
  request_hash.merge!( 'AutoScalingGroupName' => auto_scaling_group_name,
159
159
  'LaunchConfigurationName' => launch_configuration_name,
160
160
  'MinSize' => options[:min_size],
@@ -204,7 +204,7 @@ module RightAws
204
204
  # as.update_auto_scaling_group('CentOS.5.1-c', :min_size => 1, :max_size => 4) #=> true
205
205
  #
206
206
  def update_auto_scaling_group(auto_scaling_group_name, options={})
207
- request_hash = amazonize_list('AvailabilityZones.member', options[:availability_zones].to_a)
207
+ request_hash = amazonize_list('AvailabilityZones.member', options[:availability_zones])
208
208
  request_hash['AutoScalingGroupName'] = auto_scaling_group_name
209
209
  request_hash['LaunchConfigurationName'] = options[:launch_configuration_name] if options[:launch_configuration_name]
210
210
  request_hash['MinSize'] = options[:min_size] if options[:min_size]
@@ -339,21 +339,26 @@ module RightAws
339
339
  # Options: +:security_groups+, +:block_device_mappings+, +:key_name+,
340
340
  # +:user_data+, +:kernel_id+, +:ramdisk_id+
341
341
  #
342
- # as.create_launch_configuration('CentOS.5.1-c', 'ami-08f41161', 'm1.small',
343
- # :key_name => 'kd-moo-test',
344
- # :security_groups => ['default'],
345
- # :user_data => "Woohoo: CentOS.5.1-c" ) #=> true
342
+ # as.create_launch_configuration('kd: CentOS.5.1-c.1', 'ami-08f41161', 'c1.medium',
343
+ # :key_name => 'tim',
344
+ # :security_groups => ['default'],
345
+ # :user_data => "Woohoo: CentOS.5.1-c",
346
+ # :block_device_mappings => [ { :device_name => '/dev/sdk',
347
+ # :ebs_snapshot_id => 'snap-145cbc7d',
348
+ # :ebs_delete_on_termination => true,
349
+ # :ebs_volume_size => 3,
350
+ # :virtual_name => 'ephemeral2'
351
+ # } ]
352
+ # ) #=> true
346
353
  #
347
354
  def create_launch_configuration(launch_configuration_name, image_id, instance_type, options={})
348
- availability_zones = availability_zones.to_a
349
355
  request_hash = { 'LaunchConfigurationName' => launch_configuration_name,
350
356
  'ImageId' => image_id,
351
357
  'InstanceType' => instance_type }
352
358
  request_hash.merge!(amazonize_list('SecurityGroups.member', options[:security_groups])) unless options[:security_groups].blank?
353
- request_hash.merge!(amazonize_list(['BlockDeviceMappings.member.?.DeviceName', 'BlockDeviceMappings.member.?.VirtualName'],
354
- options[:block_device_mappings].to_a)) unless options[:block_device_mappings].blank?
359
+ request_hash.merge!(amazonize_block_device_mappings(options[:block_device_mappings], 'BlockDeviceMappings.member'))
355
360
  request_hash['KeyName'] = options[:key_name] if options[:key_name]
356
- request_hash['UserData'] = options[:user_data] if options[:user_data]
361
+ request_hash['UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].blank? if options[:user_data]
357
362
  request_hash['KernelId'] = options[:kernel_id] if options[:kernel_id]
358
363
  request_hash['RamdiskId'] = options[:ramdisk_id] if options[:ramdisk_id]
359
364
  link = generate_request("CreateLaunchConfiguration", request_hash)
@@ -365,16 +370,17 @@ module RightAws
365
370
  # Returns an array of configurations.
366
371
  #
367
372
  # as.describe_launch_configurations #=>
368
- # [{:created_time=>Thu May 28 09:31:20 UTC 2009,
369
- # :kernel_id=>"",
370
- # :launch_configuration_name=>"CentOS.5.1-c",
373
+ # [{:security_groups=>["default"],
371
374
  # :ramdisk_id=>"",
372
- # :security_groups=>["default"],
373
- # :key_name=>"kd-moo-test",
374
- # :user_data=>"Woohoo: CentOS.5.1-c-array",
375
+ # :user_data=>"V29vaG9vOiBDZW50T1MuNS4xLWM=",
376
+ # :instance_type=>"c1.medium",
377
+ # :block_device_mappings=>
378
+ # [{:virtual_name=>"ephemeral2", :device_name=>"/dev/sdk"}],
379
+ # :launch_configuration_name=>"kd: CentOS.5.1-c.1",
380
+ # :created_time=>"2010-03-29T10:00:32.742Z",
375
381
  # :image_id=>"ami-08f41161",
376
- # :block_device_mappings=>[],
377
- # :instance_type=>"m1.small"}, ... ]
382
+ # :key_name=>"tim",
383
+ # :kernel_id=>""}, ...]
378
384
  #
379
385
  def describe_launch_configurations(*launch_configuration_names)
380
386
  result = []
@@ -449,12 +455,12 @@ module RightAws
449
455
  # Returns +true+ or an exception.
450
456
  #
451
457
  # Options: +:measure_name+, +:statistic+, +:period+, +:lower_threshold+, +:lower_breach_scale_increment+,
452
- # +:upper_threshold+, +:upper_breach_scale_increment+, +:dimentions+, +:breach_duration+, +:unit+, +:custom_unit+
458
+ # +:upper_threshold+, +:upper_breach_scale_increment+, +:dimensions+, +:breach_duration+, +:unit+, +:custom_unit+
453
459
  #
454
460
  # as.create_or_update_scaling_trigger('kd.tr.1', 'CentOS.5.1-c-array',
455
461
  # :measure_name => 'CPUUtilization',
456
462
  # :statistic => :average,
457
- # :dimentions => {
463
+ # :dimensions => {
458
464
  # 'AutoScalingGroupName' => 'CentOS.5.1-c-array',
459
465
  # 'Namespace' => 'AWS',
460
466
  # 'Service' => 'EC2' },
@@ -478,11 +484,11 @@ module RightAws
478
484
  'BreachDuration' => options[:breach_duration] }
479
485
  request_hash['Unit'] = options[:unit] if options[:unit]
480
486
  request_hash['CustomUnit'] = options[:custom_unit] if options[:custom_unit]
481
- dimentions = []
482
- (options[:dimentions] || {}).each do |key, values|
483
- values.to_a.each { |value| dimentions << [key, value] }
487
+ dimensions = []
488
+ (options[:dimensions] || {}).each do |key, values|
489
+ Array(values).each { |value| dimensions << [key, value] }
484
490
  end
485
- request_hash.merge!(amazonize_list(['Dimensions.member.?.Name', 'Dimensions.member.?.Value'], dimentions))
491
+ request_hash.merge!(amazonize_list(['Dimensions.member.?.Name', 'Dimensions.member.?.Value'], dimensions))
486
492
  link = generate_request("CreateOrUpdateScalingTrigger", request_hash)
487
493
  request_info(link, RightHttp2xxParser.new(:logger => @logger))
488
494
  end
@@ -537,8 +543,8 @@ module RightAws
537
543
  def tagend(name)
538
544
  case name
539
545
  when 'ActivityId' then @item[:activity_id] = @text
540
- when 'StartTime' then @item[:start_time] = Time::parse(@text)
541
- when 'EndTime' then @item[:end_time] = Time::parse(@text)
546
+ when 'StartTime' then @item[:start_time] = @text
547
+ when 'EndTime' then @item[:end_time] = @text
542
548
  when 'Progress' then @item[:progress] = @text.to_i
543
549
  when 'StatusCode' then @item[:status_code] = @text
544
550
  when 'Cause' then @item[:cause] = @text
@@ -570,7 +576,7 @@ module RightAws
570
576
  end
571
577
  def tagend(name)
572
578
  case name
573
- when 'CreatedTime' then @item[:created_time] = Time::parse(@text)
579
+ when 'CreatedTime' then @item[:created_time] = @text
574
580
  when 'MinSize' then @item[:min_size] = @text.to_i
575
581
  when 'MaxSize' then @item[:max_size] = @text.to_i
576
582
  when 'DesiredCapacity' then @item[:desired_capacity] = @text.to_i
@@ -603,18 +609,17 @@ module RightAws
603
609
 
604
610
  class DescribeLaunchConfigurationsParser < RightAWSParser #:nodoc:
605
611
  def tagstart(name, attributes)
606
- case name
607
- when 'member'
608
- case @xmlpath
609
- when @p
610
- @item = { :block_device_mappings => [],
611
- :security_groups => [] }
612
- end
612
+ case full_tag_name
613
+ when %r{/LaunchConfigurations/member$}
614
+ @item = { :block_device_mappings => [],
615
+ :security_groups => [] }
616
+ when %r{/BlockDeviceMappings/member$}
617
+ @block_device_mapping = {}
613
618
  end
614
619
  end
615
620
  def tagend(name)
616
621
  case name
617
- when 'CreatedTime' then @item[:created_time] = Time::parse(@text)
622
+ when 'CreatedTime' then @item[:created_time] = @text
618
623
  when 'InstanceType' then @item[:instance_type] = @text
619
624
  when 'KeyName' then @item[:key_name] = @text
620
625
  when 'ImageId' then @item[:image_id] = @text
@@ -622,20 +627,24 @@ module RightAws
622
627
  when 'RamdiskId' then @item[:ramdisk_id] = @text
623
628
  when 'LaunchConfigurationName' then @item[:launch_configuration_name] = @text
624
629
  when 'UserData' then @item[:user_data] = @text
625
- when 'member'
626
- case @xmlpath
627
- when "#@p/member/BlockDeviceMappings" then @item[:block_device_mappings] << @text
628
- when "#@p/member/SecurityGroups" then @item[:security_groups] << @text
629
- when @p
630
- @item[:block_device_mappings].sort!
630
+ when 'NextToken' then @result[:next_token] = @text
631
+ else
632
+ case full_tag_name
633
+ when %r{/BlockDeviceMappings/member} # no trailing $
634
+ case name
635
+ when 'DeviceName' then @block_device_mapping[:device_name] = @text
636
+ when 'VirtualName' then @block_device_mapping[:virtual_name] = @text
637
+ when 'member' then @item[:block_device_mappings] << @block_device_mapping
638
+ end
639
+ when %r{member/SecurityGroups/member$}
640
+ @item[:security_groups] << @text
641
+ when %r{/LaunchConfigurations/member$}
631
642
  @item[:security_groups].sort!
632
643
  @result[:launch_configurations] << @item
633
644
  end
634
- when 'NextToken' then @result[:next_token] = @text
635
645
  end
636
646
  end
637
647
  def reset
638
- @p = 'DescribeLaunchConfigurationsResponse/DescribeLaunchConfigurationsResult/LaunchConfigurations'
639
648
  @result = { :launch_configurations => []}
640
649
  end
641
650
  end
@@ -660,7 +669,7 @@ module RightAws
660
669
  case name
661
670
  when 'AutoScalingGroupName' then @item[:auto_scaling_group_name] = @text
662
671
  when 'MeasureName' then @item[:measure_name] = @text
663
- when 'CreatedTime' then @item[:created_time] = Time::parse(@text)
672
+ when 'CreatedTime' then @item[:created_time] = @text
664
673
  when 'BreachDuration' then @item[:breach_duration] = @text.to_i
665
674
  when 'UpperBreachScaleIncrement' then @item[:upper_breach_scale_increment] = @text.to_i
666
675
  when 'UpperThreshold' then @item[:upper_threshold] = @text.to_f