ktheory-right_aws 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/History.txt +284 -0
  2. data/Manifest.txt +50 -0
  3. data/README.txt +167 -0
  4. data/Rakefile +110 -0
  5. data/lib/acf/right_acf_interface.rb +485 -0
  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 +249 -0
  9. data/lib/as/right_as_interface.rb +699 -0
  10. data/lib/awsbase/benchmark_fix.rb +39 -0
  11. data/lib/awsbase/right_awsbase.rb +978 -0
  12. data/lib/awsbase/support.rb +115 -0
  13. data/lib/ec2/right_ec2.rb +395 -0
  14. data/lib/ec2/right_ec2_ebs.rb +452 -0
  15. data/lib/ec2/right_ec2_images.rb +373 -0
  16. data/lib/ec2/right_ec2_instances.rb +755 -0
  17. data/lib/ec2/right_ec2_monitoring.rb +70 -0
  18. data/lib/ec2/right_ec2_reserved_instances.rb +170 -0
  19. data/lib/ec2/right_ec2_security_groups.rb +277 -0
  20. data/lib/ec2/right_ec2_spot_instances.rb +399 -0
  21. data/lib/ec2/right_ec2_vpc.rb +571 -0
  22. data/lib/elb/right_elb_interface.rb +496 -0
  23. data/lib/rds/right_rds_interface.rb +998 -0
  24. data/lib/right_aws.rb +83 -0
  25. data/lib/s3/right_s3.rb +1126 -0
  26. data/lib/s3/right_s3_interface.rb +1199 -0
  27. data/lib/sdb/active_sdb.rb +1122 -0
  28. data/lib/sdb/right_sdb_interface.rb +721 -0
  29. data/lib/sqs/right_sqs.rb +388 -0
  30. data/lib/sqs/right_sqs_gen2.rb +343 -0
  31. data/lib/sqs/right_sqs_gen2_interface.rb +524 -0
  32. data/lib/sqs/right_sqs_interface.rb +594 -0
  33. data/test/acf/test_helper.rb +2 -0
  34. data/test/acf/test_right_acf.rb +138 -0
  35. data/test/ec2/test_helper.rb +2 -0
  36. data/test/ec2/test_right_ec2.rb +108 -0
  37. data/test/http_connection.rb +87 -0
  38. data/test/rds/test_helper.rb +2 -0
  39. data/test/rds/test_right_rds.rb +120 -0
  40. data/test/s3/test_helper.rb +2 -0
  41. data/test/s3/test_right_s3.rb +421 -0
  42. data/test/s3/test_right_s3_stubbed.rb +97 -0
  43. data/test/sdb/test_active_sdb.rb +357 -0
  44. data/test/sdb/test_helper.rb +3 -0
  45. data/test/sdb/test_right_sdb.rb +253 -0
  46. data/test/sqs/test_helper.rb +2 -0
  47. data/test/sqs/test_right_sqs.rb +291 -0
  48. data/test/sqs/test_right_sqs_gen2.rb +264 -0
  49. data/test/test_credentials.rb +37 -0
  50. data/test/ts_right_aws.rb +14 -0
  51. metadata +184 -0
