Class: Fog::Parsers::AWS::ELB::DescribeLoadBalancers

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/elb/describe_load_balancers.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#attr_value, #characters, #end_element_namespace, #initialize, #start_element_namespace, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/fog/aws/parsers/elb/describe_load_balancers.rb', line 61

def end_element(name)
  case name
  when 'member'
    if @in_policy_names && @in_listeners
      @listener_description['PolicyNames'] << value
    elsif @in_availability_zones
      @load_balancer['AvailabilityZones'] << value
    elsif @in_security_groups
      @load_balancer['SecurityGroups'] << value
    elsif @in_subnets
      @load_balancer['Subnets'] << value
    elsif @in_listeners
      @load_balancer['ListenerDescriptions'] << @listener_description
      reset_listener_description
    elsif @in_app_cookies
      @load_balancer['Policies']['AppCookieStickinessPolicies'] << @stickiness_policy
      reset_stickiness_policy
    elsif @in_lb_cookies
      @load_balancer['Policies']['LBCookieStickinessPolicies'] << @stickiness_policy
      reset_stickiness_policy
    elsif @in_other_policies
      @load_balancer['Policies']['OtherPolicies'] << value
    elsif @in_backend_server_descriptions && @in_policy_names
      @backend_server_description['PolicyNames'] ||= []
      @backend_server_description['PolicyNames'] << value
    elsif @in_backend_server_descriptions && !@in_policy_names
      @load_balancer['BackendServerDescriptions'] << @backend_server_description
      reset_backend_server_description
    elsif !@in_instances && !@in_policies && !@in_backend_server_descriptions
      @results['LoadBalancerDescriptions'] << @load_balancer
      reset_load_balancer
    end

  when 'BackendServerDescriptions'
    @in_backend_server_descriptions = false

  when 'InstancePort'
    if @in_backend_server_descriptions
      @backend_server_description[name] = value.to_i
    elsif @in_listeners
      @listener_description['Listener'][name] = value.to_i
    end

  when 'CanonicalHostedZoneName', 'CanonicalHostedZoneNameID', 'LoadBalancerName', 'DNSName', 'Scheme'
    @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', 'SSLCertificateId', 'InstanceProtocol'
    @listener_description['Listener'][name] = value
  when 'LoadBalancerPort'
    @listener_description['Listener'][name] = value.to_i

  when 'Instances'
    @in_instances = false
  when 'InstanceId'
    @load_balancer['Instances'] << value
  when 'VPCId'
    @load_balancer[name] = value

  when 'AvailabilityZones'
    @in_availability_zones = false
  when 'SecurityGroups'
    @in_security_groups = false
  when 'Subnets'
    @in_subnets = false

  when 'Policies'
    @in_policies = false
  when 'AppCookieStickinessPolicies'
    @in_app_cookies = false
  when 'LBCookieStickinessPolicies'
    @in_lb_cookies = false
  when 'OtherPolicies'
    @in_other_policies = false

  when 'OwnerAlias', 'GroupName'
    @load_balancer['SourceSecurityGroup'][name] = value

  when 'Interval', 'HealthyThreshold', 'Timeout', 'UnhealthyThreshold'
    @load_balancer['HealthCheck'][name] = value.to_i
  when 'Target'
    @load_balancer['HealthCheck'][name] = value

  when 'PolicyName', 'CookieName'
    @stickiness_policy[name] = value
  when 'CookieExpirationPeriod'
    @stickiness_policy[name] = value.to_i

  when 'RequestId'
    @response['ResponseMetadata'][name] = value

  when 'NextMarker'
    @results['NextMarker'] = value
  when 'DescribeLoadBalancersResponse'
    @response['DescribeLoadBalancersResult'] = @results
  end
end

#resetObject



6
7
8
9
10
11
12
13
# File 'lib/fog/aws/parsers/elb/describe_load_balancers.rb', line 6

def reset
  reset_load_balancer
  reset_listener_description
  reset_stickiness_policy
  reset_backend_server_description
  @results = { 'LoadBalancerDescriptions' => [] }
  @response = { 'DescribeLoadBalancersResult' => {}, 'ResponseMetadata' => {} }
end

#reset_backend_server_descriptionObject



23
24
25
# File 'lib/fog/aws/parsers/elb/describe_load_balancers.rb', line 23

def reset_backend_server_description
  @backend_server_description = {}
end

#reset_listener_descriptionObject



19
20
21
# File 'lib/fog/aws/parsers/elb/describe_load_balancers.rb', line 19

def reset_listener_description
  @listener_description = { 'PolicyNames' => [], 'Listener' => {} }
end

#reset_load_balancerObject



15
16
17
# File 'lib/fog/aws/parsers/elb/describe_load_balancers.rb', line 15

def reset_load_balancer
  @load_balancer = { 'Subnets' => [], 'SecurityGroups' => [], 'ListenerDescriptions' => [], 'Instances' => [], 'AvailabilityZones' => [], 'Policies' => {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [], 'OtherPolicies' => []}, 'HealthCheck' => {}, 'SourceSecurityGroup' => {}, 'BackendServerDescriptions' => [] }
end

#reset_stickiness_policyObject



27
28
29
# File 'lib/fog/aws/parsers/elb/describe_load_balancers.rb', line 27

def reset_stickiness_policy
  @stickiness_policy = {}
end

#start_element(name, attrs = []) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/aws/parsers/elb/describe_load_balancers.rb', line 31

def start_element(name, attrs = [])
  super
  case name
  when 'ListenerDescriptions'
    @in_listeners = true
  when 'Instances'
    @in_instances = true
  when 'AvailabilityZones'
    @in_availability_zones = true
  when 'SecurityGroups'
    @in_security_groups = true
  when 'Subnets'
    @in_subnets = true
  when 'PolicyNames'
    @in_policy_names = true
  when 'Policies'
    @in_policies = true
  when 'LBCookieStickinessPolicies'
    @in_lb_cookies = true
  when 'AppCookieStickinessPolicies'
    @in_app_cookies = true
  when 'AppCookieStickinessPolicies'
    @in_app_cookies = true
  when 'OtherPolicies'
    @in_other_policies = true
  when 'BackendServerDescriptions'
    @in_backend_server_descriptions = true
  end
end