1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/parsers/compute/describe_availability_zones.rb
Aaron Suggs f7aa05bd01 [aws|ec2] describe_availability_zones parser handles nested <item> tags
This patch fixes the parser so there is no empty {'messageSet' => []}
value.

At the moment, AWS is returning a body like that is incorrectly parsed:

     <availabilityZoneInfo>
        ...
        <item>
            <zoneName>us-east-1b</zoneName>
            <zoneState>impaired</zoneState>
            <regionName>us-east-1</regionName>
            <messageSet>
                <item>
                    <message>We have restored the ability to launch new
EC2 instances in this Availability Zone. At this point, customers
should be able to launch instances in any Availability Zone in the
US-EAST-1 region. We are continuing to restore impaired volumes and
their attached instances.</message>
                </item>
            </messageSet>
2012-10-22 21:50:12 -04:00

43 lines
1.1 KiB
Ruby

module Fog
module Parsers
module Compute
module AWS
class DescribeAvailabilityZones < Fog::Parsers::Base
def start_element(name, attrs = [])
case name
when 'messageSet'
@in_message_set = true
end
super
end
def reset
@availability_zone = { 'messageSet' => [] }
@response = { 'availabilityZoneInfo' => [] }
end
def end_element(name)
case name
when 'item'
unless @in_message_set
@response['availabilityZoneInfo'] << @availability_zone
@availability_zone = { 'messageSet' => [] }
end
when 'message'
@availability_zone['messageSet'] << value
when 'regionName', 'zoneName', 'zoneState'
@availability_zone[name] = value
when 'requestId'
@response[name] = value
when 'messageSet'
@in_message_set = false
end
end
end
end
end
end
end