revans_right_aws 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.gemtest +0 -0
  2. data/History.txt +284 -0
  3. data/Manifest.txt +50 -0
  4. data/README.txt +167 -0
  5. data/Rakefile +110 -0
  6. data/lib/acf/right_acf_interface.rb +485 -0
  7. data/lib/acf/right_acf_origin_access_identities.rb +230 -0
  8. data/lib/acf/right_acf_streaming_interface.rb +236 -0
  9. data/lib/acw/right_acw_interface.rb +249 -0
  10. data/lib/as/right_as_interface.rb +699 -0
  11. data/lib/awsbase/benchmark_fix.rb +39 -0
  12. data/lib/awsbase/right_awsbase.rb +978 -0
  13. data/lib/awsbase/support.rb +115 -0
  14. data/lib/ec2/right_ec2.rb +395 -0
  15. data/lib/ec2/right_ec2_ebs.rb +452 -0
  16. data/lib/ec2/right_ec2_images.rb +373 -0
  17. data/lib/ec2/right_ec2_instances.rb +755 -0
  18. data/lib/ec2/right_ec2_monitoring.rb +70 -0
  19. data/lib/ec2/right_ec2_reserved_instances.rb +170 -0
  20. data/lib/ec2/right_ec2_security_groups.rb +277 -0
  21. data/lib/ec2/right_ec2_spot_instances.rb +399 -0
  22. data/lib/ec2/right_ec2_vpc.rb +571 -0
  23. data/lib/elb/right_elb_interface.rb +496 -0
  24. data/lib/rds/right_rds_interface.rb +998 -0
  25. data/lib/right_aws.rb +83 -0
  26. data/lib/s3/right_s3.rb +1126 -0
  27. data/lib/s3/right_s3_interface.rb +1199 -0
  28. data/lib/sdb/active_sdb.rb +1122 -0
  29. data/lib/sdb/right_sdb_interface.rb +721 -0
  30. data/lib/sqs/right_sqs.rb +388 -0
  31. data/lib/sqs/right_sqs_gen2.rb +343 -0
  32. data/lib/sqs/right_sqs_gen2_interface.rb +524 -0
  33. data/lib/sqs/right_sqs_interface.rb +594 -0
  34. data/test/acf/test_helper.rb +2 -0
  35. data/test/acf/test_right_acf.rb +138 -0
  36. data/test/ec2/test_helper.rb +2 -0
  37. data/test/ec2/test_right_ec2.rb +108 -0
  38. data/test/http_connection.rb +87 -0
  39. data/test/rds/test_helper.rb +2 -0
  40. data/test/rds/test_right_rds.rb +120 -0
  41. data/test/s3/test_helper.rb +2 -0
  42. data/test/s3/test_right_s3.rb +421 -0
  43. data/test/s3/test_right_s3_stubbed.rb +97 -0
  44. data/test/sdb/test_active_sdb.rb +357 -0
  45. data/test/sdb/test_helper.rb +3 -0
  46. data/test/sdb/test_right_sdb.rb +253 -0
  47. data/test/sqs/test_helper.rb +2 -0
  48. data/test/sqs/test_right_sqs.rb +291 -0
  49. data/test/sqs/test_right_sqs_gen2.rb +264 -0
  50. data/test/test_credentials.rb +37 -0
  51. data/test/ts_right_aws.rb +14 -0
  52. metadata +169 -0
