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_images.rb

63 lines
1.9 KiB
Ruby
Raw Normal View History

module Fog
module Parsers
module AWS
2010-09-08 17:40:02 -04:00
module Compute
class DescribeImages < Fog::Parsers::Base
def reset
@block_device_mapping = {}
@image = { 'blockDeviceMapping' => [], 'productCodes' => [] }
2009-08-01 04:15:44 -04:00
@response = { 'imagesSet' => [] }
end
def start_element(name, attrs = [])
super
case name
when 'productCodes'
@in_product_codes = true
when 'blockDeviceMapping'
@in_block_device_mapping = true
end
end
def end_element(name)
case name
when 'architecture', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName'
2009-08-01 04:15:44 -04:00
@image[name] = @value
when 'deviceName', 'virtualName', 'snapshotId', 'volumeSize', 'deleteOnTermination'
@block_device_mapping[name] = @value
when 'isPublic'
if @value == 'true'
2009-08-01 04:15:44 -04:00
@image[name] = true
else
2009-08-01 04:15:44 -04:00
@image[name] = false
end
when 'item'
if @in_block_device_mapping
@image['blockDeviceMapping'] << @block_device_mapping
@block_device_mapping = {}
elsif !@in_product_codes
2009-08-01 04:15:44 -04:00
@response['imagesSet'] << @image
@image = { 'blockDeviceMapping' => [], 'productCodes' => [] }
end
when 'productCode'
2009-08-01 04:15:44 -04:00
@image['productCodes'] << @value
when 'productCodes'
@in_product_codes = false
when 'blockDeviceMapping'
@in_block_device_mapping = false
when 'requestId'
2009-08-01 04:15:44 -04:00
@response[name] = @value
when 'volumeSize'
@block_device_mapping[name] = @value.to_i
end
end
end
end
end
end
end