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