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.
- data/History.txt +46 -1
- data/Manifest.txt +4 -0
- data/README.txt +0 -0
- data/Rakefile +0 -0
- data/lib/acf/right_acf_interface.rb +105 -33
- data/lib/acf/right_acf_origin_access_identities.rb +230 -0
- data/lib/acf/right_acf_streaming_interface.rb +236 -0
- data/lib/acw/right_acw_interface.rb +3 -3
- data/lib/as/right_as_interface.rb +55 -46
- data/lib/awsbase/benchmark_fix.rb +0 -0
- data/lib/awsbase/right_awsbase.rb +71 -12
- data/lib/awsbase/support.rb +0 -0
- data/lib/ec2/right_ec2.rb +22 -244
- data/lib/ec2/right_ec2_ebs.rb +23 -22
- data/lib/ec2/right_ec2_images.rb +21 -21
- data/lib/ec2/right_ec2_instances.rb +49 -54
- data/lib/ec2/right_ec2_reserved_instances.rb +7 -4
- data/lib/ec2/right_ec2_security_groups.rb +277 -0
- data/lib/ec2/right_ec2_spot_instances.rb +399 -0
- data/lib/ec2/right_ec2_vpc.rb +4 -4
- data/lib/elb/right_elb_interface.rb +112 -23
- data/lib/rds/right_rds_interface.rb +4 -4
- data/lib/right_aws.rb +8 -4
- data/lib/s3/right_s3.rb +25 -1
- data/lib/s3/right_s3_interface.rb +6 -2
- data/lib/sdb/active_sdb.rb +202 -10
- data/lib/sdb/right_sdb_interface.rb +61 -11
- data/lib/sqs/right_sqs.rb +0 -0
- data/lib/sqs/right_sqs_gen2.rb +0 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +5 -4
- data/lib/sqs/right_sqs_interface.rb +0 -0
- data/test/acf/test_helper.rb +0 -0
- data/test/acf/test_right_acf.rb +10 -18
- data/test/ec2/test_helper.rb +0 -0
- data/test/ec2/test_right_ec2.rb +0 -0
- data/test/http_connection.rb +0 -0
- data/test/s3/test_helper.rb +0 -0
- data/test/s3/test_right_s3.rb +10 -8
- data/test/s3/test_right_s3_stubbed.rb +6 -4
- data/test/sdb/test_active_sdb.rb +70 -12
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sdb/test_helper.rb +0 -0
- data/test/sdb/test_right_sdb.rb +13 -7
- data/test/sqs/test_helper.rb +0 -0
- data/test/sqs/test_right_sqs.rb +0 -0
- data/test/sqs/test_right_sqs_gen2.rb +21 -33
- data/test/test_credentials.rb +0 -0
- data/test/ts_right_aws.rb +0 -0
- metadata +16 -4
@@ -0,0 +1,399 @@
|
|
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
|
+
#-----------------------------------------------------------------
|
29
|
+
# Spot Instances
|
30
|
+
#-----------------------------------------------------------------
|
31
|
+
|
32
|
+
# Describe Spot Price history.
|
33
|
+
# Options: :start_time, :end_time, instance_types, product_description
|
34
|
+
#
|
35
|
+
# ec2.describe_spot_price_history #=>
|
36
|
+
# [{:spot_price=>0.054,
|
37
|
+
# :timestamp=>"2009-12-07T12:12:58.000Z",
|
38
|
+
# :product_description=>"Windows",
|
39
|
+
# :instance_type=>"m1.small"},
|
40
|
+
# {:spot_price=>0.06,
|
41
|
+
# :timestamp=>"2009-12-07T12:18:32.000Z",
|
42
|
+
# :product_description=>"Linux/UNIX",
|
43
|
+
# :instance_type=>"c1.medium"},
|
44
|
+
# {:spot_price=>0.198,
|
45
|
+
# :timestamp=>"2009-12-07T12:58:00.000Z",
|
46
|
+
# :product_description=>"Windows",
|
47
|
+
# :instance_type=>"m1.large"},
|
48
|
+
# {:spot_price=>0.028,
|
49
|
+
# :timestamp=>"2009-12-07T13:48:50.000Z",
|
50
|
+
# :product_description=>"Linux/UNIX",
|
51
|
+
# :instance_type=>"m1.small"}, ... ]
|
52
|
+
#
|
53
|
+
# ec2.describe_spot_price_history(:start_time => 1.day.ago,
|
54
|
+
# :end_time => 10.minutes.ago,
|
55
|
+
# :instance_types => ["c1.medium", "m1.small"],
|
56
|
+
# :product_description => "Linux/UNIX" ) #=>
|
57
|
+
# [{:product_description=>"Linux/UNIX",
|
58
|
+
# :timestamp=>"2010-02-04T05:44:36.000Z",
|
59
|
+
# :spot_price=>0.031,
|
60
|
+
# :instance_type=>"m1.small"},
|
61
|
+
# {:product_description=>"Linux/UNIX",
|
62
|
+
# :timestamp=>"2010-02-04T17:56:25.000Z",
|
63
|
+
# :spot_price=>0.058,
|
64
|
+
# :instance_type=>"c1.medium"}, ... ]
|
65
|
+
#
|
66
|
+
def describe_spot_price_history(options={})
|
67
|
+
options = options.dup
|
68
|
+
request_hash = {}
|
69
|
+
request_hash['StartTime'] = AwsUtils::utc_iso8601(options[:start_time]) unless options[:start_time].blank?
|
70
|
+
request_hash['EndTime'] = AwsUtils::utc_iso8601(options[:end_time]) unless options[:end_time].blank?
|
71
|
+
request_hash['ProductDescription'] = options[:product_description] unless options[:product_description].blank?
|
72
|
+
request_hash.merge!(amazonize_list('InstanceType', Array(options[:instance_types]))) unless options[:instance_types].blank?
|
73
|
+
link = generate_request("DescribeSpotPriceHistory", request_hash)
|
74
|
+
request_info(link, QEc2DescribeSpotPriceHistoryParser.new)
|
75
|
+
rescue Exception
|
76
|
+
on_exception
|
77
|
+
end
|
78
|
+
|
79
|
+
# Describe Spot Instance requests.
|
80
|
+
#
|
81
|
+
# ec2.describe_spot_instance_requests #=>
|
82
|
+
# [{:type=>"one-time",
|
83
|
+
# :create_time=>"2010-03-10T10:30:32.000Z",
|
84
|
+
# :instance_type=>"c1.medium",
|
85
|
+
# :state=>"cancelled",
|
86
|
+
# :groups=>["default"],
|
87
|
+
# :product_description=>"Linux/UNIX",
|
88
|
+
# :spot_instance_request_id=>"sir-bfa06804",
|
89
|
+
# :image_id=>"ami-08f41161",
|
90
|
+
# :spot_price=>0.01,
|
91
|
+
# :monitoring_enabled=>false},
|
92
|
+
# {:type=>"one-time",
|
93
|
+
# :create_time=>"2010-03-10T10:33:29.000Z",
|
94
|
+
# :instance_type=>"c1.medium",
|
95
|
+
# :state=>"open",
|
96
|
+
# :groups=>["default", "33"],
|
97
|
+
# :product_description=>"Linux/UNIX",
|
98
|
+
# :spot_instance_request_id=>"sir-b1713a03",
|
99
|
+
# :image_id=>"ami-08f41161",
|
100
|
+
# :spot_price=>0.01,
|
101
|
+
# :monitoring_enabled=>false,
|
102
|
+
# :key_name=>"tim"},
|
103
|
+
# {:type=>"one-time",
|
104
|
+
# :instance_id=>"i-c516ceae",
|
105
|
+
# :create_time=>"2010-03-10T10:43:48.000Z",
|
106
|
+
# :instance_type=>"c1.medium",
|
107
|
+
# :state=>"active",
|
108
|
+
# :groups=>["default", "33"],
|
109
|
+
# :product_description=>"Linux/UNIX",
|
110
|
+
# :spot_instance_request_id=>"sir-5eb6c604",
|
111
|
+
# :image_id=>"ami-08f41161",
|
112
|
+
# :spot_price=>0.2,
|
113
|
+
# :monitoring_enabled=>false,
|
114
|
+
# :key_name=>"tim"}]
|
115
|
+
#
|
116
|
+
def describe_spot_instance_requests(*spot_instance_request_ids)
|
117
|
+
link = generate_request("DescribeSpotInstanceRequests", amazonize_list('SpotInstanceRequestId', spot_instance_request_ids.flatten))
|
118
|
+
request_info(link, QEc2DescribeSpotInstanceParser.new(:logger => @logger))
|
119
|
+
end
|
120
|
+
|
121
|
+
# Create a Spot Instance request.
|
122
|
+
#
|
123
|
+
# Mandatory params: :image_id, :spot_price, :instance_type
|
124
|
+
# Optional params: :valid_from, :valid_until, :instance_count, :type, :launch_group,
|
125
|
+
# :availability_zone_group, :key_name, :user_data, :addressing_type, :kernel_id,
|
126
|
+
# :ramdisk_id, :subnet_id, :availability_zone, :monitoring_enabled, :groups,
|
127
|
+
# :block_device_mappings
|
128
|
+
#
|
129
|
+
# ec2.request_spot_instances(
|
130
|
+
# :image_id => 'ami-08f41161',
|
131
|
+
# :spot_price => 0.01,
|
132
|
+
# :key_name => 'tim',
|
133
|
+
# :instance_count => 2,
|
134
|
+
# :groups => ['33','default'],
|
135
|
+
# :instance_type => 'c1.medium') #=>
|
136
|
+
#
|
137
|
+
# [{:product_description=>"Linux/UNIX",
|
138
|
+
# :type=>"one-time",
|
139
|
+
# :spot_instance_requestId=>"sir-7a893003",
|
140
|
+
# :monitoring_enabled=>false,
|
141
|
+
# :image_id=>"ami-08f41161",
|
142
|
+
# :state=>"open",
|
143
|
+
# :spot_price=>0.01,
|
144
|
+
# :groups=>["default", "33"],
|
145
|
+
# :key_name=>"tim",
|
146
|
+
# :create_time=>"2010-03-10T10:33:09.000Z",
|
147
|
+
# :instance_type=>"c1.medium"},
|
148
|
+
# {:product_description=>"Linux/UNIX",
|
149
|
+
# :type=>"one-time",
|
150
|
+
# :spot_instance_requestId=>"sir-13dc9a03",
|
151
|
+
# :monitoring_enabled=>false,
|
152
|
+
# :image_id=>"ami-08f41161",
|
153
|
+
# :state=>"open",
|
154
|
+
# :spot_price=>0.01,
|
155
|
+
# :groups=>["default", "33"],
|
156
|
+
# :key_name=>"tim",
|
157
|
+
# :create_time=>"2010-03-10T10:33:09.000Z",
|
158
|
+
# :instance_type=>"c1.medium"}]
|
159
|
+
#
|
160
|
+
# ec2.request_spot_instances(
|
161
|
+
# :image_id => 'ami-08f41161',
|
162
|
+
# :spot_price => 0.01,
|
163
|
+
# :instance_type => 'm1.small',
|
164
|
+
# :valid_from => 10.minutes.since,
|
165
|
+
# :valid_until => 1.hour.since,
|
166
|
+
# :instance_count => 1,
|
167
|
+
# :key_name => 'tim',
|
168
|
+
# :groups => ['33','default'],
|
169
|
+
# :availability_zone => 'us-east-1a',
|
170
|
+
# :monitoring_enabled => true,
|
171
|
+
# :launch_group => 'lg1',
|
172
|
+
# :availability_zone_group => 'azg1',
|
173
|
+
# :block_device_mappings => [ { :device_name => '/dev/sdk',
|
174
|
+
# :ebs_snapshot_id => 'snap-145cbc7d',
|
175
|
+
# :ebs_delete_on_termination => true,
|
176
|
+
# :ebs_volume_size => 3,
|
177
|
+
# :virtual_name => 'ephemeral2'
|
178
|
+
# } ] ) #=>
|
179
|
+
#
|
180
|
+
# [{:monitoring_enabled=>true,
|
181
|
+
# :type=>"one-time",
|
182
|
+
# :image_id=>"ami-08f41161",
|
183
|
+
# :launch_group=>"lg1",
|
184
|
+
# :state=>"open",
|
185
|
+
# :valid_until=>"2010-02-05T19:13:44.000Z",
|
186
|
+
# :create_time=>"2010-02-05T18:13:46.000Z",
|
187
|
+
# :availability_zone_group=>"azg1",
|
188
|
+
# :spot_price=>0.01,
|
189
|
+
# :block_device_mappings=>
|
190
|
+
# [{:ebs_delete_on_termination=>true,
|
191
|
+
# :ebs_volume_size=>3,
|
192
|
+
# :virtual_name=>"ephemeral2",
|
193
|
+
# :device_name=>"/dev/sdk",
|
194
|
+
# :ebs_snapshot_id=>"snap-145cbc7d"}],
|
195
|
+
# :instance_type=>"m1.small",
|
196
|
+
# :groups=>["default", "33"],
|
197
|
+
# :product_description=>"Linux/UNIX",
|
198
|
+
# :key_name=>"tim",
|
199
|
+
# :valid_from=>"2010-02-05T18:23:44.000Z",
|
200
|
+
# :availability_zone=>"us-east-1a",
|
201
|
+
# :spot_instance_request_id=>"sir-32da8a03"}]
|
202
|
+
#
|
203
|
+
def request_spot_instances(options)
|
204
|
+
options = options.dup
|
205
|
+
request_hash = { 'SpotPrice' => options[:spot_price],
|
206
|
+
'LaunchSpecification.ImageId' => options[:image_id],
|
207
|
+
'LaunchSpecification.InstanceType' => options[:instance_type]}
|
208
|
+
request_hash['ValidFrom'] = AwsUtils::utc_iso8601(options[:valid_from]) unless options[:valid_from].blank?
|
209
|
+
request_hash['ValidUntil'] = AwsUtils::utc_iso8601(options[:valid_until]) unless options[:valid_until].blank?
|
210
|
+
request_hash['InstanceCount'] = options[:instance_count] unless options[:instance_count].blank?
|
211
|
+
request_hash['Type'] = options[:type] unless options[:type].blank?
|
212
|
+
request_hash['LaunchGroup'] = options[:launch_group] unless options[:launch_group].blank?
|
213
|
+
request_hash['AvailabilityZoneGroup'] = options[:availability_zone_group] unless options[:availability_zone_group].blank?
|
214
|
+
request_hash['LaunchSpecification.KeyName'] = options[:key_name] unless options[:key_name].blank?
|
215
|
+
request_hash['LaunchSpecification.AddressingType'] = options[:addressing_type] unless options[:addressing_type].blank?
|
216
|
+
request_hash['LaunchSpecification.KernelId'] = options[:kernel_id] unless options[:kernel_id].blank?
|
217
|
+
request_hash['LaunchSpecification.RamdiskId'] = options[:ramdisk_id] unless options[:ramdisk_id].blank?
|
218
|
+
request_hash['LaunchSpecification.SubnetId'] = options[:subnet_id] unless options[:subnet_id].blank?
|
219
|
+
request_hash['LaunchSpecification.Placement.AvailabilityZone'] = options[:availability_zone] unless options[:availability_zone].blank?
|
220
|
+
request_hash['LaunchSpecification.Monitoring.Enabled'] = options[:monitoring_enabled] unless options[:monitoring_enabled].blank?
|
221
|
+
request_hash.merge!(amazonize_list('LaunchSpecification.SecurityGroup', options[:groups])) unless options[:groups].blank?
|
222
|
+
request_hash.merge!(amazonize_block_device_mappings(options[:block_device_mappings], 'LaunchSpecification.BlockDeviceMapping'))
|
223
|
+
unless options[:user_data].blank?
|
224
|
+
# See RightAws::Ec2#run_instances
|
225
|
+
options[:user_data].strip!
|
226
|
+
request_hash['LaunchSpecification.UserData'] = Base64.encode64(options[:user_data]).delete("\n") unless options[:user_data].blank?
|
227
|
+
end
|
228
|
+
link = generate_request("RequestSpotInstances", request_hash)
|
229
|
+
request_info(link, QEc2DescribeSpotInstanceParser.new(:logger => @logger))
|
230
|
+
end
|
231
|
+
|
232
|
+
# Cancel one or more Spot Instance requests.
|
233
|
+
#
|
234
|
+
# ec2.cancel_spot_instance_requests('sir-60662c03',"sir-d3c96e04", "sir-4fa8d804","sir-6992ce04") #=>
|
235
|
+
# [{:state=>"cancelled", :spot_instance_request_id=>"sir-60662c03"},
|
236
|
+
# {:state=>"cancelled", :spot_instance_request_id=>"sir-6992ce04"},
|
237
|
+
# {:state=>"cancelled", :spot_instance_request_id=>"sir-4fa8d804"},
|
238
|
+
# {:state=>"cancelled", :spot_instance_request_id=>"sir-d3c96e04"}]
|
239
|
+
#
|
240
|
+
def cancel_spot_instance_requests(*spot_instance_request_ids)
|
241
|
+
link = generate_request("CancelSpotInstanceRequests", amazonize_list('SpotInstanceRequestId', spot_instance_request_ids.flatten))
|
242
|
+
request_info(link, QEc2CancelSpotInstanceParser.new(:logger => @logger))
|
243
|
+
end
|
244
|
+
|
245
|
+
# Create the data feed for Spot Instances
|
246
|
+
# (Enables to view Spot Instance usage logs)
|
247
|
+
#
|
248
|
+
# ec2.create_spot_datafeed_subscription('bucket-for-konstantin-eu', 'splogs/') #=>
|
249
|
+
# { :owner_id=>"826693181925",
|
250
|
+
# :bucket=>"bucket-for-konstantin-eu",
|
251
|
+
# :prefix=>"splogs/",
|
252
|
+
# :state=>"Active"}
|
253
|
+
#
|
254
|
+
def create_spot_datafeed_subscription(bucket, prefix=nil)
|
255
|
+
request_hash = { 'Bucket' => bucket }
|
256
|
+
request_hash['Prefix'] = prefix unless prefix.blank?
|
257
|
+
link = generate_request("CreateSpotDatafeedSubscription", request_hash)
|
258
|
+
request_info(link, QEc2DescribeSpotDatafeedSubscriptionParser.new(:logger => @logger))
|
259
|
+
end
|
260
|
+
|
261
|
+
# Describe the data feed for Spot Instances.
|
262
|
+
#
|
263
|
+
# ec2.describe_spot_datafeed_subscription #=>
|
264
|
+
# { :owner_id=>"826693181925",
|
265
|
+
# :bucket=>"bucket-for-konstantin-eu",
|
266
|
+
# :prefix=>"splogs/",
|
267
|
+
# :state=>"Active"}
|
268
|
+
#
|
269
|
+
def describe_spot_datafeed_subscription
|
270
|
+
link = generate_request("DescribeSpotDatafeedSubscription")
|
271
|
+
request_info(link, QEc2DescribeSpotDatafeedSubscriptionParser.new(:logger => @logger))
|
272
|
+
end
|
273
|
+
|
274
|
+
# Delete the data feed for Spot Instances.
|
275
|
+
#
|
276
|
+
# ec2.delete_spot_datafeed_subscription #=> true
|
277
|
+
#
|
278
|
+
def delete_spot_datafeed_subscription()
|
279
|
+
link = generate_request("DeleteSpotDatafeedSubscription")
|
280
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
281
|
+
end
|
282
|
+
|
283
|
+
#-----------------------------------------------------------------
|
284
|
+
# PARSERS: Spot Instances
|
285
|
+
#-----------------------------------------------------------------
|
286
|
+
|
287
|
+
class QEc2DescribeSpotPriceHistoryParser < RightAWSParser #:nodoc:
|
288
|
+
def tagstart(name, attributes)
|
289
|
+
@item = {} if name == 'item'
|
290
|
+
end
|
291
|
+
def tagend(name)
|
292
|
+
case name
|
293
|
+
when 'instanceType' then @item[:instance_type] = @text
|
294
|
+
when 'productDescription' then @item[:product_description] = @text
|
295
|
+
when 'spotPrice' then @item[:spot_price] = @text.to_f
|
296
|
+
when 'timestamp' then @item[:timestamp] = @text
|
297
|
+
when 'item' then @result << @item
|
298
|
+
end
|
299
|
+
end
|
300
|
+
def reset
|
301
|
+
@result = []
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
class QEc2DescribeSpotInstanceParser < RightAWSParser #:nodoc:
|
306
|
+
def tagstart(name, attributes)
|
307
|
+
case full_tag_name
|
308
|
+
when %r{spotInstanceRequestSet/item$}
|
309
|
+
@item = {}
|
310
|
+
when %r{/blockDeviceMapping/item$}
|
311
|
+
@item[:block_device_mappings] ||= []
|
312
|
+
@block_device_mapping = {}
|
313
|
+
end
|
314
|
+
end
|
315
|
+
def tagend(name)
|
316
|
+
case name
|
317
|
+
when 'spotInstanceRequestId' then @item[:spot_instance_request_id]= @text
|
318
|
+
when 'spotPrice' then @item[:spot_price] = @text.to_f
|
319
|
+
when 'type' then @item[:type] = @text
|
320
|
+
when 'state' then @item[:state] = @text
|
321
|
+
when 'code' then @item[:fault_code] = @text
|
322
|
+
when 'message' then @item[:fault_message] = @text
|
323
|
+
when 'validFrom' then @item[:valid_from] = @text
|
324
|
+
when 'validUntil' then @item[:valid_until] = @text
|
325
|
+
when 'launchGroup' then @item[:launch_group] = @text
|
326
|
+
when 'availabilityZoneGroup' then @item[:availability_zone_group] = @text
|
327
|
+
when 'imageId' then @item[:image_id] = @text
|
328
|
+
when 'keyName' then @item[:key_name] = @text
|
329
|
+
when 'userData' then @item[:userData] = @text
|
330
|
+
when 'data' then @item[:data] = @text
|
331
|
+
when 'addressingType' then @item[:addressing_type] = @text
|
332
|
+
when 'instanceType' then @item[:instance_type] = @text
|
333
|
+
when 'availabilityZone' then @item[:availability_zone] = @text
|
334
|
+
when 'kernelId' then @item[:kernel_id] = @text
|
335
|
+
when 'ramdiskId' then @item[:ramdisk_id] = @text
|
336
|
+
when 'subnetId' then @item[:subnet_id] = @text
|
337
|
+
when 'instanceId' then @item[:instance_id] = @text
|
338
|
+
when 'createTime' then @item[:create_time] = @text
|
339
|
+
when 'productDescription' then @item[:product_description] = @text
|
340
|
+
when 'groupId' then (@item[:groups] ||= []) << @text
|
341
|
+
else
|
342
|
+
case full_tag_name
|
343
|
+
when %r{monitoring/enabled$}
|
344
|
+
@item[:monitoring_enabled] = @text == 'true'
|
345
|
+
when %r{/blockDeviceMapping/item} # no trailing $
|
346
|
+
case name
|
347
|
+
when 'deviceName' then @block_device_mapping[:device_name] = @text
|
348
|
+
when 'virtualName' then @block_device_mapping[:virtual_name] = @text
|
349
|
+
when 'volumeSize' then @block_device_mapping[:ebs_volume_size] = @text.to_i
|
350
|
+
when 'snapshotId' then @block_device_mapping[:ebs_snapshot_id] = @text
|
351
|
+
when 'deleteOnTermination' then @block_device_mapping[:ebs_delete_on_termination] = @text == 'true' ? true : false
|
352
|
+
when 'item' then @item[:block_device_mappings] << @block_device_mapping
|
353
|
+
end
|
354
|
+
when %r{spotInstanceRequestSet/item$}
|
355
|
+
@result << @item
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
def reset
|
360
|
+
@result = []
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
class QEc2CancelSpotInstanceParser < RightAWSParser #:nodoc:
|
365
|
+
def tagstart(name, attributes)
|
366
|
+
@item = {} if name == 'item'
|
367
|
+
end
|
368
|
+
def tagend(name)
|
369
|
+
case name
|
370
|
+
when 'spotInstanceRequestId' then @item[:spot_instance_request_id] = @text
|
371
|
+
when 'state' then @item[:state] = @text
|
372
|
+
when 'item' then @result << @item
|
373
|
+
end
|
374
|
+
end
|
375
|
+
def reset
|
376
|
+
@result = []
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
class QEc2DescribeSpotDatafeedSubscriptionParser < RightAWSParser #:nodoc:
|
381
|
+
def tagend(name)
|
382
|
+
case name
|
383
|
+
when 'ownerId' then @result[:owner_id] = @text
|
384
|
+
when 'bucket' then @result[:bucket] = @text
|
385
|
+
when 'prefix' then @result[:prefix] = @text
|
386
|
+
when 'state' then @result[:state] = @text
|
387
|
+
when 'fault' then @result[:fault] = @text
|
388
|
+
when 'code' then @result[:code] = @text
|
389
|
+
when 'message' then @result[:message] = @text
|
390
|
+
end
|
391
|
+
end
|
392
|
+
def reset
|
393
|
+
@result = {}
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
end
|
398
|
+
|
399
|
+
end
|
data/lib/ec2/right_ec2_vpc.rb
CHANGED
@@ -27,11 +27,11 @@ module RightAws
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
def vpc__split_list_and_filters(params) # :nodoc:
|
31
|
-
params = params.
|
30
|
+
def vpc__split_list_and_filters(*params) # :nodoc:
|
31
|
+
params = params.flatten
|
32
32
|
filters = params.last.is_a?(Hash) ? params.pop : {}
|
33
33
|
# Make values to be arrays.
|
34
|
-
filters.each{|key, values| filters[key] = values
|
34
|
+
filters.each{|key, values| filters[key] = Array(values) }
|
35
35
|
[params, filters]
|
36
36
|
end
|
37
37
|
|
@@ -176,7 +176,7 @@ module RightAws
|
|
176
176
|
# {"netbios-node-type"=>["1"], "domain-name"=>["my.awesomesite.ru"]}}
|
177
177
|
#
|
178
178
|
def create_dhcp_options(dhcp_configuration)
|
179
|
-
dhcp_configuration.each{ |key, values| dhcp_configuration[key] = values
|
179
|
+
dhcp_configuration.each{ |key, values| dhcp_configuration[key] = Array(values) }
|
180
180
|
request_hash = amazonize_list(['DhcpConfiguration.?.Key','DhcpConfiguration.?.Value.?'], dhcp_configuration)
|
181
181
|
link = generate_request("CreateDhcpOptions", request_hash)
|
182
182
|
request_info(link, QEc2DescribeDhcpOptionsParser.new(:logger => @logger)).first
|
@@ -62,7 +62,7 @@ module RightAws
|
|
62
62
|
include RightAwsBaseInterface
|
63
63
|
|
64
64
|
# Amazon ELB API version being used
|
65
|
-
API_VERSION = "2009-
|
65
|
+
API_VERSION = "2009-11-25"
|
66
66
|
DEFAULT_HOST = "elasticloadbalancing.amazonaws.com"
|
67
67
|
DEFAULT_PATH = '/'
|
68
68
|
DEFAULT_PROTOCOL = 'https'
|
@@ -128,10 +128,40 @@ module RightAws
|
|
128
128
|
# :listeners =>
|
129
129
|
# [ { :protocol => "HTTP", :load_balancer_port => "80", :instance_port => "80" },
|
130
130
|
# { :protocol => "TCP", :load_balancer_port => "443", :instance_port => "443" } ],
|
131
|
-
# :created_time =>
|
131
|
+
# :created_time => "2009-05-27T11:59:11.000Z",
|
132
132
|
# :dns_name => "test-kd1-1519253964.us-east-1.elb.amazonaws.com",
|
133
133
|
# :instances => [] } ]
|
134
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
|
+
#
|
135
165
|
def describe_load_balancers(*load_balancers)
|
136
166
|
load_balancers = load_balancers.flatten.compact
|
137
167
|
request_hash = amazonize_list("LoadBalancerNames.member", load_balancers)
|
@@ -151,7 +181,7 @@ module RightAws
|
|
151
181
|
def create_load_balancer(load_balancer_name, availability_zones=[], listeners=[])
|
152
182
|
request_hash = { 'LoadBalancerName' => load_balancer_name }
|
153
183
|
# merge zones
|
154
|
-
request_hash.merge!( amazonize_list("AvailabilityZones.member", availability_zones
|
184
|
+
request_hash.merge!( amazonize_list("AvailabilityZones.member", availability_zones) )
|
155
185
|
# merge listeners
|
156
186
|
if listeners.blank?
|
157
187
|
listeners = { :protocol => :http,
|
@@ -277,28 +307,76 @@ module RightAws
|
|
277
307
|
request_info(link, InstancesWithLoadBalancerParser.new(:logger => @logger))
|
278
308
|
end
|
279
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
|
+
|
280
356
|
#-----------------------------------------------------------------
|
281
357
|
# PARSERS: Load Balancers
|
282
358
|
#-----------------------------------------------------------------
|
283
359
|
|
284
360
|
class DescribeLoadBalancersParser < RightAWSParser #:nodoc:
|
285
361
|
def tagstart(name, attributes)
|
286
|
-
case
|
287
|
-
when
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
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 = {}
|
295
373
|
end
|
296
374
|
end
|
297
375
|
def tagend(name)
|
298
376
|
case name
|
299
377
|
when 'LoadBalancerName' then @item[:load_balancer_name] = @text
|
300
378
|
when 'DNSName' then @item[:dns_name] = @text
|
301
|
-
when 'CreatedTime' then @item[:created_time] =
|
379
|
+
when 'CreatedTime' then @item[:created_time] = @text
|
302
380
|
when 'Interval' then @item[:health_check][:interval] = @text.to_i
|
303
381
|
when 'Target' then @item[:health_check][:target] = @text
|
304
382
|
when 'HealthyThreshold' then @item[:health_check][:healthy_threshold] = @text.to_i
|
@@ -307,20 +385,31 @@ module RightAws
|
|
307
385
|
when 'Protocol' then @listener[:protocol] = @text
|
308
386
|
when 'LoadBalancerPort' then @listener[:load_balancer_port] = @text
|
309
387
|
when 'InstancePort' then @listener[:instance_port] = @text
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
when
|
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
|
319
405
|
end
|
406
|
+
when %r{LoadBalancerDescriptions/member$}
|
407
|
+
@item[:availability_zones].sort!
|
408
|
+
@item[:instances].sort!
|
409
|
+
@result << @item
|
320
410
|
end
|
321
411
|
end
|
322
412
|
def reset
|
323
|
-
@p = 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions'
|
324
413
|
@result = []
|
325
414
|
end
|
326
415
|
end
|