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
|
2012-05-21 14:37:00 -04:00
|
|
|
@load_balancer = { 'Subnets' => [], 'SecurityGroups' => [], 'ListenerDescriptions' => [], 'Instances' => [], 'AvailabilityZones' => [], 'Policies' => {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [] }, 'HealthCheck' => {}, 'SourceSecurityGroup' => {} }
|
2011-04-09 09:08:08 -04:00
|
|
|
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
|
2012-05-21 14:37:00 -04:00
|
|
|
when 'SecurityGroups'
|
|
|
|
@in_security_groups = true
|
|
|
|
when 'Subnets'
|
|
|
|
@in_subnets = true
|
2010-05-02 03:13:35 -04:00
|
|
|
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
|
2011-05-12 16:15:13 -04:00
|
|
|
@listener_description['PolicyNames'] << value
|
2010-05-02 03:13:35 -04:00
|
|
|
elsif @in_availability_zones
|
2011-05-12 16:15:13 -04:00
|
|
|
@load_balancer['AvailabilityZones'] << value
|
2012-05-21 14:37:00 -04:00
|
|
|
elsif @in_security_groups
|
|
|
|
@load_balancer['SecurityGroups'] << value
|
|
|
|
elsif @in_subnets
|
|
|
|
@load_balancer['Subnets'] << value
|
2010-05-02 03:13:35 -04:00
|
|
|
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
|
|
|
|
|
2012-06-13 12:17:56 -04:00
|
|
|
when 'CanonicalHostedZoneName', 'CanonicalHostedZoneNameID', 'LoadBalancerName', 'DNSName', 'Scheme'
|
2011-05-12 16:15:13 -04:00
|
|
|
@load_balancer[name] = value
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'CreatedTime'
|
2011-05-12 16:15:13 -04:00
|
|
|
@load_balancer[name] = Time.parse(value)
|
2010-05-02 03:13:35 -04:00
|
|
|
|
|
|
|
when 'ListenerDescriptions'
|
|
|
|
@in_listeners = false
|
|
|
|
when 'PolicyNames'
|
|
|
|
@in_policy_names = false
|
2012-07-06 11:24:12 -04:00
|
|
|
when 'Protocol', 'SSLCertificateId', 'InstanceProtocol'
|
2011-05-12 16:15:13 -04:00
|
|
|
@listener_description['Listener'][name] = value
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'LoadBalancerPort', 'InstancePort'
|
2011-05-12 16:15:13 -04:00
|
|
|
@listener_description['Listener'][name] = value.to_i
|
2010-05-02 03:13:35 -04:00
|
|
|
|
|
|
|
when 'Instances'
|
|
|
|
@in_instances = false
|
|
|
|
when 'InstanceId'
|
2011-05-12 16:15:13 -04:00
|
|
|
@load_balancer['Instances'] << value
|
2012-05-21 14:37:00 -04:00
|
|
|
when 'VPCId'
|
|
|
|
@load_balancer[name] = value
|
2010-05-02 03:13:35 -04:00
|
|
|
|
|
|
|
when 'AvailabilityZones'
|
|
|
|
@in_availability_zones = false
|
2012-05-21 14:37:00 -04:00
|
|
|
when 'SecurityGroups'
|
|
|
|
@in_security_groups = false
|
|
|
|
when 'Subnets'
|
|
|
|
@in_subnets = false
|
2010-05-02 03:13:35 -04:00
|
|
|
|
|
|
|
when 'Policies'
|
|
|
|
@in_policies = false
|
|
|
|
when 'AppCookieStickinessPolicies'
|
|
|
|
@in_app_cookies = false
|
|
|
|
when 'LBCookieStickinessPolicies'
|
|
|
|
@in_lb_cookies = false
|
|
|
|
|
2011-05-30 18:57:07 -04:00
|
|
|
when 'OwnerAlias', 'GroupName'
|
|
|
|
@load_balancer['SourceSecurityGroup'][name] = value
|
|
|
|
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'Interval', 'HealthyThreshold', 'Timeout', 'UnhealthyThreshold'
|
2011-05-12 16:15:13 -04:00
|
|
|
@load_balancer['HealthCheck'][name] = value.to_i
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'Target'
|
2011-05-12 16:15:13 -04:00
|
|
|
@load_balancer['HealthCheck'][name] = value
|
2010-05-02 03:13:35 -04:00
|
|
|
|
2011-04-09 09:08:08 -04:00
|
|
|
when 'PolicyName', 'CookieName'
|
2011-05-12 16:15:13 -04:00
|
|
|
@policy[name] = value
|
2011-04-09 09:08:08 -04:00
|
|
|
when 'CookieExpirationPeriod'
|
2011-05-12 16:15:13 -04:00
|
|
|
@policy[name] = value.to_i
|
2011-04-09 09:08:08 -04:00
|
|
|
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'RequestId'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['ResponseMetadata'][name] = value
|
2010-05-02 03:13:35 -04:00
|
|
|
|
2012-04-22 21:46:17 -04:00
|
|
|
when 'NextMarker'
|
|
|
|
@results['NextMarker'] = value
|
2010-05-02 03:13:35 -04:00
|
|
|
when 'DescribeLoadBalancersResponse'
|
|
|
|
@response['DescribeLoadBalancersResult'] = @results
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|