diff --git a/lib/fog/aws/parsers/compute/describe_images.rb b/lib/fog/aws/parsers/compute/describe_images.rb index 4597e015e..89de28ac4 100644 --- a/lib/fog/aws/parsers/compute/describe_images.rb +++ b/lib/fog/aws/parsers/compute/describe_images.rb @@ -15,8 +15,6 @@ module Fog def start_element(name, attrs = []) super case name - when 'productCodes' - @in_product_codes = true when 'blockDeviceMapping' @in_block_device_mapping = true when 'tagSet' @@ -25,45 +23,47 @@ module Fog end def end_element(name) - case name - when 'architecture', 'description', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName' - @image[name] = @value - when 'blockDeviceMapping' - @in_block_device_mapping = false - when 'deviceName', 'virtualName', 'snapshotId', 'deleteOnTermination' - @block_device_mapping[name] = @value - when 'isPublic' - if @value == 'true' - @image[name] = true - else - @image[name] = false + if @in_tag_set + case name + when 'item' + @image['tagSet'][@tag['key']] = @tag['value'] + @tag = {} + when 'key', 'value' + @tag[name] = @value + when 'tagSet' + @in_tag_set = false end - when 'item' - if @in_block_device_mapping - @image['blockDeviceMapping'] << @block_device_mapping - @block_device_mapping = {} - elsif @in_tag_set - @image['tagSet'][@tag['key']] = @tag['value'] - @tag = {} - elsif !@in_product_codes + elsif @in_block_device_mapping + case name + when 'blockDeviceMapping' + @in_block_device_mapping = false + when 'deviceName', 'virtualName', 'snapshotId', 'deleteOnTermination' + @block_device_mapping[name] = @value + when 'volumeSize' + @block_device_mapping[name] = @value.to_i + when 'item' + @image['blockDeviceMapping'] << @block_device_mapping + @block_device_mapping = {} + end + else + case name + when 'name','requestId','architecture', 'description', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName','virtualizationType' + @image[name] = @value + when 'isPublic' + if @value == 'true' + @image[name] = true + else + @image[name] = false + end + when 'item' @response['imagesSet'] << @image @image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'tagSet' => {} } + when 'productCode' + @image['productCodes'] << @value end - when 'key', 'value' - @tag[name] = @value - when 'productCode' - @image['productCodes'] << @value - when 'productCodes' - @in_product_codes = false - when 'requestId' - @response[name] = @value - when 'volumeSize' - @block_device_mapping[name] = @value.to_i end end - end - end end end