aboisvert_aws 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +329 -0
- data/Manifest.txt +61 -0
- data/README.txt +163 -0
- data/Rakefile +130 -0
- data/lib/acf/right_acf_interface.rb +549 -0
- data/lib/acf/right_acf_invalidations.rb +144 -0
- data/lib/acf/right_acf_origin_access_identities.rb +230 -0
- data/lib/acf/right_acf_streaming_interface.rb +229 -0
- data/lib/acw/right_acw_interface.rb +248 -0
- data/lib/as/right_as_interface.rb +698 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/right_awsbase.rb +1343 -0
- data/lib/awsbase/support.rb +35 -0
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +541 -0
- data/lib/ec2/right_ec2_ebs.rb +481 -0
- data/lib/ec2/right_ec2_images.rb +444 -0
- data/lib/ec2/right_ec2_instances.rb +788 -0
- data/lib/ec2/right_ec2_monitoring.rb +70 -0
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +184 -0
- data/lib/ec2/right_ec2_security_groups.rb +491 -0
- data/lib/ec2/right_ec2_spot_instances.rb +422 -0
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +590 -0
- data/lib/ec2/right_ec2_vpc2.rb +381 -0
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +573 -0
- data/lib/emr/right_emr_interface.rb +727 -0
- data/lib/iam/right_iam_access_keys.rb +71 -0
- data/lib/iam/right_iam_groups.rb +195 -0
- data/lib/iam/right_iam_interface.rb +341 -0
- data/lib/iam/right_iam_mfa_devices.rb +67 -0
- data/lib/iam/right_iam_users.rb +251 -0
- data/lib/rds/right_rds_interface.rb +1384 -0
- data/lib/right_aws.rb +86 -0
- data/lib/route_53/right_route_53_interface.rb +640 -0
- data/lib/s3/right_s3.rb +1138 -0
- data/lib/s3/right_s3_interface.rb +1278 -0
- data/lib/sdb/active_sdb.rb +1107 -0
- data/lib/sdb/right_sdb_interface.rb +762 -0
- data/lib/sns/right_sns_interface.rb +286 -0
- data/lib/sqs/right_sqs.rb +387 -0
- data/lib/sqs/right_sqs_gen2.rb +342 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +523 -0
- data/lib/sqs/right_sqs_interface.rb +593 -0
- data/right_aws.gemspec +90 -0
- data/test/README.mdown +39 -0
- data/test/acf/test_helper.rb +2 -0
- data/test/acf/test_right_acf.rb +138 -0
- data/test/awsbase/test_helper.rb +2 -0
- data/test/awsbase/test_right_awsbase.rb +11 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_right_ec2.rb +107 -0
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/http_connection.rb +87 -0
- data/test/rds/test_helper.rb +2 -0
- data/test/rds/test_right_rds.rb +120 -0
- data/test/route_53/fixtures/a_record.xml +18 -0
- data/test/route_53/fixtures/alias_record.xml +18 -0
- data/test/route_53/test_helper.rb +2 -0
- data/test/route_53/test_right_route_53.rb +141 -0
- data/test/s3/test_helper.rb +2 -0
- data/test/s3/test_right_s3.rb +528 -0
- data/test/s3/test_right_s3_stubbed.rb +97 -0
- data/test/sdb/test_active_sdb.rb +357 -0
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sdb/test_helper.rb +3 -0
- data/test/sdb/test_right_sdb.rb +253 -0
- data/test/sns/test_helper.rb +2 -0
- data/test/sns/test_right_sns.rb +153 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_right_sqs.rb +285 -0
- data/test/sqs/test_right_sqs_gen2.rb +264 -0
- data/test/test_credentials.rb +37 -0
- data/test/ts_right_aws.rb +15 -0
- metadata +257 -0
@@ -0,0 +1,381 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2011 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
|
+
# VPC v2: Limits
|
29
|
+
#
|
30
|
+
# http://docs.amazonwebservices.com/AmazonVPC/latest/UserGuide/index.html?VPC_Appendix_Limits.html
|
31
|
+
|
32
|
+
#----------------------
|
33
|
+
# InternetGateways
|
34
|
+
#----------------------
|
35
|
+
|
36
|
+
# Create internet gateway
|
37
|
+
#
|
38
|
+
# ec2.create_internet_gateway #=>
|
39
|
+
# { :internet_gateway_id=>"igw-6585c10c", :tags=>{}}
|
40
|
+
#
|
41
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-CreateInternetGateway.html
|
42
|
+
#
|
43
|
+
def create_internet_gateway
|
44
|
+
link = generate_request("CreateInternetGateway")
|
45
|
+
request_info(link, QEc2DescribeInternetGatewaysParser.new(:logger => @logger)).first
|
46
|
+
rescue Exception
|
47
|
+
on_exception
|
48
|
+
end
|
49
|
+
|
50
|
+
# Describe internet gateways.
|
51
|
+
#
|
52
|
+
# ec2.describe_internet_gateways #=>
|
53
|
+
# [{:state=>"available",
|
54
|
+
# :internet_gateway_id=>"igw-6585c10c",
|
55
|
+
# :vpc_id=>"vpc-df80a6b6",
|
56
|
+
# :tags=>{}},
|
57
|
+
# {:internet_gateway_id=>"igw-883503e1",
|
58
|
+
# :tags=>{}}]
|
59
|
+
#
|
60
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-CreateInternetGateway.html
|
61
|
+
#
|
62
|
+
def describe_internet_gateways(*list_and_options)
|
63
|
+
describe_resources_with_list_and_options('DescribeInternetGateways', 'InternetGatewayId', QEc2DescribeInternetGatewaysParser, list_and_options)
|
64
|
+
rescue Exception
|
65
|
+
on_exception
|
66
|
+
end
|
67
|
+
|
68
|
+
# Delete internet gateway.
|
69
|
+
#
|
70
|
+
# ec2.delete_internet_gateway("igw-6585c10c") #=> true
|
71
|
+
#
|
72
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteInternetGateway.html
|
73
|
+
#
|
74
|
+
def delete_internet_gateway(internet_gateway_id)
|
75
|
+
link = generate_request("DeleteInternetGateway", 'InternetGatewayId' => internet_gateway_id )
|
76
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
77
|
+
rescue Exception
|
78
|
+
on_exception
|
79
|
+
end
|
80
|
+
|
81
|
+
# Attaches an Internet gateway to a VPC, enabling connectivity between the Internet and the VPC.
|
82
|
+
#
|
83
|
+
# ec2.attach_internet_gateway("igw-6585c10c", "vpc-df80a6b6") #=> true
|
84
|
+
#
|
85
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AttachInternetGateway.html
|
86
|
+
#
|
87
|
+
def attach_internet_gateway(internet_gateway_id, vpc_id)
|
88
|
+
request_hash = { 'InternetGatewayId' => internet_gateway_id,
|
89
|
+
'VpcId' => vpc_id }
|
90
|
+
link = generate_request("AttachInternetGateway", request_hash)
|
91
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
92
|
+
rescue Exception
|
93
|
+
on_exception
|
94
|
+
end
|
95
|
+
|
96
|
+
# Detaches an Internet gateway from a VPC, disabling connectivity between the Internet and the VPC.
|
97
|
+
# The VPC must not contain any running instances with Elastic IP addresses.
|
98
|
+
#
|
99
|
+
# ec2.detach_internet_gateway("igw-6585c10c", "vpc-df80a6b6") #=> true
|
100
|
+
#
|
101
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DetachInternetGateway.html
|
102
|
+
#
|
103
|
+
def detach_internet_gateway(internet_gateway_id, vpc_id)
|
104
|
+
request_hash = { 'InternetGatewayId' => internet_gateway_id,
|
105
|
+
'VpcId' => vpc_id }
|
106
|
+
link = generate_request("DetachInternetGateway", request_hash)
|
107
|
+
request_info(link, RightHttp2xxParser::new(:logger => @logger))
|
108
|
+
rescue Exception
|
109
|
+
on_exception
|
110
|
+
end
|
111
|
+
|
112
|
+
#----------------------
|
113
|
+
# RouteTables
|
114
|
+
#----------------------
|
115
|
+
|
116
|
+
# Describe route tables.
|
117
|
+
#
|
118
|
+
# # List all tables
|
119
|
+
# ec2.describe_route_tables #=>
|
120
|
+
# [{:route_table_id=>"rtb-be3006d7",
|
121
|
+
# :route_set=>
|
122
|
+
# [{:state=>"active",
|
123
|
+
# :destination_cidr_block=>"10.0.3.0/24",
|
124
|
+
# :gateway_id=>"local"}],
|
125
|
+
# :vpc_id=>"vpc-df80a6b6",
|
126
|
+
# :association_set=>[],
|
127
|
+
# :tags=>{}},
|
128
|
+
# {:route_table_id=>"rtb-e36cf98a",
|
129
|
+
# :route_set=>
|
130
|
+
# [{:state=>"active",
|
131
|
+
# :destination_cidr_block=>"192.168.0.0/24",
|
132
|
+
# :gateway_id=>"local"}],
|
133
|
+
# :vpc_id=>"vpc-e16cf988",
|
134
|
+
# :association_set=>
|
135
|
+
# [{:route_table_id=>"rtb-e36cf98a",
|
136
|
+
# :main=>true,
|
137
|
+
# :route_table_association_id=>"rtbassoc-e26cf98b"}],
|
138
|
+
# :tags=>{}}, ... ]
|
139
|
+
#
|
140
|
+
# # Filter tables by VpcId
|
141
|
+
# ec2.describe_route_tables(:filters => {'vpc-id' => "vpc-df80a6b6"})
|
142
|
+
#
|
143
|
+
# # Custom route table
|
144
|
+
# ec2.describe_route_tables("rtb-be3006d7") #=>
|
145
|
+
# [{:vpc_id=>"vpc-df80a6b6",
|
146
|
+
# :route_set=>
|
147
|
+
# [{:state=>"active",
|
148
|
+
# :destination_cidr_block=>"0.0.0.1/32",
|
149
|
+
# :gateway_id=>"igw-6585c10c"},
|
150
|
+
# {:state=>"active",
|
151
|
+
# :destination_cidr_block=>"10.0.3.0/24",
|
152
|
+
# :gateway_id=>"local"}],
|
153
|
+
# :route_table_id=>"rtb-be3006d7",
|
154
|
+
# :tags=>{},
|
155
|
+
# :association_set=>
|
156
|
+
# [{:route_table_association_id=>"rtbassoc-a02610c9",
|
157
|
+
# :subnet_id=>"subnet-b95f76d0",
|
158
|
+
# :route_table_id=>"rtb-be3006d7"}]}]
|
159
|
+
#
|
160
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeRouteTables.html
|
161
|
+
#
|
162
|
+
def describe_route_tables(*list_and_options)
|
163
|
+
describe_resources_with_list_and_options('DescribeRouteTables', 'RouteTableId', QEc2DescribeRouteTablesParser, list_and_options)
|
164
|
+
rescue Exception
|
165
|
+
on_exception
|
166
|
+
end
|
167
|
+
|
168
|
+
# Creates a new route table within a VPC. After you create a new route table, you can add routes and associate the table with a subne
|
169
|
+
#
|
170
|
+
# ec2.create_route_table("vpc-df80a6b6") #=>
|
171
|
+
# {:route_table_id=>"rtb-4331072a",
|
172
|
+
# :route_set=>
|
173
|
+
# [{:state=>"active",
|
174
|
+
# :destination_cidr_block=>"10.0.3.0/24",
|
175
|
+
# :gateway_id=>"local"}],
|
176
|
+
# :vpc_id=>"vpc-df80a6b6",
|
177
|
+
# :association_set=>[],
|
178
|
+
# :tags=>{}}
|
179
|
+
#
|
180
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-CreateRouteTable.html
|
181
|
+
#
|
182
|
+
def create_route_table(vpc_id)
|
183
|
+
link = generate_request("CreateRouteTable", 'VpcId' => vpc_id )
|
184
|
+
request_info(link, QEc2DescribeRouteTablesParser::new(:logger => @logger)).first
|
185
|
+
rescue Exception
|
186
|
+
on_exception
|
187
|
+
end
|
188
|
+
|
189
|
+
# Deletes a route table from a VPC.
|
190
|
+
# The route table must not be associated with a subnet. You can't delete the main route table.
|
191
|
+
#
|
192
|
+
# ec2.delete_route_table("rtb-4331072a") #=> true
|
193
|
+
#
|
194
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DeleteRouteTable.html
|
195
|
+
def delete_route_table(route_table_id)
|
196
|
+
link = generate_request("DeleteRouteTable", 'RouteTableId' => route_table_id )
|
197
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
198
|
+
rescue Exception
|
199
|
+
on_exception
|
200
|
+
end
|
201
|
+
|
202
|
+
# Associates a subnet with a route table. The subnet and route table must be in the same VPC.
|
203
|
+
# This association causes traffic originating from the subnet to be routed according to the routes in
|
204
|
+
# the route table. The action returns an association ID, which you need if you want to disassociate
|
205
|
+
# the route table from the subnet later. A route table can be associated with multiple subnets.
|
206
|
+
#
|
207
|
+
# ec2.associate_route_table("rtb-be3006d7", "subnet-b95f76d0") #=> true
|
208
|
+
#
|
209
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-AssociateRouteTable.html
|
210
|
+
#
|
211
|
+
def associate_route_table(route_table_id, subnet_id)
|
212
|
+
request_hash = { 'RouteTableId' => route_table_id,
|
213
|
+
'SubnetId' => subnet_id }
|
214
|
+
link = generate_request("AssociateRouteTable", request_hash)
|
215
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
216
|
+
rescue Exception
|
217
|
+
on_exception
|
218
|
+
end
|
219
|
+
|
220
|
+
# Disassociates a subnet from a route table.
|
221
|
+
#
|
222
|
+
# ec2.disassociate_route_table(route_table_association_id) #=> true
|
223
|
+
#
|
224
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DisassociateRouteTable.html
|
225
|
+
#
|
226
|
+
def disassociate_route_table(route_table_association_id)
|
227
|
+
link = generate_request("DisassociateRouteTable", 'AssociationId' => route_table_association_id )
|
228
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
229
|
+
rescue Exception
|
230
|
+
on_exception
|
231
|
+
end
|
232
|
+
|
233
|
+
# Changes the route table associated with a given subnet in a VPC. After you execute this action, the subnet
|
234
|
+
# uses the routes in the new route table it's associated with.
|
235
|
+
# You can also use this action to change which table is the main route table in the VPC. You just specify
|
236
|
+
# the main route table's association ID and the route table that you want to be the new main route table.
|
237
|
+
#
|
238
|
+
# ec2.replace_route_table_association("rtb-be3006d7", "rtbassoc-a02610c9") #=> true
|
239
|
+
#
|
240
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ReplaceRouteTableAssociation.html
|
241
|
+
#
|
242
|
+
def replace_route_table_association(route_table_id, route_table_association_id)
|
243
|
+
request_hash = { 'RouteTableId' => route_table_id,
|
244
|
+
'AssociationId' => route_table_association_id }
|
245
|
+
link = generate_request("ReplaceRouteTableAssociation", request_hash)
|
246
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
247
|
+
rescue Exception
|
248
|
+
on_exception
|
249
|
+
end
|
250
|
+
|
251
|
+
#---------------------
|
252
|
+
# Routes
|
253
|
+
#---------------------
|
254
|
+
|
255
|
+
# Creates a new route in a route table within a VPC. The route's target can be either a gateway attached to
|
256
|
+
# the VPC or a NAT instance in the VPC.
|
257
|
+
# Options: :gateway_id, :instance_id
|
258
|
+
#
|
259
|
+
# ec2.create_route("rtb-be3006d7", "0.0.0.1/32", :gateway_id => 'igw-6585c10c') #=> true
|
260
|
+
#
|
261
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateRoute.html
|
262
|
+
#
|
263
|
+
def create_route(route_table_id, destination_cidr_block, options = {})
|
264
|
+
request_hash = { 'RouteTableId' => route_table_id,
|
265
|
+
'DestinationCidrBlock' => destination_cidr_block }
|
266
|
+
request_hash['GatewayId'] = options[:gateway_id] unless options[:gateway_id].right_blank?
|
267
|
+
request_hash['InstanceId'] = options[:instance_id] unless options[:instance_id].right_blank?
|
268
|
+
link = generate_request("CreateRoute", request_hash)
|
269
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
270
|
+
rescue Exception
|
271
|
+
on_exception
|
272
|
+
end
|
273
|
+
|
274
|
+
# Deletes a route from a route table in a VPC.
|
275
|
+
#
|
276
|
+
# ec2.delete_route("rtb-be3006d7", "0.0.0.1/32") #=> true
|
277
|
+
#
|
278
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteRoute.html
|
279
|
+
#
|
280
|
+
def delete_route(route_table_id, destination_cidr_block)
|
281
|
+
link = generate_request("DeleteRoute", 'RouteTableId' => route_table_id,
|
282
|
+
'DestinationCidrBlock' => destination_cidr_block )
|
283
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
284
|
+
rescue Exception
|
285
|
+
on_exception
|
286
|
+
end
|
287
|
+
|
288
|
+
# Replaces an existing route within a route table in a VPC
|
289
|
+
# Options: :gateway_id, :instance_id
|
290
|
+
#
|
291
|
+
# ec2.replace_route("rtb-be3006d7", "0.0.0.2/32", :gateway_id => 'igw-6585c10c') #=> true
|
292
|
+
#
|
293
|
+
# P.S. http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ReplaceRoute.html
|
294
|
+
#
|
295
|
+
def replace_route(route_table_id, destination_cidr_block, options = {})
|
296
|
+
request_hash = { 'RouteTableId' => route_table_id,
|
297
|
+
'DestinationCidrBlock' => destination_cidr_block }
|
298
|
+
request_hash['GatewayId'] = options[:gateway_id] unless options[:gateway_id].right_blank?
|
299
|
+
request_hash['InstanceId'] = options[:instance_id] unless options[:instance_id].right_blank?
|
300
|
+
link = generate_request("ReplaceRoute", request_hash)
|
301
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
302
|
+
rescue Exception
|
303
|
+
on_exception
|
304
|
+
end
|
305
|
+
|
306
|
+
#---------------------
|
307
|
+
# InternetGateways
|
308
|
+
#---------------------
|
309
|
+
|
310
|
+
class QEc2DescribeInternetGatewaysParser < RightAWSParser #:nodoc:
|
311
|
+
def tagstart(name, attributes)
|
312
|
+
case full_tag_name
|
313
|
+
when %r{/(internetGatewaySet/item|internetGateway)$} then @item = { :tags => {} }
|
314
|
+
when %r{/tagSet/item$} then @aws_tag = {}
|
315
|
+
end
|
316
|
+
end
|
317
|
+
def tagend(name)
|
318
|
+
case full_tag_name
|
319
|
+
# item
|
320
|
+
when %r{/(internetGatewaySet/item|internetGateway)$} then @result << @item
|
321
|
+
when %r{/internetGatewayId$} then @item[:internet_gateway_id] = @text
|
322
|
+
when %r{/vpcId$} then @item[:vpc_id] = @text
|
323
|
+
when %r{/state$} then @item[:state] = @text
|
324
|
+
# tags
|
325
|
+
when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
|
326
|
+
when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
|
327
|
+
when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
|
328
|
+
end
|
329
|
+
end
|
330
|
+
def reset
|
331
|
+
@result = []
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
#---------------------
|
336
|
+
# Routes
|
337
|
+
#---------------------
|
338
|
+
|
339
|
+
class QEc2DescribeRouteTablesParser < RightAWSParser #:nodoc:
|
340
|
+
def tagstart(name, attributes)
|
341
|
+
case full_tag_name
|
342
|
+
when %r{/(routeTableSet/item|routeTable)$}
|
343
|
+
@item = { :route_set => [],
|
344
|
+
:association_set => [],
|
345
|
+
:tags => {}}
|
346
|
+
when %r{/routeSet/item$} then @route_set = {}
|
347
|
+
when %r{/associationSet/item$} then @association_set = {}
|
348
|
+
end
|
349
|
+
end
|
350
|
+
def tagend(name)
|
351
|
+
case full_tag_name
|
352
|
+
# item
|
353
|
+
when %r{/(routeTableSet/item|routeTable)/routeTableId$} then @item[:route_table_id] = @text
|
354
|
+
when %r{/(routeTableSet/item|routeTable)/vpcId$} then @item[:vpc_id] = @text
|
355
|
+
when %r{/(routeTableSet/item|routeTable)$} then @result << @item
|
356
|
+
# route set
|
357
|
+
when %r{/routeSet/item/destinationCidrBlock$} then @route_set[:destination_cidr_block] = @text
|
358
|
+
when %r{/routeSet/item/gatewayId$} then @route_set[:gateway_id] = @text
|
359
|
+
when %r{/routeSet/item/instanceId$} then @route_set[:instance_id] = @text
|
360
|
+
when %r{/routeSet/item/state$} then @route_set[:state] = @text
|
361
|
+
when %r{/routeSet/item$} then @item[:route_set] << @route_set
|
362
|
+
# association set
|
363
|
+
when %r{/associationSet/item/routeTableId$} then @association_set[:route_table_id] = @text
|
364
|
+
when %r{/associationSet/item/routeTableAssociationId$} then @association_set[:route_table_association_id] = @text
|
365
|
+
when %r{/associationSet/item/subnetId$} then @association_set[:subnet_id] = @text
|
366
|
+
when %r{/associationSet/item/main} then @association_set[:main] = @text == 'true'
|
367
|
+
when %r{/associationSet/item$} then @item[:association_set] << @association_set
|
368
|
+
# tags
|
369
|
+
when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
|
370
|
+
when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
|
371
|
+
when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
|
372
|
+
end
|
373
|
+
end
|
374
|
+
def reset
|
375
|
+
@result = []
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2010 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
|
+
def describe_licenses(*license_ids)
|
29
|
+
link = generate_request("DescribeLicenses", amazonize_list('LicenseId', license_ids))
|
30
|
+
request_info(link, QEc2DescribeLicensesParser.new(:logger => @logger))
|
31
|
+
end
|
32
|
+
|
33
|
+
def activate_license(license_id, capacity)
|
34
|
+
link = generate_request("ActivateLicense", 'LicenseId' => license_id,
|
35
|
+
'Capacity' => capacity)
|
36
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
37
|
+
end
|
38
|
+
|
39
|
+
# def get_license_capacity(license_id)
|
40
|
+
# link = generate_request("GetLicenseCapacity", 'LicenseId' => license_id)
|
41
|
+
# request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
42
|
+
# end
|
43
|
+
|
44
|
+
def deactivate_license(license_id, capacity)
|
45
|
+
link = generate_request("DeactivateLicense", 'LicenseId' => license_id,
|
46
|
+
'Capacity' => capacity)
|
47
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------
|
51
|
+
# PARSERS: Images
|
52
|
+
#-----------------------------------------------------------------
|
53
|
+
|
54
|
+
class QEc2DescribeLicensesParser < RightAWSParser #:nodoc:
|
55
|
+
def tagstart(name, attributes)
|
56
|
+
case full_tag_name
|
57
|
+
when %r{/licenseSet/item$} then @item = { :capacities => [] }
|
58
|
+
when %r{/capacitySet/item$} then @capacity_item = {}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
def tagend(name)
|
62
|
+
case name
|
63
|
+
when 'licenseId' then @item[:license_id] = @text
|
64
|
+
when 'type' then @item[:type] = @text
|
65
|
+
when 'pool' then @item[:pool] = @text
|
66
|
+
when 'capacity' then @capacity_item[:capacity] = @text.to_i
|
67
|
+
when 'instanceCapacity' then @capacity_item[:instance_capacity] = @text.to_i
|
68
|
+
when 'state' then @capacity_item[:state] = @text
|
69
|
+
when 'earliestAllowedDeactivationTime' then @capacity_item[:earliest_allowed_deactivation_time] = @text
|
70
|
+
else
|
71
|
+
case full_tag_name
|
72
|
+
when %r{/capacitySet/item$} then @item[:capacities] << @capacity_item
|
73
|
+
when %r{/licenseSet/item$} then @result << @item
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
def reset
|
78
|
+
@result = []
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|