2009-07-11 13:41:21 -07:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module AWS
|
2010-09-08 14:40:02 -07:00
|
|
|
module Compute
|
2009-07-11 13:41:21 -07:00
|
|
|
|
|
|
|
class DescribeImages < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
2010-07-26 04:13:35 +08:00
|
|
|
@image = { 'productCodes' => [], 'blockDeviceMapping' => nil }
|
2009-08-01 01:15:44 -07:00
|
|
|
@response = { 'imagesSet' => [] }
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
2010-05-05 13:39:41 -07:00
|
|
|
super
|
2009-07-11 13:41:21 -07:00
|
|
|
if name == 'productCodes'
|
|
|
|
@in_product_codes = true
|
2010-07-26 04:13:35 +08:00
|
|
|
elsif name == 'blockDeviceMapping'
|
|
|
|
@in_block_device_mapping = true
|
|
|
|
@image['blockDeviceMapping'] = []
|
|
|
|
elsif name == 'item' && @in_block_device_mapping
|
|
|
|
@image['blockDeviceMapping'] << {}
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
end
|
2009-07-13 20:00:27 -07:00
|
|
|
|
2009-07-11 13:41:21 -07:00
|
|
|
def end_element(name)
|
|
|
|
case name
|
2010-07-26 00:24:08 +08:00
|
|
|
when 'architecture', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName'
|
2009-08-01 01:15:44 -07:00
|
|
|
@image[name] = @value
|
2009-07-11 13:41:21 -07:00
|
|
|
when 'isPublic'
|
|
|
|
if @value == 'true'
|
2009-08-01 01:15:44 -07:00
|
|
|
@image[name] = true
|
2009-07-11 13:41:21 -07:00
|
|
|
else
|
2009-08-01 01:15:44 -07:00
|
|
|
@image[name] = false
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
when 'item'
|
2010-07-26 04:13:35 +08:00
|
|
|
if @in_block_device_mapping
|
|
|
|
elsif !@in_product_codes
|
2009-08-01 01:15:44 -07:00
|
|
|
@response['imagesSet'] << @image
|
|
|
|
@image = { 'productCodes' => [] }
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
when 'productCode'
|
2009-08-01 01:15:44 -07:00
|
|
|
@image['productCodes'] << @value
|
2009-07-11 13:41:21 -07:00
|
|
|
when 'productCodes'
|
|
|
|
@in_product_codes = false
|
2010-07-26 04:13:35 +08:00
|
|
|
when 'blockDeviceMapping'
|
|
|
|
@in_block_device_mapping = false
|
2009-07-11 13:41:21 -07:00
|
|
|
when 'requestId'
|
2009-08-01 01:15:44 -07:00
|
|
|
@response[name] = @value
|
2010-07-26 04:13:35 +08:00
|
|
|
when 'deviceName','virtualName','snapshotId','volumeSize','deleteOnTermination'
|
|
|
|
l = @image['blockDeviceMapping'].length
|
|
|
|
@image['blockDeviceMapping'][l-1].store(name,@value)
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|