@@ -0,0 +1,496 @@
1
+ #
2
+ # Copyright (c) 2007-2009 RightScale Inc
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module RightAws
25
+
26
+ # = RightAWS::ElbInterface -- RightScale Amazon Elastic Load Balancer interface
27
+ # The RightAws::ElbInterface class provides a complete interface to Amazon's
28
+ # Elastic Load Balancer service.
29
+ #
30
+ # For explanations of the semantics of each call, please refer to Amazon's documentation at
31
+ # http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/
32
+ #
33
+ # Create an interface handle:
34
+ #
35
+ # elb = RightAws::ElbInterface.new(aws_access_key_id, aws_security_access_key)
36
+ #
37
+ # Create an new load balancer:
38
+ #
39
+ # elb.create_load_balancer( 'test-kd1',
40
+ # ['us-east-1a', 'us-east-1b'],
41
+ # [ { :protocol => :http, :load_balancer_port => 80, :instance_port => 80 },
42
+ # { :protocol => :tcp, :load_balancer_port => 443, :instance_port => 443 } ])
43
+ #
44
+ # Configure its health checking:
45
+ #
46
+ # elb.configure_health_check( 'test-kd1',
47
+ # { :healthy_threshold => 9,
48
+ # :unhealthy_threshold => 3,
49
+ # :target => "TCP:433",
50
+ # :timeout => 6,
51
+ # :interval => 31}
52
+ #
53
+ # Register instances with the balancer:
54
+ #
55
+ # elb.register_instances_with_load_balancer('test-kd1', 'i-8b8bcbe2', 'i-bf8bcbd6') #=> ["i-8b8bcbe2", "i-bf8bcbd6"]
56
+ #
57
+ # Add new availability zones:
58
+ #
59
+ # elb.enable_availability_zones_for_load_balancer("test-kd1", "us-east-1c")
60
+ #
61
+ class ElbInterface < RightAwsBase
62
+ include RightAwsBaseInterface
63
+
64
+ # Amazon ELB API version being used
65
+ API_VERSION = "2009-11-25"
66
+ DEFAULT_HOST = "elasticloadbalancing.amazonaws.com"
67
+ DEFAULT_PATH = '/'
68
+ DEFAULT_PROTOCOL = 'https'
69
+ DEFAULT_PORT = 443
70
+
71
+ @@bench = AwsBenchmarkingBlock.new
72
+ def self.bench_xml
73
+ @@bench.xml
74
+ end
75
+ def self.bench_service
76
+ @@bench.service
77
+ end
78
+
79
+ # Create a new handle to an ELB account. All handles share the same per process or per thread
80
+ # HTTP connection to Amazon ELB. Each handle is for a specific account. The params have the
81
+ # following options:
82
+ # * <tt>:endpoint_url</tt> a fully qualified url to Amazon API endpoint (this overwrites: :server, :port, :service, :protocol). Example: 'https://elasticloadbalancing.amazonaws.com'
83
+ # * <tt>:server</tt>: ELB service host, default: DEFAULT_HOST
84
+ # * <tt>:port</tt>: ELB service port, default: DEFAULT_PORT
85
+ # * <tt>:protocol</tt>: 'http' or 'https', default: DEFAULT_PROTOCOL
86
+ # * <tt>:multi_thread</tt>: true=HTTP connection per thread, false=per process
87
+ # * <tt>:logger</tt>: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT
88
+ # * <tt>:signature_version</tt>: The signature version : '0','1' or '2'(default)
89
+ # * <tt>:cache</tt>: true/false(default): caching works for: describe_load_balancers
90
+ #
91
+ def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
92
+ init({ :name => 'ELB',
93
+ :default_host => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).host : DEFAULT_HOST,
94
+ :default_port => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).port : DEFAULT_PORT,
95
+ :default_service => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).path : DEFAULT_PATH,
96
+ :default_protocol => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).scheme : DEFAULT_PROTOCOL,
97
+ :default_api_version => ENV['ELB_API_VERSION'] || API_VERSION },
98
+ aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] ,
99
+ aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
100
+ params)
101
+ end
102
+
103
+ def generate_request(action, params={}) #:nodoc:
104
+ generate_request_impl(:get, action, params )
105
+ end
106
+
107
+ # Sends request to Amazon and parses the response
108
+ # Raises AwsError if any banana happened
109
+ def request_info(request, parser) #:nodoc:
110
+ request_info_impl(:lbs_connection, @@bench, request, parser)
111
+ end
112
+
113
+ #-----------------------------------------------------------------
114
+ # Load Balancers
115
+ #-----------------------------------------------------------------
116
+ # Describe load balancers.
117
+ # Returns an array of load balancers.
118
+ #
119
+ # elb.describe_load_balancers #=>
120
+ # [ { :health_check =>
121
+ # { :healthy_threshold => 10,
122
+ # :unhealthy_threshold => 2,
123
+ # :target => "TCP:80",
124
+ # :timeout => 5,
125
+ # :interval => 30},
126
+ # :load_balancer_name => "test-kd1",
127
+ # :availability_zones => ["us-east-1a", "us-east-1b"],
128
+ # :listeners =>
129
+ # [ { :protocol => "HTTP", :load_balancer_port => "80", :instance_port => "80" },
130
+ # { :protocol => "TCP", :load_balancer_port => "443", :instance_port => "443" } ],
131
+ # :created_time => "2009-05-27T11:59:11.000Z",
132
+ # :dns_name => "test-kd1-1519253964.us-east-1.elb.amazonaws.com",
133
+ # :instances => [] } ]
134
+ #
135
+ # elb.describe_load_balancers("test-kd1") #=>
136
+ # [{:load_balancer_name=>"test-kd1",
137
+ # :instances=>["i-9fc056f4", "i-b3debfd8"],
138
+ # :health_check=>
139
+ # {:interval=>30,
140
+ # :healthy_threshold=>10,
141
+ # :target=>"TCP:80",
142
+ # :unhealthy_threshold=>2,
143
+ # :timeout=>5},
144
+ # :dns_name=>"test-kd1-869291821.us-east-1.elb.amazonaws.com",
145
+ # :listeners=>
146
+ # [{:load_balancer_port=>"80",
147
+ # :policy_names=>["my-policy-1"],
148
+ # :instance_port=>"80",
149
+ # :protocol=>"HTTP"},
150
+ # {:load_balancer_port=>"8080",
151
+ # :policy_names=>["my-policy-lb-1"],
152
+ # :instance_port=>"8080",
153
+ # :protocol=>"HTTP"},
154
+ # {:load_balancer_port=>"443",
155
+ # :policy_names=>[],
156
+ # :instance_port=>"443",
157
+ # :protocol=>"TCP"}],
158
+ # :created_time=>"2010-04-15T12:04:49.000Z",
159
+ # :availability_zones=>["us-east-1a", "us-east-1b"],
160
+ # :app_cookie_stickiness_policies=>
161
+ # [{:policy_name=>"my-policy-1", :cookie_name=>"my-cookie-1"}],
162
+ # :lb_cookie_stickiness_policies=>
163
+ # [{:cookie_expiration_period=>60, :policy_name=>"my-policy-lb-1"}]}]
164
+ #
165
+ def describe_load_balancers(*load_balancers)
166
+ load_balancers = load_balancers.flatten.compact
167
+ request_hash = amazonize_list("LoadBalancerNames.member", load_balancers)
168
+ link = generate_request("DescribeLoadBalancers", request_hash)
169
+ request_cache_or_info(:describe_load_balancers, link, DescribeLoadBalancersParser, @@bench, load_balancers.blank?)
170
+ end
171
+
172
+ # Create new load balancer.
173
+ # Returns a new load balancer DNS name.
174
+ #
175
+ # lb = elb.create_load_balancer( 'test-kd1',
176
+ # ['us-east-1a', 'us-east-1b'],
177
+ # [ { :protocol => :http, :load_balancer_port => 80, :instance_port => 80 },
178
+ # { :protocol => :tcp, :load_balancer_port => 443, :instance_port => 443 } ])
179
+ # puts lb #=> "test-kd1-1519253964.us-east-1.elb.amazonaws.com"
180
+ #
181
+ def create_load_balancer(load_balancer_name, availability_zones=[], listeners=[])
182
+ request_hash = { 'LoadBalancerName' => load_balancer_name }
183
+ # merge zones
184
+ request_hash.merge!( amazonize_list("AvailabilityZones.member", availability_zones) )
185
+ # merge listeners
186
+ if listeners.blank?
187
+ listeners = { :protocol => :http,
188
+ :load_balancer_port => 80,
189
+ :instance_port => 80 }
190
+ end
191
+ listeners = [listeners] unless listeners.is_a?(Array)
192
+ request_hash.merge!( amazonize_list( ['Listeners.member.?.Protocol',
193
+ 'Listeners.member.?.LoadBalancerPort',
194
+ 'Listeners.member.?.InstancePort'],
195
+ listeners.map{|i| [ (i[:protocol] || 'HTTP').to_s.upcase,
196
+ (i[:load_balancer_port] || 80),
197
+ (i[:instance_port] || 80) ] } ) )
198
+ link = generate_request("CreateLoadBalancer", request_hash)
199
+ request_info(link, CreateLoadBalancerParser.new(:logger => @logger))
200
+ end
201
+
202
+ # Delete load balancer.
203
+ # Returns +true+ on success.
204
+ #
205
+ # elb.delete_load_balancer('test-kd1') #=> true
206
+ #
207
+ # Amazon: Because this API has been designed to be idempotent, even if the LoadBalancer does not exist or
208
+ # has been deleted, DeleteLoadBalancer still returns a success.
209
+ #
210
+ def delete_load_balancer(load_balancer_name)
211
+ link = generate_request("DeleteLoadBalancer", 'LoadBalancerName' => load_balancer_name)
212
+ request_info(link, DeleteLoadBalancerParser.new(:logger => @logger))
213
+ end
214
+
215
+ # Add one or more zones to a load balancer.
216
+ # Returns a list of updated availability zones for the load balancer.
217
+ #
218
+ # elb.enable_availability_zones_for_load_balancer("test-kd1", "us-east-1c") #=> ["us-east-1a", "us-east-1c"]
219
+ #
220
+ def enable_availability_zones_for_load_balancer(load_balancer_name, *availability_zones)
221
+ availability_zones.flatten!
222
+ request_hash = amazonize_list("AvailabilityZones.member", availability_zones)
223
+ request_hash.merge!( 'LoadBalancerName' => load_balancer_name )
224
+ link = generate_request("EnableAvailabilityZonesForLoadBalancer", request_hash)
225
+ request_info(link, AvailabilityZonesForLoadBalancerParser.new(:logger => @logger))
226
+ end
227
+
228
+ # Remove one or more zones from a load balancer.
229
+ # Returns a list of updated availability zones for the load balancer.
230
+ #
231
+ # elb.disable_availability_zones_for_load_balancer("test-kd1", "us-east-1c") #=> ["us-east-1a"]
232
+ #
233
+ def disable_availability_zones_for_load_balancer(load_balancer_name, *availability_zones)
234
+ availability_zones.flatten!
235
+ request_hash = amazonize_list("AvailabilityZones.member", availability_zones)
236
+ request_hash.merge!( 'LoadBalancerName' => load_balancer_name )
237
+ link = generate_request("DisableAvailabilityZonesForLoadBalancer", request_hash)
238
+ request_info(link, AvailabilityZonesForLoadBalancerParser.new(:logger => @logger))
239
+ end
240
+
241
+ # Define an application healthcheck for the instances.
242
+ # Returns an updated health check configuration for the load balancer.
243
+ #
244
+ # hc = elb.configure_health_check( 'test-kd1',
245
+ # { :healthy_threshold => 9,
246
+ # :unhealthy_threshold => 3,
247
+ # :target => "TCP:433",
248
+ # :timeout => 6,
249
+ # :interval => 31}
250
+ # pp hc #=> { :target=>"TCP:433", :timeout=>6, :interval=>31, :healthy_threshold=>9, :unhealthy_threshold=>3 }
251
+ #
252
+ def configure_health_check(load_balancer_name, health_check)
253
+ request_hash = { 'LoadBalancerName' => load_balancer_name }
254
+ health_check.each{ |key, value| request_hash["HealthCheck.#{key.to_s.camelize}"] = value }
255
+ link = generate_request("ConfigureHealthCheck", request_hash)
256
+ request_info(link, HealthCheckParser.new(:logger => @logger))
257
+ end
258
+
259
+ #-----------------------------------------------------------------
260
+ # Instances
261
+ #-----------------------------------------------------------------
262
+
263
+ # Describe the current state of the instances of the specified load balancer.
264
+ # Returns a list of the instances.
265
+ #
266
+ # elb.describe_instance_health('test-kd1', 'i-8b8bcbe2', 'i-bf8bcbd6') #=>
267
+ # [ { :description => "Instance registration is still in progress",
268
+ # :reason_code => "ELB",
269
+ # :instance_id => "i-8b8bcbe2",
270
+ # :state => "OutOfService" },
271
+ # { :description => "Instance has failed at least the UnhealthyThreshold number of health checks consecutively.",
272
+ # :reason_code => "Instance",
273
+ # :instance_id => "i-bf8bcbd6",
274
+ # :state => "OutOfService" } ]
275
+ #
276
+ def describe_instance_health(load_balancer_name, *instances)
277
+ instances.flatten!
278
+ request_hash = amazonize_list("Instances.member.?.InstanceId", instances)
279
+ request_hash.merge!( 'LoadBalancerName' => load_balancer_name )
280
+ link = generate_request("DescribeInstanceHealth", request_hash)
281
+ request_info(link, DescribeInstanceHealthParser.new(:logger => @logger))
282
+ end
283
+
284
+ # Add new instance(s) to the load balancer.
285
+ # Returns an updated list of instances for the load balancer.
286
+ #
287
+ # elb.register_instances_with_load_balancer('test-kd1', 'i-8b8bcbe2', 'i-bf8bcbd6') #=> ["i-8b8bcbe2", "i-bf8bcbd6"]
288
+ #
289
+ def register_instances_with_load_balancer(load_balancer_name, *instances)
290
+ instances.flatten!
291
+ request_hash = amazonize_list("Instances.member.?.InstanceId", instances)
292
+ request_hash.merge!( 'LoadBalancerName' => load_balancer_name )
293
+ link = generate_request("RegisterInstancesWithLoadBalancer", request_hash)
294
+ request_info(link, InstancesWithLoadBalancerParser.new(:logger => @logger))
295
+ end
296
+
297
+ # Remove instance(s) from the load balancer.
298
+ # Returns an updated list of instances for the load balancer.
299
+ #
300
+ # elb.deregister_instances_with_load_balancer('test-kd1', 'i-8b8bcbe2') #=> ["i-bf8bcbd6"]
301
+ #
302
+ def deregister_instances_with_load_balancer(load_balancer_name, *instances)
303
+ instances.flatten!
304
+ request_hash = amazonize_list("Instances.member.?.InstanceId", instances)
305
+ request_hash.merge!( 'LoadBalancerName' => load_balancer_name )
306
+ link = generate_request("DeregisterInstancesFromLoadBalancer", request_hash)
307
+ request_info(link, InstancesWithLoadBalancerParser.new(:logger => @logger))
308
+ end
309
+
310
+ #-----------------------------------------------------------------
311
+ # Cookies
312
+ #-----------------------------------------------------------------
313
+
314
+ # Generates a stickiness policy with sticky session lifetimes that follow
315
+ # that of an application-generated cookie.
316
+ # This policy can only be associated with HTTP listeners.
317
+ #
318
+ # elb.create_app_cookie_stickiness_policy('my-load-balancer', 'MyLoadBalancerPolicy', 'MyCookie') #=> true
319
+ #
320
+ def create_app_cookie_stickiness_policy(load_balancer_name, policy_name, cookie_name)
321
+ request_hash = { 'LoadBalancerName' => load_balancer_name,
322
+ 'PolicyName' => policy_name,
323
+ 'CookieName' => cookie_name }
324
+ link = generate_request("CreateAppCookieStickinessPolicy", request_hash)
325
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
326
+ end
327
+
328
+ # Generates a stickiness policy with sticky session lifetimes controlled by the
329
+ # lifetime of the browser (user-agent) or a specified expiration period.
330
+ # This policy can only be associated only with HTTP listeners.
331
+ #
332
+ # elb.create_lb_cookie_stickiness_policy('my-load-balancer', 'MyLoadBalancerPolicy', 60) #=> true
333
+ #
334
+ def create_lb_cookie_stickiness_policy(load_balancer_name, policy_name, cookie_expiration_period)
335
+ request_hash = { 'LoadBalancerName' => load_balancer_name,
336
+ 'PolicyName' => policy_name,
337
+ 'CookieExpirationPeriod' => cookie_expiration_period }
338
+ link = generate_request("CreateLBCookieStickinessPolicy", request_hash)
339
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
340
+ end
341
+
342
+ # Associates, updates, or disables a policy with a listener on the load balancer.
343
+ # Only zero(0) or one(1) policy can be associated with a listener.
344
+ #
345
+ # elb.set_load_balancer_policies_of_listener('my-load-balancer', 80, 'MyLoadBalancerPolicy') #=> true
346
+ #
347
+ def set_load_balancer_policies_of_listener(load_balancer_name, load_balancer_port, *policy_names)
348
+ policy_names.flatten!
349
+ request_hash = { 'LoadBalancerName' => load_balancer_name,
350
+ 'LoadBalancerPort' => load_balancer_port }
351
+ request_hash.merge!(amazonize_list('PolicyNames.member', policy_names))
352
+ link = generate_request("SetLoadBalancerPoliciesOfListener", request_hash)
353
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
354
+ end
355
+
356
+ #-----------------------------------------------------------------
357
+ # PARSERS: Load Balancers
358
+ #-----------------------------------------------------------------
359
+
360
+ class DescribeLoadBalancersParser < RightAWSParser #:nodoc:
361
+ def tagstart(name, attributes)
362
+ case full_tag_name
363
+ when %r{LoadBalancerDescriptions/member$}
364
+ @item = { :availability_zones => [],
365
+ :health_check => {},
366
+ :listeners => [],
367
+ :instances => [],
368
+ :app_cookie_stickiness_policies => [],
369
+ :lb_cookie_stickiness_policies => []}
370
+ when %r{ListenerDescriptions/member$} then @listener = {:policy_names => []}
371
+ when %r{AppCookieStickinessPolicies/member$} then @app_cookie_stickiness_policy = {}
372
+ when %r{LBCookieStickinessPolicies/member$} then @lb_cookie_stickiness_policy = {}
373
+ end
374
+ end
375
+ def tagend(name)
376
+ case name
377
+ when 'LoadBalancerName' then @item[:load_balancer_name] = @text
378
+ when 'DNSName' then @item[:dns_name] = @text
379
+ when 'CreatedTime' then @item[:created_time] = @text
380
+ when 'Interval' then @item[:health_check][:interval] = @text.to_i
381
+ when 'Target' then @item[:health_check][:target] = @text
382
+ when 'HealthyThreshold' then @item[:health_check][:healthy_threshold] = @text.to_i
383
+ when 'Timeout' then @item[:health_check][:timeout] = @text.to_i
384
+ when 'UnhealthyThreshold' then @item[:health_check][:unhealthy_threshold] = @text.to_i
385
+ when 'Protocol' then @listener[:protocol] = @text
386
+ when 'LoadBalancerPort' then @listener[:load_balancer_port] = @text
387
+ when 'InstancePort' then @listener[:instance_port] = @text
388
+ end
389
+ case full_tag_name
390
+ when %r{AvailabilityZones/member$} then @item[:availability_zones] << @text
391
+ when %r{Instances/member/InstanceId$} then @item[:instances] << @text
392
+ when %r{ListenerDescriptions/member$} then @item[:listeners] << @listener
393
+ when %r{ListenerDescriptions/member/PolicyNames/member$} then @listener[:policy_names] << @text
394
+ when %r{AppCookieStickinessPolicies/member}
395
+ case name
396
+ when 'PolicyName' then @app_cookie_stickiness_policy[:policy_name] = @text
397
+ when 'CookieName' then @app_cookie_stickiness_policy[:cookie_name] = @text
398
+ when 'member' then @item[:app_cookie_stickiness_policies] << @app_cookie_stickiness_policy
399
+ end
400
+ when %r{LBCookieStickinessPolicies/member}
401
+ case name
402
+ when 'PolicyName' then @lb_cookie_stickiness_policy[:policy_name] = @text
403
+ when 'CookieExpirationPeriod' then @lb_cookie_stickiness_policy[:cookie_expiration_period] = @text.to_i
404
+ when 'member' then @item[:lb_cookie_stickiness_policies] << @lb_cookie_stickiness_policy
405
+ end
406
+ when %r{LoadBalancerDescriptions/member$}
407
+ @item[:availability_zones].sort!
408
+ @item[:instances].sort!
409
+ @result << @item
410
+ end
411
+ end
412
+ def reset
413
+ @result = []
414
+ end
415
+ end
416
+
417
+ class CreateLoadBalancerParser < RightAWSParser #:nodoc:
418
+ def tagend(name)
419
+ @result = @text if name == 'DNSName'
420
+ end
421
+ end
422
+
423
+ class DeleteLoadBalancerParser < RightAWSParser #:nodoc:
424
+ def tagend(name)
425
+ @result = true if name == 'DeleteLoadBalancerResult'
426
+ end
427
+ end
428
+
429
+ class AvailabilityZonesForLoadBalancerParser < RightAWSParser #:nodoc:
430
+ def tagend(name)
431
+ case name
432
+ when 'member'
433
+ @result << @text
434
+ when 'AvailabilityZones'
435
+ @result.sort!
436
+ end
437
+ end
438
+ def reset
439
+ @result = []
440
+ end
441
+ end
442
+
443
+ class HealthCheckParser < RightAWSParser #:nodoc:
444
+ def tagend(name)
445
+ case name
446
+ when 'Interval' then @result[:interval] = @text.to_i
447
+ when 'Target' then @result[:target] = @text
448
+ when 'HealthyThreshold' then @result[:healthy_threshold] = @text.to_i
449
+ when 'Timeout' then @result[:timeout] = @text.to_i
450
+ when 'UnhealthyThreshold' then @result[:unhealthy_threshold] = @text.to_i
451
+ end
452
+ end
453
+ def reset
454
+ @result = {}
455
+ end
456
+ end
457
+
458
+ #-----------------------------------------------------------------
459
+ # PARSERS: Instances
460
+ #-----------------------------------------------------------------
461
+
462
+ class DescribeInstanceHealthParser < RightAWSParser #:nodoc:
463
+ def tagstart(name, attributes)
464
+ @item = {} if name == 'member'
465
+ end
466
+ def tagend(name)
467
+ case name
468
+ when 'Description' then @item[:description] = @text
469
+ when 'State' then @item[:state] = @text
470
+ when 'InstanceId' then @item[:instance_id] = @text
471
+ when 'ReasonCode' then @item[:reason_code] = @text
472
+ when 'member' then @result << @item
473
+ end
474
+ end
475
+ def reset
476
+ @result = []
477
+ end
478
+ end
479
+
480
+ class InstancesWithLoadBalancerParser < RightAWSParser #:nodoc:
481
+ def tagend(name)
482
+ case name
483
+ when 'InstanceId'
484
+ @result << @text
485
+ when 'Instances'
486
+ @result.sort!
487
+ end
488
+ end
489
+ def reset
490
+ @result = []
491
+ end
492
+ end
493
+
494
+ end
495
+
496
+ end