aws 2.1.8 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/aws.rb +1 -1
- data/lib/elb/{right_elb_interface.rb → elb_interface.rb} +65 -7
- data/lib/right_aws.rb +1 -1
- data/lib/sdb/active_sdb.rb +2 -2
- data/test/elb/test_elb.rb +51 -0
- data/test/sdb/test_active_sdb.rb +37 -0
- metadata +4 -3
data/lib/aws.rb
CHANGED
@@ -128,7 +128,7 @@ module Aws
|
|
128
128
|
@logger.info("Registering Instances #{instance_ids.join(',')} with Load Balancer '#{name}'")
|
129
129
|
|
130
130
|
link = generate_request("RegisterInstancesWithLoadBalancer", params)
|
131
|
-
resp = request_info(link,
|
131
|
+
resp = request_info(link, QElbRegisterInstancesParser.new(:logger => @logger))
|
132
132
|
|
133
133
|
rescue Exception
|
134
134
|
on_exception
|
@@ -147,12 +147,13 @@ module Aws
|
|
147
147
|
@logger.info("Deregistering Instances #{instance_ids.join(',')} from Load Balancer '#{name}'")
|
148
148
|
|
149
149
|
link = generate_request("DeregisterInstancesFromLoadBalancer", params) # Same response as register I believe
|
150
|
-
resp = request_info(link,
|
150
|
+
resp = request_info(link, QElbRegisterInstancesParser.new(:logger => @logger))
|
151
151
|
|
152
152
|
rescue Exception
|
153
153
|
on_exception
|
154
154
|
end
|
155
155
|
|
156
|
+
|
156
157
|
def describe_load_balancers(lparams={})
|
157
158
|
@logger.info("Describing Load Balancers")
|
158
159
|
|
@@ -167,6 +168,30 @@ module Aws
|
|
167
168
|
on_exception
|
168
169
|
end
|
169
170
|
|
171
|
+
|
172
|
+
def describe_instance_health(name, instance_ids)
|
173
|
+
instance_ids = [instance_ids] if instance_ids.is_a?(String)
|
174
|
+
# @logger.info("Describing Instance Health")
|
175
|
+
params = {}
|
176
|
+
params['LoadBalancerName'] = name
|
177
|
+
|
178
|
+
i = 1
|
179
|
+
instance_ids.each do |l|
|
180
|
+
params["Instances.member.#{i}.InstanceId"] = "#{l}"
|
181
|
+
i += 1
|
182
|
+
end
|
183
|
+
|
184
|
+
@logger.info("Describing Instances Health #{instance_ids.join(',')} with Load Balancer '#{name}'")
|
185
|
+
|
186
|
+
link = generate_request("DescribeInstanceHealth", params)
|
187
|
+
resp = request_info(link, QElbDescribeInstancesHealthParser.new(:logger => @logger))
|
188
|
+
|
189
|
+
|
190
|
+
rescue Exception
|
191
|
+
on_exception
|
192
|
+
end
|
193
|
+
|
194
|
+
|
170
195
|
def delete_load_balancer(name)
|
171
196
|
@logger.info("Deleting Load Balancer - " + name.to_s)
|
172
197
|
|
@@ -274,28 +299,61 @@ module Aws
|
|
274
299
|
end
|
275
300
|
end
|
276
301
|
|
277
|
-
class
|
302
|
+
class QElbRegisterInstancesParser < AwsParser
|
278
303
|
|
279
304
|
def reset
|
280
|
-
@result =
|
305
|
+
@result = []
|
281
306
|
end
|
282
307
|
|
308
|
+
def tagstart(name, attributes)
|
309
|
+
# puts 'tagstart ' + name + ' -- ' + @xmlpath
|
310
|
+
if (name == 'member' && @xmlpath == 'RegisterInstancesWithLoadBalancerResult/Instances/member')
|
311
|
+
@member = { }
|
312
|
+
end
|
283
313
|
|
314
|
+
end
|
284
315
|
def tagend(name)
|
285
316
|
case name
|
286
317
|
when 'InstanceId' then
|
287
|
-
@
|
318
|
+
@member[:instance_id] = @text
|
288
319
|
end
|
289
320
|
end
|
321
|
+
#
|
290
322
|
end
|
291
323
|
|
292
|
-
class
|
324
|
+
class QElbDescribeInstancesHealthParser < AwsParser
|
293
325
|
|
294
326
|
def reset
|
295
|
-
@result =
|
327
|
+
@result = []
|
328
|
+
end
|
329
|
+
|
330
|
+
def tagstart(name, attributes)
|
331
|
+
# puts 'tagstart ' + name + ' -- ' + @xmlpath
|
332
|
+
if (name == 'member' && @xmlpath == 'DescribeInstanceHealthResult/InstanceStates')
|
333
|
+
@member = { }
|
334
|
+
end
|
296
335
|
end
|
297
336
|
|
337
|
+
def tagend(name)
|
338
|
+
case name
|
339
|
+
when 'Description' then
|
340
|
+
@member[:description] = @text
|
341
|
+
when 'State' then
|
342
|
+
@member[:state] = @text
|
343
|
+
when 'InstanceId' then
|
344
|
+
@member[:instance_id] = @text
|
345
|
+
when 'ReasonCode' then
|
346
|
+
@member[:reason_code] = @text
|
298
347
|
|
348
|
+
end
|
349
|
+
end
|
350
|
+
#
|
351
|
+
end
|
352
|
+
|
353
|
+
class QElbDeleteParser < AwsParser
|
354
|
+
def reset
|
355
|
+
@result = true
|
356
|
+
end
|
299
357
|
end
|
300
358
|
|
301
359
|
|
data/lib/right_aws.rb
CHANGED
data/lib/sdb/active_sdb.rb
CHANGED
@@ -343,7 +343,7 @@ module Aws
|
|
343
343
|
bunch_of_records_requested = args.size > 1 || args.first.is_a?(Array)
|
344
344
|
# flatten ids
|
345
345
|
args = args.to_a.flatten
|
346
|
-
args.each { |id| cond << "
|
346
|
+
args.each { |id| cond << "itemName() = #{self.connection.escape(id)}" }
|
347
347
|
ids_cond = "(#{cond.join(' OR ')})"
|
348
348
|
# user defined :conditions to string (if it was defined)
|
349
349
|
options[:conditions] = build_conditions(options[:conditions])
|
@@ -563,7 +563,7 @@ module Aws
|
|
563
563
|
sort_by, sort_order = sort_options(options[:order])
|
564
564
|
conditions << (conditions.blank? ? " WHERE " : " AND ") << "(#{sort_by} IS NOT NULL)"
|
565
565
|
end
|
566
|
-
"SELECT #{select} FROM
|
566
|
+
"SELECT #{select} FROM `#{from}`#{conditions}#{order}#{limit}"
|
567
567
|
end
|
568
568
|
|
569
569
|
def build_conditions(conditions) # :nodoc:
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'pp'
|
3
|
+
require File.dirname(__FILE__) + '/../test_credentials.rb'
|
4
|
+
|
5
|
+
class TestEc2 < Test::Unit::TestCase
|
6
|
+
|
7
|
+
# Some of RightEc2 instance methods concerning instance launching and image registration
|
8
|
+
# are not tested here due to their potentially risk.
|
9
|
+
|
10
|
+
def setup
|
11
|
+
TestCredentials.get_credentials
|
12
|
+
@ec2 = Aws::Elb.new(TestCredentials.aws_access_key_id,
|
13
|
+
TestCredentials.aws_secret_access_key)
|
14
|
+
@key = 'right_ec2_awesome_test_key'
|
15
|
+
@group = 'right_ec2_awesome_test_security_group'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_01_create_elb
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_02_register_instances
|
23
|
+
assert @ec2.create_security_group(@group,'My awesone test group'), 'Create_security_group fail'
|
24
|
+
group = @ec2.describe_security_groups([@group])[0]
|
25
|
+
assert_equal @group, group[:aws_group_name], 'Group must be created but does not exist'
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_03_deregister_instances
|
29
|
+
assert @ec2.authorize_security_group_named_ingress(@group, TestCredentials.account_number, 'default')
|
30
|
+
assert @ec2.authorize_security_group_IP_ingress(@group, 80,80,'udp','192.168.1.0/8')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_04_describe_instance_health
|
34
|
+
assert_equal 2, @ec2.describe_security_groups([@group])[0][:aws_perms].size
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_05_describe_elb
|
38
|
+
assert @ec2.revoke_security_group_IP_ingress(@group, 80,80,'udp','192.168.1.0/8')
|
39
|
+
assert @ec2.revoke_security_group_named_ingress(@group,
|
40
|
+
TestCredentials.account_number, 'default')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_06_delete_elb
|
44
|
+
images = @ec2.describe_images
|
45
|
+
assert images.size>0, 'Amazon must have at least some public images'
|
46
|
+
# unknown image
|
47
|
+
assert_raise(Aws::AwsError){ @ec2.describe_images(['ami-ABCDEFGH'])}
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
data/test/sdb/test_active_sdb.rb
CHANGED
@@ -4,10 +4,14 @@ require File.dirname(__FILE__) + '/../test_credentials.rb'
|
|
4
4
|
class TestSdb < Test::Unit::TestCase
|
5
5
|
|
6
6
|
DOMAIN_NAME = 'right_sdb_awesome_test_domain'
|
7
|
+
DASH_DOMAIN_NAME = 'right_sdb-awesome_test_domain'
|
7
8
|
|
8
9
|
class Client < Aws::ActiveSdb::Base
|
9
10
|
set_domain_name DOMAIN_NAME
|
10
11
|
end
|
12
|
+
class DashClient < RightAws::ActiveSdb::Base
|
13
|
+
set_domain_name DASH_DOMAIN_NAME
|
14
|
+
end
|
11
15
|
|
12
16
|
def setup
|
13
17
|
TestCredentials.get_credentials
|
@@ -115,6 +119,39 @@ class TestSdb < Test::Unit::TestCase
|
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
122
|
+
def test_04b_find_all_dashed
|
123
|
+
# retrieve all the DB, make sure all are in place
|
124
|
+
clients = DashedClient.find(:all)
|
125
|
+
ids = clients.map{|client| client.id }[0..1]
|
126
|
+
assert_equal @clients.size + 1, clients.size
|
127
|
+
# retrieve all presidents (must find: Bush, Putin, Medvedev)
|
128
|
+
assert_equal 3, DashedClient.find(:all, :conditions => ["[?=?]",'post','president']).size
|
129
|
+
# retrieve all russian presidents (must find: Putin, Medvedev)
|
130
|
+
assert_equal 2, DashedClient.find(:all, :conditions => ["['post'=?] intersection ['country'=?]",'president', 'Russia']).size
|
131
|
+
# retrieve all russian presidents and all women (must find: Putin, Medvedev, 2 Maries and Sandy)
|
132
|
+
assert_equal 5, DashedClient.find(:all, :conditions => ["['post'=?] intersection ['country'=?] union ['gender'=?]",'president', 'Russia','female']).size
|
133
|
+
# find all rissian presidents Bushes
|
134
|
+
assert_equal 0, DashedClient.find(:all, :conditions => ["['post'=?] intersection ['country'=?] intersection ['name'=?]",'president', 'Russia','Bush']).size
|
135
|
+
# --- find by ids
|
136
|
+
# must find 1 rec (by rec id) and return it
|
137
|
+
assert_equal ids.first, DashedClient.find(ids.first).id
|
138
|
+
# must find 1 rec (by one item array) and return an array
|
139
|
+
assert_equal ids.first, DashedClient.find([ids.first]).first.id
|
140
|
+
# must find 2 recs (by a list of comma separated ids) and return an array
|
141
|
+
assert_equal ids.size, DashedClient.find(*ids).size
|
142
|
+
# must find 2 recs (by an array of ids) and return an array
|
143
|
+
assert_equal ids.size, DashedClient.find(ids).size
|
144
|
+
ids << 'dummy_id'
|
145
|
+
# must raise an error when getting unexistent record
|
146
|
+
assert_raise(RightAws::ActiveSdb::ActiveSdbError) do
|
147
|
+
DashedClient.find(ids)
|
148
|
+
end
|
149
|
+
# find one record by unknown id
|
150
|
+
assert_raise(RightAws::ActiveSdb::ActiveSdbError) do
|
151
|
+
DashedClient.find('dummy_id')
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
118
155
|
def test_05_find_first
|
119
156
|
# find any record
|
120
157
|
assert Client.find(:first)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-
|
14
|
+
date: 2009-12-02 00:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- lib/awsbase/support.rb
|
51
51
|
- lib/ec2/right_ec2.rb
|
52
52
|
- lib/ec2/right_mon_interface.rb
|
53
|
-
- lib/elb/
|
53
|
+
- lib/elb/elb_interface.rb
|
54
54
|
- lib/right_aws.rb
|
55
55
|
- lib/s3/right_s3.rb
|
56
56
|
- lib/s3/right_s3_interface.rb
|
@@ -93,6 +93,7 @@ test_files:
|
|
93
93
|
- test/ec2/test_helper.rb
|
94
94
|
- test/ec2/test_mon.rb
|
95
95
|
- test/ec2/test_right_ec2.rb
|
96
|
+
- test/elb/test_elb.rb
|
96
97
|
- test/http_connection.rb
|
97
98
|
- test/s3/test_helper.rb
|
98
99
|
- test/s3/test_right_s3.rb
|