aws 2.1.1 → 2.1.2
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/elb/right_elb_interface.rb +101 -62
- metadata +2 -2
@@ -1,50 +1,52 @@
|
|
1
1
|
module Aws
|
2
2
|
|
3
3
|
|
4
|
-
|
5
4
|
class Elb < AwsBase
|
6
5
|
include AwsBaseInterface
|
7
6
|
|
8
7
|
|
9
8
|
#Amazon EC2 API version being used
|
10
|
-
API_VERSION
|
11
|
-
DEFAULT_HOST
|
12
|
-
DEFAULT_PATH
|
13
|
-
DEFAULT_PROTOCOL
|
14
|
-
DEFAULT_PORT
|
9
|
+
API_VERSION = "2008-12-01"
|
10
|
+
DEFAULT_HOST = "elasticloadbalancing.amazonaws.com"
|
11
|
+
DEFAULT_PATH = '/'
|
12
|
+
DEFAULT_PROTOCOL = 'http'
|
13
|
+
DEFAULT_PORT = 80
|
15
14
|
|
16
15
|
|
17
16
|
@@bench = AwsBenchmarkingBlock.new
|
17
|
+
|
18
18
|
def self.bench_xml
|
19
19
|
@@bench.xml
|
20
20
|
end
|
21
|
+
|
21
22
|
def self.bench_ec2
|
22
23
|
@@bench.service
|
23
24
|
end
|
24
25
|
|
25
26
|
# Current API version (sometimes we have to check it outside the GEM).
|
26
27
|
@@api = ENV['EC2_API_VERSION'] || API_VERSION
|
28
|
+
|
27
29
|
def self.api
|
28
30
|
@@api
|
29
31
|
end
|
30
32
|
|
31
33
|
|
32
34
|
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
33
|
-
init({ :name
|
34
|
-
:default_host
|
35
|
-
:default_port
|
36
|
-
:default_service
|
35
|
+
init({ :name => 'ELB',
|
36
|
+
:default_host => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).host : DEFAULT_HOST,
|
37
|
+
:default_port => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).port : DEFAULT_PORT,
|
38
|
+
:default_service => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).path : DEFAULT_PATH,
|
37
39
|
:default_protocol => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).scheme : DEFAULT_PROTOCOL },
|
38
|
-
aws_access_key_id
|
40
|
+
aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
|
39
41
|
aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
|
40
42
|
params)
|
41
43
|
end
|
42
44
|
|
43
45
|
|
44
46
|
def generate_request(action, params={})
|
45
|
-
service_hash = {"Action"
|
47
|
+
service_hash = {"Action" => action,
|
46
48
|
"AWSAccessKeyId" => @aws_access_key_id,
|
47
|
-
"Version"
|
49
|
+
"Version" => @@api }
|
48
50
|
service_hash.update(params)
|
49
51
|
service_params = signed_service_params(@aws_secret_access_key, service_hash, :get, @params[:server], @params[:service])
|
50
52
|
|
@@ -54,20 +56,20 @@ module Aws
|
|
54
56
|
# resign the request because HTTP verb is included into signature
|
55
57
|
service_params = signed_service_params(@aws_secret_access_key, service_hash, :post, @params[:server], @params[:service])
|
56
58
|
end
|
57
|
-
request
|
59
|
+
request = Net::HTTP::Post.new(service)
|
58
60
|
request.body = service_params
|
59
61
|
request['Content-Type'] = 'application/x-www-form-urlencoded'
|
60
62
|
else
|
61
|
-
request
|
63
|
+
request = Net::HTTP::Get.new("#{@params[:service]}?#{service_params}")
|
62
64
|
end
|
63
65
|
|
64
66
|
#puts "\n\n --------------- QUERY REQUEST TO AWS -------------- \n\n"
|
65
67
|
#puts "#{@params[:service]}?#{service_params}\n\n"
|
66
68
|
|
67
69
|
# prepare output hash
|
68
|
-
{ :request
|
69
|
-
:server
|
70
|
-
:port
|
70
|
+
{ :request => request,
|
71
|
+
:server => @params[:server],
|
72
|
+
:port => @params[:port],
|
71
73
|
:protocol => @params[:protocol] }
|
72
74
|
end
|
73
75
|
|
@@ -85,12 +87,37 @@ module Aws
|
|
85
87
|
# REQUESTS
|
86
88
|
#-----------------------------------------------------------------
|
87
89
|
|
90
|
+
#
|
91
|
+
# name: name of load balancer
|
92
|
+
# availability_zones: array of zones
|
93
|
+
# listeners: array of hashes containing :load_balancer_port, :instance_port, :protocol
|
94
|
+
# eg: {:load_balancer_port=>80, :instance_port=>8080, :protocol=>"HTTP"}
|
95
|
+
def create_load_balancer(name, availability_zones, listeners)
|
96
|
+
params = hash_params('AvailabilityZones.member', availability_zones)
|
97
|
+
i = 0
|
98
|
+
listeners.each do |l|
|
99
|
+
params["Listeners.member.#{i}.Protocol=#{l[:protocol]}"]
|
100
|
+
params["Listeners.member.#{i}.LoadBalancerPort=#{l[:load_balancer_port]}"]
|
101
|
+
params["Listeners.member.#{i}.Protocol=#{l[:instance_port]}"]
|
102
|
+
i += 1
|
103
|
+
end
|
104
|
+
params['LoadBalancerName'] = name
|
105
|
+
|
106
|
+
@logger.info("Creating LoadBalancer called #{params['LoadBalancerName']}")
|
107
|
+
|
108
|
+
link = generate_request("CreateLoadBalancer", params)
|
109
|
+
resp = request_info(link, QElbCreateParser.new(:logger => @logger))
|
110
|
+
|
111
|
+
rescue Exception
|
112
|
+
on_exception
|
113
|
+
end
|
114
|
+
|
88
115
|
|
89
116
|
def register_instance_with_elb(instance_id, lparams={})
|
90
117
|
params = {}
|
91
118
|
|
92
|
-
params['LoadBalancerName']
|
93
|
-
params['Instances.member.1.InstanceId']
|
119
|
+
params['LoadBalancerName'] = lparams[:load_balancer_name]
|
120
|
+
params['Instances.member.1.InstanceId'] = instance_id
|
94
121
|
|
95
122
|
@logger.info("Registering Instance #{instance_id} with Load Balancer '#{params['LoadBalancerName']}'")
|
96
123
|
|
@@ -102,10 +129,6 @@ module Aws
|
|
102
129
|
end
|
103
130
|
|
104
131
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
132
|
def describe_load_balancers
|
110
133
|
@logger.info("Describing Load Balancers")
|
111
134
|
|
@@ -120,67 +143,83 @@ module Aws
|
|
120
143
|
end
|
121
144
|
|
122
145
|
|
123
|
-
|
124
|
-
|
125
146
|
#-----------------------------------------------------------------
|
126
147
|
# PARSERS: Instances
|
127
148
|
#-----------------------------------------------------------------
|
128
149
|
|
129
|
-
|
150
|
+
|
151
|
+
class QElbCreateParser < AwsParser
|
130
152
|
|
131
153
|
def reset
|
132
|
-
@result =
|
154
|
+
@result = {}
|
133
155
|
end
|
134
156
|
|
135
157
|
|
136
158
|
def tagend(name)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
# @result[:availability_zones] = @text
|
142
|
-
# when 'CreatedTime' then
|
143
|
-
# @result[:created_time] = Time.parse(@text)
|
144
|
-
# when 'DNSName' then
|
145
|
-
# @result[:dns_name] = @text
|
146
|
-
# when 'Instances' then
|
147
|
-
# @result[:instances] = @text
|
148
|
-
# when 'HealthCheck' then
|
149
|
-
# @result[:health_check] = @text
|
150
|
-
# when 'Listeners' then
|
151
|
-
# @result[:listeners] = @text
|
152
|
-
#end
|
159
|
+
case name
|
160
|
+
when 'DNSName' then
|
161
|
+
@result[:dns_name] = @text
|
162
|
+
end
|
153
163
|
end
|
154
164
|
end
|
155
165
|
|
156
|
-
class
|
166
|
+
class QElbDescribeLoadBalancersParser < AwsParser
|
157
167
|
|
158
168
|
def reset
|
159
|
-
@result =
|
169
|
+
@result = {}
|
160
170
|
end
|
161
171
|
|
162
172
|
|
163
173
|
def tagend(name)
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
174
|
+
case name
|
175
|
+
when 'LoadBalancerName' then
|
176
|
+
@result[:load_balancer_name] = @text
|
177
|
+
# when 'AvailabilityZones' then
|
178
|
+
# @result[:availability_zones] = @text
|
179
|
+
when 'CreatedTime' then
|
180
|
+
@result[:created_time] = Time.parse(@text)
|
181
|
+
when 'DNSName' then
|
182
|
+
@result[:dns_name] = @text
|
183
|
+
when 'Protocol' then
|
184
|
+
@result[:protocol] = @text
|
185
|
+
when 'LoadBalancerPort' then
|
186
|
+
@result[:load_balancer_port] = @text.to_i
|
187
|
+
when 'InstancePort' then
|
188
|
+
@result[:instance_port] = @text.to_i
|
189
|
+
# HEALTH CHECK STUFF
|
190
|
+
when 'Interval' then
|
191
|
+
@result[:interval] = @text.to_i
|
192
|
+
when 'Target' then
|
193
|
+
@result[:target] = @text
|
194
|
+
when 'HealthyThreshold' then
|
195
|
+
@result[:healthy_threshold] = @text.to_i
|
196
|
+
when 'Timeout' then
|
197
|
+
@result[:timeout] = @text.to_i
|
198
|
+
when 'UnhealthyThreshold' then
|
199
|
+
@result[:unhealthy_threshold] = @text.to_i
|
200
|
+
# AvailabilityZones
|
201
|
+
when 'member' then
|
202
|
+
@result[:availability_zones] = [] unless @result[:availability_zones]
|
203
|
+
@result[:availability_zones] << @text
|
204
|
+
|
205
|
+
end
|
180
206
|
end
|
181
207
|
end
|
182
208
|
|
209
|
+
class QElbRegisterInstanceParser < AwsParser
|
183
210
|
|
211
|
+
def reset
|
212
|
+
@result = {}
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
def tagend(name)
|
217
|
+
case name
|
218
|
+
when 'InstanceId' then
|
219
|
+
@result[:instance_id] = @text
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
184
223
|
|
185
224
|
|
186
225
|
end
|
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.2
|
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-11-
|
14
|
+
date: 2009-11-04 00:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|