2010-05-02 03:13:35 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module AWS
|
|
|
|
module ELB
|
|
|
|
|
|
|
|
class DescribeLoadBalancers < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
2011-04-09 09:08:08 -04:00
|
|
|
reset_load_balancer
|
|
|
|
reset_listener_description
|
|
|
|
reset_policy
|
2010-05-02 03:13:35 -04:00
|
|
|
@results = { 'LoadBalancerDescriptions' => [] }
|
|
|
|
@response = { 'DescribeLoadBalancersResult' => {}, 'ResponseMetadata' => {} }
|
|
|
|
end
|
|
|
|
|
2011-04-09 09:08:08 -04:00
|
|
|
def reset_load_balancer
|
|
|
|
@load_balancer = { 'ListenerDescriptions' => [], 'Instances' => [], 'AvailabilityZones' => [], 'Policies' => {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [] }, 'HealthCheck' => {} }
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_listener_description
|
|
|
|
@listener_description = { 'PolicyNames' => [], 'Listener' => {} }
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_policy
|
|
|
|
@policy = {}
|
|
|
|
end
|
|
|
|
|
2010-05-02 03:13:35 -04:00
|
|
|
def start_element(name, attrs = [])
|
2010-05-05 16:39:41 -04:00
|
|
|
super
|
2010-05-02 03:13:35 -04:00
|
|
|
case name
|
|
|
|
when 'ListenerDescriptions'
|
|
|
|
@in_listeners = true
|
|
|
|
when 'Instances'
|
|
|
|
@in_instances = true
|
|
|
|
when 'AvailabilityZones'
|
|
|
|
@in_availability_zones = true
|
|
|
|
when 'PolicyNames'
|
|
|
|
@in_policy_names = true
|
|
|
|
when 'Policies'
|
|
|
|
@in_policies = true
|
|
|
|
when 'LBCookieStickinessPolicies'
|
|
|
|
@in_lb_cookies = true
|
|
|
|
when 'AppCookieStickinessPolicies'
|
|
|
|
@in_app_cookies = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
|
|
|
when 'member'
|
|
|
|
if @in_policy_names
|
|
|
|
@listener_description['PolicyNames'] << @value
|
|
|
|
elsif @in_availability_zones
|
|
|
|
@load_balancer['AvailabilityZones'] << @value
|
|
|
|
elsif @in_listeners
|
2010-05-02 04:02:53 -04:00
|
|
|
@load_balancer['ListenerDescriptions'] << @listener_description
|
2011-04-09 09:08:08 -04:00
|
|
|
reset_listener_description
|
2010-05-02 03:13:35 -04:00
|
|
|
elsif @in_app_cookies
|
2011-04-09 09:08:08 -04:00
|
|
|
@load_balancer['Policies']['AppCookieStickinessPolicies'] << @policy
|
|
|
|
reset_policy
|
2010-05-02 03:13:35 -04:00
|
|
|
elsif @in_lb_cookies
|
2011-04-09 09:08:08 -04:00
|
|
|
@load_balancer['Policies']['LBCookieStickinessPolicies'] << @policy
|
|
|
|
reset_policy
|
2010-05-02 03:13:35 -04:00
|
|
|
elsif !@in_instances && !@in_policies
|
|
|
|
@results['LoadBalancerDescriptions'] << @load_balancer
|
2011-04-09 09:08:08 -04:00
|
|
|
reset_load_balancer
|
2010-05-02 03:13:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
when 'LoadBalancerName', 'DNSName'
|
|
|
|
@load_balancer[name] = @value
|
|
|
|
when 'CreatedTime'
|
|
|
|
@load_balancer[name] = Time.parse(@value)
|
|
|
|
|
|
|
|
when 'ListenerDescriptions'
|
|
|
|
@in_listeners = false
|
|
|
|
when 'PolicyNames'
|
|
|
|
@in_policy_names = false
|
|
|
|
when 'Protocol'
|
2010-05-02 04:02:53 -04:00
|
|
|
@listener_description['Listener'][name] = @value
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'LoadBalancerPort', 'InstancePort'
|
2010-05-02 04:02:53 -04:00
|
|
|
@listener_description['Listener'][name] = @value.to_i
|
2010-05-02 03:13:35 -04:00
|
|
|
|
|
|
|
when 'Instances'
|
|
|
|
@in_instances = false
|
|
|
|
when 'InstanceId'
|
|
|
|
@load_balancer['Instances'] << @value
|
|
|
|
|
|
|
|
when 'AvailabilityZones'
|
|
|
|
@in_availability_zones = false
|
|
|
|
|
|
|
|
when 'Policies'
|
|
|
|
@in_policies = false
|
|
|
|
when 'AppCookieStickinessPolicies'
|
|
|
|
@in_app_cookies = false
|
|
|
|
when 'LBCookieStickinessPolicies'
|
|
|
|
@in_lb_cookies = false
|
|
|
|
|
|
|
|
when 'Interval', 'HealthyThreshold', 'Timeout', 'UnhealthyThreshold'
|
|
|
|
@load_balancer['HealthCheck'][name] = @value.to_i
|
|
|
|
when 'Target'
|
|
|
|
@load_balancer['HealthCheck'][name] = @value
|
|
|
|
|
2011-04-09 09:08:08 -04:00
|
|
|
when 'PolicyName', 'CookieName'
|
|
|
|
@policy[name] = @value
|
|
|
|
when 'CookieExpirationPeriod'
|
|
|
|
@policy[name] = @value.to_i
|
|
|
|
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'RequestId'
|
|
|
|
@response['ResponseMetadata'][name] = @value
|
|
|
|
|
|
|
|
when 'DescribeLoadBalancersResponse'
|
|
|
|
@response['DescribeLoadBalancersResult'] = @results
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|