@@ -0,0 +1,571 @@
1
+ #
2
+ # Copyright (c) 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
+ class Ec2
27
+
28
+ private
29
+
30
+ def vpc__split_list_and_filters(*params) # :nodoc:
31
+ params = params.flatten
32
+ filters = params.last.is_a?(Hash) ? params.pop : {}
33
+ # Make values to be arrays.
34
+ filters.each{|key, values| filters[key] = Array(values) }
35
+ [params, filters]
36
+ end
37
+
38
+ public
39
+
40
+ #-----------------
41
+ # VPC
42
+ #-----------------
43
+
44
+ # Describe VPCs
45
+ #
46
+ # ec2.describe_vpcs #=>
47
+ # [{:vpc_id=>"vpc-890ce2e0",
48
+ # :dhcp_options_id=>"default",
49
+ # :cidr_block=>"10.0.0.0/23",
50
+ # :state=>"available"}]
51
+ #
52
+ # ec2.describe_vpcs("vpc-890ce2e0")
53
+ #
54
+ def describe_vpcs(*list_and_filters)
55
+ list, filters = vpc__split_list_and_filters(list_and_filters)
56
+ cache_for = (list.empty? && filters.empty?) ? :describe_vpcs : nil
57
+ request_hash = {}
58
+ request_hash.merge!(amazonize_list('VpcId', list))
59
+ request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
60
+ link = generate_request("DescribeVpcs", request_hash)
61
+ request_cache_or_info cache_for, link, QEc2DescribeVpcsParser, @@bench, cache_for
62
+ rescue Exception
63
+ on_exception
64
+ end
65
+
66
+ # Create VPC.
67
+ #
68
+ # ec2.create_vpc('10.0.0.0/23') #=>
69
+ # {:vpc_id=>"vpc-890ce2e0",
70
+ # :dhcp_options_id=>"default",
71
+ # :cidr_block=>"10.0.0.0/23",
72
+ # :state=>"pending"}
73
+ #
74
+ def create_vpc(cidr_block)
75
+ link = generate_request("CreateVpc",'CidrBlock' => cidr_block )
76
+ request_info(link, QEc2DescribeVpcsParser.new(:logger => @logger)).first
77
+ rescue Exception
78
+ on_exception
79
+ end
80
+
81
+ # Delete VPC.
82
+ #
83
+ # ec2.delete_vpc("vpc-890ce2e0") #=> true
84
+ #
85
+ def delete_vpc(vpc_id)
86
+ link = generate_request("DeleteVpc", 'VpcId' => vpc_id )
87
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
88
+ rescue Exception
89
+ on_exception
90
+ end
91
+
92
+ #-----------------
93
+ # Subnets
94
+ #-----------------
95
+
96
+ # Describe Subnet.
97
+ #
98
+ # ec2.describe_subnets #=>
99
+ # [{:available_ip_address_count=>"251",
100
+ # :vpc_id=>"vpc-890ce2e0",
101
+ # :availability_zone=>"us-east-1a",
102
+ # :subnet_id=>"subnet-770de31e",
103
+ # :cidr_block=>"10.0.1.0/24",
104
+ # :state=>"available"}]
105
+ #
106
+ def describe_subnets(*list_and_filters)
107
+ list, filters = vpc__split_list_and_filters(list_and_filters)
108
+ cache_for = (list.empty? && filters.empty?) ? :describe_subnets : nil
109
+ request_hash = {}
110
+ request_hash.merge!(amazonize_list('SubnetId', list))
111
+ request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
112
+ link = generate_request("DescribeSubnets", request_hash)
113
+ request_cache_or_info cache_for, link, QEc2DescribeSubnetsParser, @@bench, cache_for
114
+ rescue Exception
115
+ on_exception
116
+ end
117
+
118
+ # Create Subnet.
119
+ #
120
+ # ec2.create_subnet("vpc-890ce2e0",'10.0.1.0/24') #=>
121
+ # {:available_ip_address_count=>"251",
122
+ # :vpc_id=>"vpc-890ce2e0",
123
+ # :availability_zone=>"us-east-1a",
124
+ # :subnet_id=>"subnet-770de31e",
125
+ # :cidr_block=>"10.0.1.0/24",
126
+ # :state=>"pending"}
127
+ #
128
+ def create_subnet(vpc_id, cidr_block, availability_zone = nil)
129
+ request_hash = { 'VpcId' => vpc_id,
130
+ 'CidrBlock' => cidr_block }
131
+ request_hash['AvailabilityZone'] = availability_zone unless availability_zone.blank?
132
+ link = generate_request("CreateSubnet", request_hash)
133
+ request_info(link, QEc2DescribeSubnetsParser.new(:logger => @logger)).first
134
+ rescue Exception
135
+ on_exception
136
+ end
137
+
138
+ # Delete Subnet.
139
+ #
140
+ # ec2.delete_subnet("subnet-770de31e") #=> true
141
+ #
142
+ def delete_subnet(subnet_id)
143
+ link = generate_request("DeleteSubnet", 'SubnetId' => subnet_id )
144
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
145
+ rescue Exception
146
+ on_exception
147
+ end
148
+
149
+ #-----------------
150
+ # DHCP Options
151
+ #-----------------
152
+
153
+ # Describe DHCP options.
154
+ #
155
+ # ec2.describe_dhcp_options #=>
156
+ # [{:dhcp_options_id=>"dopt-cb0de3a2",
157
+ # :dhcp_configuration_set=>
158
+ # {"netbios-node-type"=>["1"], "domain-name"=>["my.awesomesite.ru"]}}]
159
+ #
160
+ def describe_dhcp_options(*list)
161
+ list = list.flatten
162
+ cache_for = list.empty? ? :describe_dhcp_options : nil
163
+ request_hash = amazonize_list('DhcpOptionsId', list)
164
+ link = generate_request("DescribeDhcpOptions", request_hash)
165
+ request_cache_or_info cache_for, link, QEc2DescribeDhcpOptionsParser, @@bench, cache_for
166
+ rescue Exception
167
+ on_exception
168
+ end
169
+
170
+ # Create DHCP options.
171
+ #
172
+ # ec2.create_dhcp_options('domain-name' => 'my.awesomesite.ru',
173
+ # 'netbios-node-type' => 1) #=>
174
+ # {:dhcp_options_id=>"dopt-cb0de3a2",
175
+ # :dhcp_configuration_set=>
176
+ # {"netbios-node-type"=>["1"], "domain-name"=>["my.awesomesite.ru"]}}
177
+ #
178
+ def create_dhcp_options(dhcp_configuration)
179
+ dhcp_configuration.each{ |key, values| dhcp_configuration[key] = Array(values) }
180
+ request_hash = amazonize_list(['DhcpConfiguration.?.Key','DhcpConfiguration.?.Value.?'], dhcp_configuration)
181
+ link = generate_request("CreateDhcpOptions", request_hash)
182
+ request_info(link, QEc2DescribeDhcpOptionsParser.new(:logger => @logger)).first
183
+ rescue Exception
184
+ on_exception
185
+ end
186
+
187
+ # Associate DHCP options
188
+ #
189
+ # ec2.associate_dhcp_options("dopt-cb0de3a2", "vpc-890ce2e0" ) #=> true
190
+ # ec2.describe_vpcs #=>
191
+ # [{:vpc_id=>"vpc-890ce2e0",
192
+ # :dhcp_options_id=>"dopt-cb0de3a2",
193
+ # :cidr_block=>"10.0.0.0/23",
194
+ # :state=>"available"}]
195
+ #
196
+ def associate_dhcp_options(dhcp_options_id, vpc_id)
197
+ link = generate_request("AssociateDhcpOptions", 'DhcpOptionsId' => dhcp_options_id,
198
+ 'VpcId' => vpc_id)
199
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
200
+ rescue Exception
201
+ on_exception
202
+ end
203
+
204
+ # Delete DHCP Options.
205
+ #
206
+ # ec2.delete_dhcp_options("dopt-cb0de3a2") #=> true
207
+ #
208
+ def delete_dhcp_options(dhcp_options_id)
209
+ link = generate_request("DeleteDhcpOptions", 'DhcpOptionsId' => dhcp_options_id )
210
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
211
+ rescue Exception
212
+ on_exception
213
+ end
214
+
215
+ #-----------------
216
+ # Customer Gateways
217
+ #-----------------
218
+
219
+ # Describe customer gateways.
220
+ #
221
+ # ec2.describe_customer_gateways
222
+ #
223
+ # [{:type=>"ipsec.1",
224
+ # :ip_address=>"12.1.2.3",
225
+ # :bgp_asn=>"65534",
226
+ # :state=>"available",
227
+ # :customer_gateway_id=>"cgw-d5a643bc"}]
228
+ #
229
+ def describe_customer_gateways(*list_and_filters)
230
+ list, filters = vpc__split_list_and_filters(list_and_filters)
231
+ cache_for = (list.empty? && filters.empty?) ? :describe_customer_gateways : nil
232
+ request_hash = {}
233
+ request_hash.merge!(amazonize_list('CustomerGatewayId', list))
234
+ request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
235
+ link = generate_request("DescribeCustomerGateways", request_hash)
236
+ request_cache_or_info cache_for, link, QEc2DescribeCustomerGatewaysParser, @@bench, cache_for
237
+ rescue Exception
238
+ on_exception
239
+ end
240
+
241
+ # Create customer gateway.
242
+ #
243
+ # ec2.create_customer_gateway('ipsec.1', '12.1.2.3', 65534) #=>
244
+ # {:type=>"ipsec.1",
245
+ # :bgp_asn=>"65534",
246
+ # :ip_address=>"12.1.2.3",
247
+ # :state=>"pending",
248
+ # :customer_gateway_id=>"cgw-d5a643bc"}
249
+ #
250
+ def create_customer_gateway(type, ip_address, bgp_asn)
251
+ link = generate_request("CreateCustomerGateway", 'Type' => type,
252
+ 'IpAddress' => ip_address,
253
+ 'BgpAsn' => bgp_asn )
254
+ request_info(link, QEc2DescribeCustomerGatewaysParser.new(:logger => @logger)).first
255
+ rescue Exception
256
+ on_exception
257
+ end
258
+
259
+ # Delete customer gateway.
260
+ #
261
+ # ec2.delete_customer_gateway("cgw-d5a643bc") #=> true
262
+ #
263
+ def delete_customer_gateway(customer_gateway_id)
264
+ link = generate_request("DeleteCustomerGateway", 'CustomerGatewayId' => customer_gateway_id )
265
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
266
+ rescue Exception
267
+ on_exception
268
+ end
269
+
270
+ #-----------------
271
+ # VPN Gateways
272
+ #-----------------
273
+
274
+ # Describe VPN gateways.
275
+ #
276
+ # ec2.describe_vpn_gateways #=>
277
+ # [{:type=>"ipsec.1",
278
+ # :availability_zone=>"us-east-1a",
279
+ # :attachments=>[{:vpc_id=>"vpc-890ce2e0", :state=>"attached"}],
280
+ # :vpn_gateway_id=>"vgw-dfa144b6"}]
281
+ #
282
+ def describe_vpn_gateways(*list_and_filters)
283
+ list, filters = vpc__split_list_and_filters(list_and_filters)
284
+ cache_for = (list.empty? && filters.empty?) ? :describe_vpn_gateways : nil
285
+ request_hash = {}
286
+ request_hash.merge!(amazonize_list('VpnGatewayId', list))
287
+ request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
288
+ link = generate_request("DescribeVpnGateways", request_hash)
289
+ request_cache_or_info cache_for, link, QEc2DescribeVpnGatewaysParser, @@bench, cache_for
290
+ rescue Exception
291
+ on_exception
292
+ end
293
+
294
+ # Create VPN gateway.
295
+ #
296
+ # ec2.create_vpn_gateway('ipsec.1') #=>
297
+ # {:type=>"ipsec.1",
298
+ # :availability_zone=>"us-east-1a",
299
+ # :attachments=>[nil],
300
+ # :vpn_gateway_id=>"vgw-dfa144b6"}
301
+ #
302
+ def create_vpn_gateway(type, availability_zone=nil)
303
+ request_hash = { 'Type' => type }
304
+ request_hash['AvailabilityZone'] = availability_zone unless availability_zone.blank?
305
+ link = generate_request("CreateVpnGateway", request_hash )
306
+ request_info(link, QEc2DescribeVpnGatewaysParser.new(:logger => @logger)).first
307
+ rescue Exception
308
+ on_exception
309
+ end
310
+
311
+ # Attach VPN gateway.
312
+ #
313
+ # ec2.attach_vpn_gateway('vgw-dfa144b6','vpc-890ce2e0') #=>
314
+ # {:vpc_id=>"vpc-890ce2e0", :state=>"attaching"}
315
+ #
316
+ def attach_vpn_gateway(vpn_gateway_id, vpc_id)
317
+ link = generate_request("AttachVpnGateway", 'VpnGatewayId' => vpn_gateway_id,
318
+ 'VpcId' => vpc_id )
319
+ request_info(link, QEc2AttachVpnGatewayParser.new(:logger => @logger))
320
+ rescue Exception
321
+ on_exception
322
+ end
323
+
324
+ # Detach VPN gateway.
325
+ #
326
+ # ec2.detach_vpn_gateway('vgw-dfa144b6','vpc-890ce2e0') #=> true
327
+ #
328
+ def detach_vpn_gateway(vpn_gateway_id, vpc_id)
329
+ link = generate_request("DetachVpnGateway", 'VpnGatewayId' => vpn_gateway_id,
330
+ 'VpcId' => vpc_id )
331
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
332
+ rescue Exception
333
+ on_exception
334
+ end
335
+
336
+ # Delete vpn gateway.
337
+ #
338
+ # ec2.delete_vpn_gateway("vgw-dfa144b6") #=> true
339
+ #
340
+ def delete_vpn_gateway(vpn_gateway_id)
341
+ link = generate_request("DeleteVpnGateway", 'VpnGatewayId' => vpn_gateway_id )
342
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
343
+ rescue Exception
344
+ on_exception
345
+ end
346
+
347
+ #-----------------
348
+ # VPN Connections
349
+ #-----------------
350
+
351
+ # Describe VPN connections.
352
+ #
353
+ # ec2.describe_vpn_connections #=>
354
+ # [{:type=>"ipsec.1",
355
+ # :vpn_connection_id=>"vpn-a9a643c0",
356
+ # :customer_gateway_configuration=>
357
+ # "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-a9a643c0\">\n...</vpn_connection>\n",
358
+ # :state=>"available",
359
+ # :vpn_gateway_id=>"vgw-dfa144b6",
360
+ # :customer_gateway_id=>"cgw-81a643e8"}]
361
+ #
362
+ def describe_vpn_connections(*list_and_filters)
363
+ list, filters = vpc__split_list_and_filters(list_and_filters)
364
+ cache_for = (list.empty? && filters.empty?) ? :describe_vpn_connections : nil
365
+ request_hash = {}
366
+ request_hash.merge!(amazonize_list('VpnConnectionId', list))
367
+ request_hash.merge!(amazonize_list(['Filter.?.Key','Filter.?.Value.?'], filters))
368
+ link = generate_request("DescribeVpnConnections", request_hash)
369
+ request_cache_or_info cache_for, link, QEc2DescribeVpnConnectionsParser, @@bench, cache_for
370
+ rescue Exception
371
+ on_exception
372
+ end
373
+
374
+ # Create VPN connection.
375
+ #
376
+ # ec2.create_vpn_connection('ipsec.1', 'cgw-81a643e8' ,'vgw-dfa144b6')
377
+ # {:customer_gateway_id=>"cgw-81a643e8",
378
+ # :vpn_connection_id=>"vpn-a9a643c0",
379
+ # :customer_gateway_configuration=>
380
+ # "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-a9a643c0\">\n...</vpn_connection>\n",
381
+ # :state=>"pending",
382
+ # :vpn_gateway_id=>"vgw-dfa144b6"}
383
+ #
384
+ def create_vpn_connection(type, customer_gateway_id, vpn_gateway_id)
385
+ link = generate_request("CreateVpnConnection", 'Type' => type,
386
+ 'CustomerGatewayId' => customer_gateway_id,
387
+ 'VpnGatewayId' => vpn_gateway_id )
388
+ request_info(link, QEc2DescribeVpnConnectionsParser.new(:logger => @logger)).first
389
+ rescue Exception
390
+ on_exception
391
+ end
392
+
393
+ # Delete VPN connection.
394
+ #
395
+ # ec2.delete_vpn_connection("vpn-a9a643c0") #=> true
396
+ #
397
+ def delete_vpn_connection(vpn_connection_id)
398
+ link = generate_request("DeleteVpnConnection", 'VpnConnectionId' => vpn_connection_id )
399
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
400
+ rescue Exception
401
+ on_exception
402
+ end
403
+
404
+ #-----------------
405
+ # Parsers
406
+ #-----------------
407
+
408
+ class QEc2DescribeVpcsParser < RightAWSParser #:nodoc:
409
+ def tagstart(name, attributes)
410
+ case name
411
+ when 'item', 'vpc' then @item = {}
412
+ end
413
+ end
414
+ def tagend(name)
415
+ case name
416
+ when 'vpcId' then @item[:vpc_id] = @text
417
+ when 'state' then @item[:state] = @text
418
+ when 'dhcpOptionsId' then @item[:dhcp_options_id] = @text
419
+ when 'cidrBlock' then @item[:cidr_block] = @text
420
+ when 'item', 'vpc' then @result << @item
421
+ end
422
+ end
423
+ def reset
424
+ @result = []
425
+ end
426
+ end
427
+
428
+ class QEc2DescribeSubnetsParser < RightAWSParser #:nodoc:
429
+ def tagstart(name, attributes)
430
+ case name
431
+ when 'item', 'subnet' then @item = {}
432
+ end
433
+ end
434
+ def tagend(name)
435
+ case name
436
+ when 'subnetId' then @item[:subnet_id] = @text
437
+ when 'state' then @item[:state] = @text
438
+ when 'vpcId' then @item[:vpc_id] = @text
439
+ when 'cidrBlock' then @item[:cidr_block] = @text
440
+ when 'availabilityZone' then @item[:availability_zone] = @text
441
+ when 'availableIpAddressCount' then @item[:available_ip_address_count] = @text
442
+ when 'item', 'subnet' then @result << @item
443
+ end
444
+ end
445
+ def reset
446
+ @result = []
447
+ end
448
+ end
449
+
450
+ class QEc2DescribeDhcpOptionsParser < RightAWSParser #:nodoc:
451
+ def tagstart(name, attributes)
452
+ case full_tag_name
453
+ when @p1, @p2
454
+ @item = { :dhcp_configuration_set => {} }
455
+ end
456
+ end
457
+ def tagend(name)
458
+ case name
459
+ when 'dhcpOptionsId' then @item[:dhcp_options_id] = @text
460
+ when 'key' then @conf_item_key = @text
461
+ when 'value' then (@item[:dhcp_configuration_set][@conf_item_key] ||= []) << @text
462
+ end
463
+ case full_tag_name
464
+ when @p1, @p2
465
+ @result << @item
466
+ end
467
+ end
468
+ def reset
469
+ @p1 = 'DescribeDhcpOptionsResponse/dhcpOptionsSet/item'
470
+ @p2 = 'CreateDhcpOptionsResponse/dhcpOptions'
471
+ @result = []
472
+ end
473
+ end
474
+
475
+ class QEc2DescribeCustomerGatewaysParser < RightAWSParser #:nodoc:
476
+ def tagstart(name, attributes)
477
+ case name
478
+ when 'item', 'customerGateway'
479
+ @item = {}
480
+ end
481
+ end
482
+ def tagend(name)
483
+ case name
484
+ when 'customerGatewayId' then @item[:customer_gateway_id] = @text
485
+ when 'state' then @item[:state] = @text
486
+ when 'type' then @item[:type] = @text
487
+ when 'ipAddress' then @item[:ip_address] = @text
488
+ when 'bgpAsn' then @item[:bgp_asn] = @text
489
+ when 'item', 'customerGateway' then @result << @item
490
+ end
491
+ end
492
+ def reset
493
+ @result = []
494
+ end
495
+ end
496
+
497
+ class QEc2DescribeVpnGatewaysParser < RightAWSParser #:nodoc:
498
+ def tagstart(name, attributes)
499
+ case full_tag_name
500
+ when @p1, @p2
501
+ @item = { :attachments => [] }
502
+ when "#{@p1}/attachments/item",
503
+ "#{@p2}/attachments/item"
504
+ @attachment = {}
505
+ end
506
+ end
507
+ def tagend(name)
508
+ case name
509
+ when 'vpnGatewayId' then @item[:vpn_gateway_id] = @text
510
+ when 'availabilityZone' then @item[:availability_zone] = @text
511
+ when 'type' then @item[:type] = @text
512
+ when 'vpcId' then @attachment[:vpc_id] = @text
513
+ end
514
+ case full_tag_name
515
+ when "#{@p1}/state",
516
+ "#{@p2}/state"
517
+ @item[:state] = @text
518
+ when "#{@p1}/attachments/item/state",
519
+ "#{@p2}/attachments/item/state"
520
+ @attachment[:state] = @text
521
+ when "#{@p1}/attachments/item",
522
+ "#{@p2}/attachments/item"
523
+ @item[:attachments] << @attachment unless @attachment.blank?
524
+ when @p1, @p2
525
+ @result << @item
526
+ end
527
+ end
528
+ def reset
529
+ @p1 = 'DescribeVpnGatewaysResponse/vpnGatewaySet/item'
530
+ @p2 = 'CreateVpnGatewayResponse/vpnGateway'
531
+ @result = []
532
+ end
533
+ end
534
+
535
+ class QEc2AttachVpnGatewayParser < RightAWSParser #:nodoc:
536
+ def tagend(name)
537
+ case name
538
+ when 'vpcId' then @result[:vpc_id] = @text
539
+ when 'state' then @result[:state] = @text
540
+ end
541
+ end
542
+ def reset
543
+ @result = {}
544
+ end
545
+ end
546
+
547
+
548
+ class QEc2DescribeVpnConnectionsParser < RightAWSParser #:nodoc:
549
+ def tagstart(name, attributes)
550
+ case name
551
+ when 'item', 'vpnConnection' then @item = {}
552
+ end
553
+ end
554
+ def tagend(name)
555
+ case name
556
+ when 'vpnConnectionId' then @item[:vpn_connection_id] = @text
557
+ when 'state' then @item[:state] = @text
558
+ when 'type' then @item[:type] = @text
559
+ when 'vpnGatewayId' then @item[:vpn_gateway_id] = @text
560
+ when 'customerGatewayId' then @item[:customer_gateway_id] = @text
561
+ when 'customerGatewayConfiguration' then @item[:customer_gateway_configuration] = @text
562
+ when 'item','vpnConnection' then @result << @item
563
+ end
564
+ end
565
+ def reset
566
+ @result = []
567
+ end
568
+ end
569
+
570
+ end
571
+ end