steamcannon-aws 2.3.26.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +187 -0
- data/lib/acf/right_acf_interface.rb +413 -0
- data/lib/aws.rb +31 -0
- data/lib/awsbase/aws_response_array.rb +30 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/right_awsbase.rb +1239 -0
- data/lib/awsbase/support.rb +129 -0
- data/lib/ec2/right_ec2.rb +1879 -0
- data/lib/ec2/right_mon_interface.rb +233 -0
- data/lib/elb/elb_interface.rb +359 -0
- data/lib/iam/iam.rb +118 -0
- data/lib/rds/rds.rb +216 -0
- data/lib/right_aws.rb +57 -0
- data/lib/s3/right_s3.rb +1110 -0
- data/lib/s3/right_s3_interface.rb +1237 -0
- data/lib/sdb/active_sdb.rb +990 -0
- data/lib/sdb/right_sdb_interface.rb +816 -0
- data/lib/sqs/right_sqs.rb +287 -0
- data/lib/sqs/right_sqs_interface.rb +445 -0
- data/test/acf/test_acf.rb +148 -0
- data/test/acf/test_helper.rb +2 -0
- data/test/ec2/test_ec2.rb +205 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_mon.rb +17 -0
- data/test/elb/test_elb.rb +51 -0
- data/test/http_connection.rb +87 -0
- data/test/iam/test_iam.rb +36 -0
- data/test/rds/test_rds.rb +181 -0
- data/test/s3/test_helper.rb +3 -0
- data/test/s3/test_s3.rb +425 -0
- data/test/s3/test_s3_stubbed.rb +97 -0
- data/test/sdb/test_active_sdb.rb +338 -0
- data/test/sdb/test_helper.rb +3 -0
- data/test/sdb/test_sdb.rb +207 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_sqs.rb +206 -0
- data/test/test_credentials.rb +54 -0
- data/test/ts_right_aws.rb +13 -0
- metadata +173 -0
@@ -0,0 +1,233 @@
|
|
1
|
+
module Aws
|
2
|
+
|
3
|
+
class Mon < Aws::AwsBase
|
4
|
+
include Aws::AwsBaseInterface
|
5
|
+
|
6
|
+
|
7
|
+
#Amazon EC2 API version being used
|
8
|
+
API_VERSION = "2009-05-15"
|
9
|
+
DEFAULT_HOST = "monitoring.amazonaws.com"
|
10
|
+
DEFAULT_PATH = '/'
|
11
|
+
DEFAULT_PROTOCOL = 'https'
|
12
|
+
DEFAULT_PORT = 443
|
13
|
+
|
14
|
+
# Available measures for EC2 instances:
|
15
|
+
# NetworkIn NetworkOut DiskReadOps DiskWriteOps DiskReadBytes DiskWriteBytes CPUUtilization
|
16
|
+
measures=%w(NetworkIn NetworkOut DiskReadOps DiskWriteOps DiskReadBytes DiskWriteBytes CPUUtilization)
|
17
|
+
|
18
|
+
@@bench = Aws::AwsBenchmarkingBlock.new
|
19
|
+
|
20
|
+
def self.bench_xml
|
21
|
+
@@bench.xml
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.bench_ec2
|
25
|
+
@@bench.service
|
26
|
+
end
|
27
|
+
|
28
|
+
# Current API version (sometimes we have to check it outside the GEM).
|
29
|
+
@@api = ENV['EC2_API_VERSION'] || API_VERSION
|
30
|
+
|
31
|
+
def self.api
|
32
|
+
@@api
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
37
|
+
init({ :name => 'MON',
|
38
|
+
:default_host => ENV['MON_URL'] ? URI.parse(ENV['MON_URL']).host : DEFAULT_HOST,
|
39
|
+
:default_port => ENV['MON_URL'] ? URI.parse(ENV['MON_URL']).port : DEFAULT_PORT,
|
40
|
+
:default_service => ENV['MON_URL'] ? URI.parse(ENV['MON_URL']).path : DEFAULT_PATH,
|
41
|
+
:default_protocol => ENV['MON_URL'] ? URI.parse(ENV['MON_URL']).scheme : DEFAULT_PROTOCOL,
|
42
|
+
:api_version => API_VERSION },
|
43
|
+
aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
|
44
|
+
aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
|
45
|
+
params)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def generate_request(action, params={})
|
50
|
+
service_hash = {"Action" => action,
|
51
|
+
"AWSAccessKeyId" => @aws_access_key_id,
|
52
|
+
"Version" => @@api }
|
53
|
+
service_hash.update(params)
|
54
|
+
service_params = signed_service_params(@aws_secret_access_key, service_hash, :get, @params[:server], @params[:service])
|
55
|
+
|
56
|
+
# use POST method if the length of the query string is too large
|
57
|
+
if service_params.size > 2000
|
58
|
+
if signature_version == '2'
|
59
|
+
# resign the request because HTTP verb is included into signature
|
60
|
+
service_params = signed_service_params(@aws_secret_access_key, service_hash, :post, @params[:server], @params[:service])
|
61
|
+
end
|
62
|
+
request = Net::HTTP::Post.new(service)
|
63
|
+
request.body = service_params
|
64
|
+
request['Content-Type'] = 'application/x-www-form-urlencoded'
|
65
|
+
else
|
66
|
+
request = Net::HTTP::Get.new("#{@params[:service]}?#{service_params}")
|
67
|
+
end
|
68
|
+
|
69
|
+
#puts "\n\n --------------- QUERY REQUEST TO AWS -------------- \n\n"
|
70
|
+
#puts "#{@params[:service]}?#{service_params}\n\n"
|
71
|
+
|
72
|
+
# prepare output hash
|
73
|
+
{ :request => request,
|
74
|
+
:server => @params[:server],
|
75
|
+
:port => @params[:port],
|
76
|
+
:protocol => @params[:protocol] }
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
# Sends request to Amazon and parses the response
|
81
|
+
# Raises AwsError if any banana happened
|
82
|
+
def request_info(request, parser)
|
83
|
+
thread = @params[:multi_thread] ? Thread.current : Thread.main
|
84
|
+
thread[:elb_connection] ||= Rightscale::HttpConnection.new(:exception => Aws::AwsError, :logger => @logger)
|
85
|
+
request_info_impl(thread[:elb_connection], @@bench, request, parser)
|
86
|
+
end
|
87
|
+
|
88
|
+
#-----------------------------------------------------------------
|
89
|
+
# REQUESTS
|
90
|
+
#-----------------------------------------------------------------
|
91
|
+
|
92
|
+
def list_metrics(options={})
|
93
|
+
|
94
|
+
next_token = options[:next_token] || nil
|
95
|
+
|
96
|
+
params = { }
|
97
|
+
params['NextToken'] = next_token unless next_token.nil?
|
98
|
+
|
99
|
+
@logger.info("list Metrics ")
|
100
|
+
|
101
|
+
link = generate_request("ListMetrics", params)
|
102
|
+
resp = request_info(link, QMonListMetrics.new(:logger => @logger))
|
103
|
+
|
104
|
+
rescue Exception
|
105
|
+
on_exception
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
# measureName: CPUUtilization (Units: Percent), NetworkIn (Units: Bytes), NetworkOut (Units: Bytes), DiskWriteOps (Units: Count)
|
110
|
+
# DiskReadBytes (Units: Bytes), DiskReadOps (Units: Count), DiskWriteBytes (Units: Bytes)
|
111
|
+
# stats: array containing one or more of Minimum, Maximum, Sum, Average, Samples
|
112
|
+
# start_time : Timestamp to start
|
113
|
+
# end_time: Timestamp to end
|
114
|
+
# unit: Either Seconds, Percent, Bytes, Bits, Count, Bytes, Bits/Second, Count/Second, and None
|
115
|
+
#
|
116
|
+
# Optional parameters:
|
117
|
+
# period: Integer 60 or multiple of 60
|
118
|
+
# dimensions: Hash containing keys ImageId, AutoScalingGroupName, InstanceId, InstanceType
|
119
|
+
# customUnit: nil. not supported currently.
|
120
|
+
# namespace: AWS/EC2
|
121
|
+
|
122
|
+
def get_metric_statistics ( measure_name, stats, start_time, end_time, unit, options={})
|
123
|
+
|
124
|
+
period = options[:period] || 60
|
125
|
+
dimensions = options[:dimensions] || nil
|
126
|
+
custom_unit = options[:custom_unit] || nil
|
127
|
+
namespace = options[:namespace] || "AWS/EC2"
|
128
|
+
|
129
|
+
params = {}
|
130
|
+
params['MeasureName'] = measure_name
|
131
|
+
i=1
|
132
|
+
stats.each do |s|
|
133
|
+
params['Statistics.member.'+i.to_s] = s
|
134
|
+
i = i+1
|
135
|
+
end
|
136
|
+
params['Period'] = period
|
137
|
+
if (dimensions != nil)
|
138
|
+
i = 1
|
139
|
+
dimensions.each do |k, v|
|
140
|
+
params['Dimensions.member.'+i.to_s+".Name."+i.to_s] = k
|
141
|
+
params['Dimensions.member.'+i.to_s+".Value."+i.to_s] = v
|
142
|
+
i = i+1
|
143
|
+
end
|
144
|
+
end
|
145
|
+
params['StartTime'] = start_time
|
146
|
+
params['EndTime'] = end_time
|
147
|
+
params['Unit'] = unit
|
148
|
+
#params['CustomUnit'] = customUnit always nil
|
149
|
+
params['Namespace'] = namespace
|
150
|
+
|
151
|
+
link = generate_request("GetMetricStatistics", params)
|
152
|
+
resp = request_info(link, QMonGetMetricStatistics.new(:logger => @logger))
|
153
|
+
|
154
|
+
rescue Exception
|
155
|
+
on_exception
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
#-----------------------------------------------------------------
|
160
|
+
# PARSERS: Instances
|
161
|
+
#-----------------------------------------------------------------
|
162
|
+
|
163
|
+
|
164
|
+
class QMonGetMetricStatistics < Aws::AwsParser
|
165
|
+
|
166
|
+
def reset
|
167
|
+
@result = []
|
168
|
+
end
|
169
|
+
|
170
|
+
def tagstart(name, attributes)
|
171
|
+
@metric = {} if name == 'member'
|
172
|
+
end
|
173
|
+
|
174
|
+
def tagend(name)
|
175
|
+
case name
|
176
|
+
when 'Timestamp' then
|
177
|
+
@metric[:timestamp] = @text
|
178
|
+
when 'Samples' then
|
179
|
+
@metric[:samples] = @text
|
180
|
+
when 'Unit' then
|
181
|
+
@metric[:unit] = @text
|
182
|
+
when 'Average' then
|
183
|
+
@metric[:average] = @text
|
184
|
+
when 'Minimum' then
|
185
|
+
@metric[:minimum] = @text
|
186
|
+
when 'Maximum' then
|
187
|
+
@metric[:maximum] = @text
|
188
|
+
when 'Sum' then
|
189
|
+
@metric[:sum] = @text
|
190
|
+
when 'Value' then
|
191
|
+
@metric[:value] = @text
|
192
|
+
when 'member' then
|
193
|
+
@result << @metric
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
class QMonListMetrics < Aws::AwsParser
|
199
|
+
|
200
|
+
def reset
|
201
|
+
@result = []
|
202
|
+
@namespace = ""
|
203
|
+
@measure_name = ""
|
204
|
+
end
|
205
|
+
|
206
|
+
def tagstart(name, attributes)
|
207
|
+
@metric = {} if name == 'member'
|
208
|
+
end
|
209
|
+
|
210
|
+
def tagend(name)
|
211
|
+
case name
|
212
|
+
when 'MeasureName' then
|
213
|
+
@measure_name = @text
|
214
|
+
when 'Namespace' then
|
215
|
+
@namespace = @text
|
216
|
+
when 'Name' then
|
217
|
+
@metric[:name] = @text
|
218
|
+
when 'Value' then
|
219
|
+
@metric[:value] = @text
|
220
|
+
when 'member' then
|
221
|
+
@metric[:namespace] = @namespace
|
222
|
+
@metric[:measure_name] = @measure_name
|
223
|
+
@result << @metric
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
end
|
233
|
+
|
@@ -0,0 +1,359 @@
|
|
1
|
+
module Aws
|
2
|
+
|
3
|
+
require 'xmlsimple'
|
4
|
+
|
5
|
+
class Elb < AwsBase
|
6
|
+
|
7
|
+
include AwsBaseInterface
|
8
|
+
|
9
|
+
|
10
|
+
#Amazon ELB API version being used
|
11
|
+
API_VERSION = "2009-05-15"
|
12
|
+
DEFAULT_HOST = "elasticloadbalancing.amazonaws.com"
|
13
|
+
DEFAULT_PATH = '/'
|
14
|
+
DEFAULT_PROTOCOL = 'https'
|
15
|
+
DEFAULT_PORT = 443
|
16
|
+
|
17
|
+
|
18
|
+
@@bench = AwsBenchmarkingBlock.new
|
19
|
+
|
20
|
+
def self.bench_xml
|
21
|
+
@@bench.xml
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.bench_ec2
|
25
|
+
@@bench.service
|
26
|
+
end
|
27
|
+
|
28
|
+
# Current API version (sometimes we have to check it outside the GEM).
|
29
|
+
@@api = ENV['ELB_API_VERSION'] || API_VERSION
|
30
|
+
|
31
|
+
def self.api
|
32
|
+
@@api
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
37
|
+
init({ :name => 'ELB',
|
38
|
+
:default_host => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).host : DEFAULT_HOST,
|
39
|
+
:default_port => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).port : DEFAULT_PORT,
|
40
|
+
:default_service => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).path : DEFAULT_PATH,
|
41
|
+
:default_protocol => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).scheme : DEFAULT_PROTOCOL,
|
42
|
+
:api_version => API_VERSION },
|
43
|
+
aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
|
44
|
+
aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
|
45
|
+
params)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
# Sends request to Amazon and parses the response
|
50
|
+
# Raises AwsError if any banana happened
|
51
|
+
def request_info(request, parser)
|
52
|
+
request_info2(request, parser, @params, :elb_connection, @logger, @@bench)
|
53
|
+
end
|
54
|
+
|
55
|
+
# todo: convert to xml-simple version and get rid of parser below
|
56
|
+
def do_request(action, params, options={})
|
57
|
+
link = generate_request(action, params)
|
58
|
+
resp = request_info_xml_simple(:rds_connection, @params, link, @logger,
|
59
|
+
:group_tags=>{"LoadBalancersDescriptions"=>"LoadBalancersDescription",
|
60
|
+
"DBParameterGroups"=>"DBParameterGroup",
|
61
|
+
"DBSecurityGroups"=>"DBSecurityGroup",
|
62
|
+
"EC2SecurityGroups"=>"EC2SecurityGroup",
|
63
|
+
"IPRanges"=>"IPRange"},
|
64
|
+
:force_array=>["DBInstances",
|
65
|
+
"DBParameterGroups",
|
66
|
+
"DBSecurityGroups",
|
67
|
+
"EC2SecurityGroups",
|
68
|
+
"IPRanges"],
|
69
|
+
:pull_out_array=>options[:pull_out_array],
|
70
|
+
:pull_out_single=>options[:pull_out_single],
|
71
|
+
:wrapper=>options[:wrapper])
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
#-----------------------------------------------------------------
|
76
|
+
# REQUESTS
|
77
|
+
#-----------------------------------------------------------------
|
78
|
+
|
79
|
+
#
|
80
|
+
# name: name of load balancer
|
81
|
+
# availability_zones: array of zones
|
82
|
+
# listeners: array of hashes containing :load_balancer_port, :instance_port, :protocol
|
83
|
+
# eg: {:load_balancer_port=>80, :instance_port=>8080, :protocol=>"HTTP"}
|
84
|
+
def create_load_balancer(name, availability_zones, listeners)
|
85
|
+
params = hash_params('AvailabilityZones.member', availability_zones)
|
86
|
+
i = 1
|
87
|
+
listeners.each do |l|
|
88
|
+
params["Listeners.member.#{i}.Protocol"] = "#{l[:protocol]}"
|
89
|
+
params["Listeners.member.#{i}.LoadBalancerPort"] = "#{l[:load_balancer_port]}"
|
90
|
+
params["Listeners.member.#{i}.InstancePort"] = "#{l[:instance_port]}"
|
91
|
+
i += 1
|
92
|
+
end
|
93
|
+
params['LoadBalancerName'] = name
|
94
|
+
|
95
|
+
@logger.info("Creating LoadBalancer called #{params['LoadBalancerName']}")
|
96
|
+
|
97
|
+
link = generate_request("CreateLoadBalancer", params)
|
98
|
+
resp = request_info(link, QElbCreateParser.new(:logger => @logger))
|
99
|
+
|
100
|
+
rescue Exception
|
101
|
+
on_exception
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# name: name of load balancer
|
106
|
+
# instance_ids: array of instance_id's to add to load balancer
|
107
|
+
def register_instances_with_load_balancer(name, instance_ids)
|
108
|
+
params = {}
|
109
|
+
params['LoadBalancerName'] = name
|
110
|
+
|
111
|
+
i = 1
|
112
|
+
instance_ids.each do |l|
|
113
|
+
params["Instances.member.#{i}.InstanceId"] = "#{l}"
|
114
|
+
i += 1
|
115
|
+
end
|
116
|
+
|
117
|
+
@logger.info("Registering Instances #{instance_ids.join(',')} with Load Balancer '#{name}'")
|
118
|
+
|
119
|
+
link = generate_request("RegisterInstancesWithLoadBalancer", params)
|
120
|
+
resp = request_info(link, QElbRegisterInstancesParser.new(:logger => @logger))
|
121
|
+
|
122
|
+
rescue Exception
|
123
|
+
on_exception
|
124
|
+
end
|
125
|
+
|
126
|
+
def deregister_instances_from_load_balancer(name, instance_ids)
|
127
|
+
params = {}
|
128
|
+
params['LoadBalancerName'] = name
|
129
|
+
|
130
|
+
i = 1
|
131
|
+
instance_ids.each do |l|
|
132
|
+
params["Instances.member.#{i}.InstanceId"] = "#{l}"
|
133
|
+
i += 1
|
134
|
+
end
|
135
|
+
|
136
|
+
@logger.info("Deregistering Instances #{instance_ids.join(',')} from Load Balancer '#{name}'")
|
137
|
+
|
138
|
+
link = generate_request("DeregisterInstancesFromLoadBalancer", params) # Same response as register I believe
|
139
|
+
resp = request_info(link, QElbRegisterInstancesParser.new(:logger => @logger))
|
140
|
+
|
141
|
+
rescue Exception
|
142
|
+
on_exception
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
def describe_load_balancers(lparams={})
|
147
|
+
@logger.info("Describing Load Balancers")
|
148
|
+
|
149
|
+
params = {}
|
150
|
+
params.update( hash_params('LoadBalancerNames.member', lparams[:names]) ) if lparams[:names]
|
151
|
+
|
152
|
+
link = generate_request("DescribeLoadBalancers", params)
|
153
|
+
|
154
|
+
resp = request_info(link, QElbDescribeLoadBalancersParser.new(:logger => @logger))
|
155
|
+
|
156
|
+
rescue Exception
|
157
|
+
on_exception
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def describe_instance_health(name, instance_ids=[])
|
162
|
+
instance_ids = [instance_ids] if instance_ids.is_a?(String)
|
163
|
+
# @logger.info("Describing Instance Health")
|
164
|
+
params = {}
|
165
|
+
params['LoadBalancerName'] = name
|
166
|
+
|
167
|
+
i = 1
|
168
|
+
instance_ids.each do |l|
|
169
|
+
params["Instances.member.#{i}.InstanceId"] = "#{l}"
|
170
|
+
i += 1
|
171
|
+
end
|
172
|
+
|
173
|
+
@logger.info("Describing Instances Health #{instance_ids.join(',')} with Load Balancer '#{name}'")
|
174
|
+
|
175
|
+
link = generate_request("DescribeInstanceHealth", params)
|
176
|
+
resp = request_info(link, QElbDescribeInstancesHealthParser.new(:logger => @logger))
|
177
|
+
|
178
|
+
|
179
|
+
rescue Exception
|
180
|
+
on_exception
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
def delete_load_balancer(name)
|
185
|
+
@logger.info("Deleting Load Balancer - " + name.to_s)
|
186
|
+
|
187
|
+
params = {}
|
188
|
+
params['LoadBalancerName'] = name
|
189
|
+
|
190
|
+
link = generate_request("DeleteLoadBalancer", params)
|
191
|
+
|
192
|
+
resp = request_info(link, QElbDeleteParser.new(:logger => @logger))
|
193
|
+
|
194
|
+
rescue Exception
|
195
|
+
on_exception
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
#-----------------------------------------------------------------
|
200
|
+
# PARSERS: Instances
|
201
|
+
#-----------------------------------------------------------------
|
202
|
+
|
203
|
+
|
204
|
+
class QElbCreateParser < AwsParser
|
205
|
+
|
206
|
+
def reset
|
207
|
+
@result = {}
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
def tagend(name)
|
212
|
+
case name
|
213
|
+
when 'DNSName' then
|
214
|
+
@result[:dns_name] = @text
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
class QElbDescribeLoadBalancersParser < AwsParser
|
220
|
+
|
221
|
+
def reset
|
222
|
+
@result = []
|
223
|
+
end
|
224
|
+
|
225
|
+
def tagstart(name, attributes)
|
226
|
+
# puts 'tagstart ' + name + ' -- ' + @xmlpath
|
227
|
+
if (name == 'member' && @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions/member/Listeners')
|
228
|
+
@listener = { }
|
229
|
+
end
|
230
|
+
if (name == 'member' && @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions/member/AvailabilityZones')
|
231
|
+
@availability_zone = { }
|
232
|
+
end
|
233
|
+
if (name == 'member' && @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions/member/Instances')
|
234
|
+
@instance = {}
|
235
|
+
end
|
236
|
+
if (name == 'member' && @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions')
|
237
|
+
@member = { :listeners=>[], :availability_zones=>[], :health_check=>{}, :instances=>[] }
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
def tagend(name)
|
244
|
+
case name
|
245
|
+
when 'LoadBalancerName' then
|
246
|
+
@member[:load_balancer_name] = @text
|
247
|
+
@member[:name] = @text
|
248
|
+
when 'CreatedTime' then
|
249
|
+
@member[:created_time] = Time.parse(@text)
|
250
|
+
@member[:created] = @member[:created_time]
|
251
|
+
when 'DNSName' then
|
252
|
+
@member[:dns_name] = @text
|
253
|
+
# Instances
|
254
|
+
when 'InstanceId' then
|
255
|
+
@instance[:instance_id] = @text
|
256
|
+
# Listeners
|
257
|
+
when 'Protocol' then
|
258
|
+
@listener[:protocol] = @text
|
259
|
+
when 'LoadBalancerPort' then
|
260
|
+
@listener[:load_balancer_port] = @text.to_i
|
261
|
+
when 'InstancePort' then
|
262
|
+
@listener[:instance_port] = @text.to_i
|
263
|
+
# HEALTH CHECK STUFF
|
264
|
+
when 'Interval' then
|
265
|
+
@member[:health_check][:interval] = @text.to_i
|
266
|
+
when 'Target' then
|
267
|
+
@member[:health_check][:target] = @text
|
268
|
+
when 'HealthyThreshold' then
|
269
|
+
@member[:health_check][:healthy_threshold] = @text.to_i
|
270
|
+
when 'Timeout' then
|
271
|
+
@member[:health_check][:timeout] = @text.to_i
|
272
|
+
when 'UnhealthyThreshold' then
|
273
|
+
@member[:health_check][:unhealthy_threshold] = @text.to_i
|
274
|
+
# AvailabilityZones
|
275
|
+
when 'member' then
|
276
|
+
if @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions/member/Listeners'
|
277
|
+
@member[:listeners] << @listener
|
278
|
+
elsif @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions/member/AvailabilityZones'
|
279
|
+
@availability_zone = @text
|
280
|
+
@member[:availability_zones] << @availability_zone
|
281
|
+
elsif @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions/member/Instances'
|
282
|
+
@member[:instances] << @instance
|
283
|
+
elsif @xmlpath == 'DescribeLoadBalancersResponse/DescribeLoadBalancersResult/LoadBalancerDescriptions'
|
284
|
+
@result << @member
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
class QElbRegisterInstancesParser < AwsParser
|
292
|
+
|
293
|
+
def reset
|
294
|
+
@result = []
|
295
|
+
end
|
296
|
+
|
297
|
+
def tagstart(name, attributes)
|
298
|
+
# puts 'tagstart ' + name + ' -- ' + @xmlpath
|
299
|
+
if (name == 'member' &&
|
300
|
+
(@xmlpath == 'RegisterInstancesWithLoadBalancerResponse/RegisterInstancesWithLoadBalancerResult/Instances' ||
|
301
|
+
@xmlpath == 'DeregisterInstancesFromLoadBalancerResponse/DeregisterInstancesFromLoadBalancerResult/Instances')
|
302
|
+
)
|
303
|
+
@member = { }
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
def tagend(name)
|
309
|
+
case name
|
310
|
+
when 'InstanceId' then
|
311
|
+
@member[:instance_id] = @text
|
312
|
+
when 'member' then
|
313
|
+
@result << @member
|
314
|
+
end
|
315
|
+
end
|
316
|
+
#
|
317
|
+
end
|
318
|
+
|
319
|
+
class QElbDescribeInstancesHealthParser < AwsParser
|
320
|
+
|
321
|
+
def reset
|
322
|
+
@result = []
|
323
|
+
end
|
324
|
+
|
325
|
+
def tagstart(name, attributes)
|
326
|
+
# puts 'tagstart ' + name + ' -- ' + @xmlpath
|
327
|
+
if (name == 'member' && @xmlpath == 'DescribeInstanceHealthResponse/DescribeInstanceHealthResult/InstanceStates')
|
328
|
+
@member = { }
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def tagend(name)
|
333
|
+
case name
|
334
|
+
when 'Description' then
|
335
|
+
@member[:description] = @text
|
336
|
+
when 'State' then
|
337
|
+
@member[:state] = @text
|
338
|
+
when 'InstanceId' then
|
339
|
+
@member[:instance_id] = @text
|
340
|
+
when 'ReasonCode' then
|
341
|
+
@member[:reason_code] = @text
|
342
|
+
when 'member' then
|
343
|
+
@result << @member
|
344
|
+
end
|
345
|
+
end
|
346
|
+
#
|
347
|
+
end
|
348
|
+
|
349
|
+
class QElbDeleteParser < AwsParser
|
350
|
+
def reset
|
351
|
+
@result = true
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
|
356
|
+
end
|
357
|
+
|
358
|
+
|
359
|
+
end
|