1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Fix load balancers parser to handle more than one availability zone with addresses

This commit is contained in:
KevinLoiseau 2019-10-29 13:49:56 +01:00
parent 401e86ef22
commit 9022987bfb
No known key found for this signature in database
GPG key ID: 709159A779B96CC3
3 changed files with 16 additions and 3 deletions

View file

@ -5,7 +5,7 @@ module Fog
class DescribeLoadBalancers < Fog::Parsers::Base class DescribeLoadBalancers < Fog::Parsers::Base
def reset def reset
reset_load_balancer reset_load_balancer
@availability_zone = { 'LoadBalancerAddresses' => [] } reset_availability_zone
@load_balancer_addresses = {} @load_balancer_addresses = {}
@state = {} @state = {}
@results = { 'LoadBalancers' => [] } @results = { 'LoadBalancers' => [] }
@ -16,6 +16,10 @@ module Fog
@load_balancer = { 'SecurityGroups' => [], 'AvailabilityZones' => [] } @load_balancer = { 'SecurityGroups' => [], 'AvailabilityZones' => [] }
end end
def reset_availability_zone
@availability_zone = { 'LoadBalancerAddresses' => [] }
end
def start_element(name, attrs = []) def start_element(name, attrs = [])
super super
case name case name
@ -37,7 +41,7 @@ module Fog
@availability_zone['LoadBalancerAddresses'] << @load_balancer_addresses @availability_zone['LoadBalancerAddresses'] << @load_balancer_addresses
elsif @in_availability_zones elsif @in_availability_zones
@load_balancer['AvailabilityZones'] << @availability_zone @load_balancer['AvailabilityZones'] << @availability_zone
@availability_zone = {} reset_availability_zone
elsif @in_security_groups elsif @in_security_groups
@load_balancer['SecurityGroups'] << value @load_balancer['SecurityGroups'] << value
else else

View file

@ -20,6 +20,12 @@ DESCRIBE_LOAD_BALANCERS_RESULT = <<-EOF
<member> <member>
<SubnetId>subnet-b7d581c0</SubnetId> <SubnetId>subnet-b7d581c0</SubnetId>
<ZoneName>us-west-2b</ZoneName> <ZoneName>us-west-2b</ZoneName>
<LoadBalancerAddresses>
<member>
<IpAddress>127.0.0.1</IpAddress>
<AllocationId>eipalloc-1c2ab192c131q2377</AllocationId>
</member>
</LoadBalancerAddresses>
</member> </member>
</AvailabilityZones> </AvailabilityZones>
<SecurityGroups> <SecurityGroups>

View file

@ -6,7 +6,10 @@ class AWS
} }
LOAD_BALANCER = { LOAD_BALANCER = {
"AvailabilityZones" => Array, "AvailabilityZones" => [{
"SubnetId" => String, "ZoneName" => String,
"LoadBalancerAddresses" => [Fog::Nullable::Hash]
}],
"LoadBalancerArn" => String, "LoadBalancerArn" => String,
"DNSName" => String, "DNSName" => String,
"CreatedTime" => Time, "CreatedTime" => Time,