Skip to content

Commit

Permalink
[aws|ec2] describe_availability_zones parser handles nested <item> tags
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ktheory committed Oct 23, 2012
1 parent dce5e80 commit f7aa05b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/fog/aws/parsers/compute/describe_availability_zones.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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' => [] }
Expand All @@ -13,14 +20,18 @@ def reset
def end_element(name)
case name
when 'item'
@response['availabilityZoneInfo'] << @availability_zone
@availability_zone = { 'messageSet' => [] }
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

Expand Down

0 comments on commit f7aa05b

Please sign in to comment.