2009-07-11 16:41:21 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
module AWS
|
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 = {}
|
2010-10-12 14:00:59 -04:00
|
|
|
@image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'tagSet' => {} }
|
2009-08-01 04:15:44 -04:00
|
|
|
@response = { 'imagesSet' => [] }
|
2010-10-12 14:00:59 -04:00
|
|
|
@tag = {}
|
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 'blockDeviceMapping'
|
2010-07-25 16:13:35 -04:00
|
|
|
@in_block_device_mapping = true
|
2010-10-12 14:00:59 -04:00
|
|
|
when 'tagSet'
|
|
|
|
@in_tag_set = 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)
|
2010-12-21 13:55:33 -05:00
|
|
|
if @in_tag_set
|
|
|
|
case name
|
|
|
|
when 'item'
|
|
|
|
@image['tagSet'][@tag['key']] = @tag['value']
|
|
|
|
@tag = {}
|
|
|
|
when 'key', 'value'
|
2011-05-12 16:15:13 -04:00
|
|
|
@tag[name] = value
|
2010-12-21 13:55:33 -05:00
|
|
|
when 'tagSet'
|
|
|
|
@in_tag_set = false
|
|
|
|
end
|
|
|
|
elsif @in_block_device_mapping
|
|
|
|
case name
|
|
|
|
when 'blockDeviceMapping'
|
|
|
|
@in_block_device_mapping = false
|
|
|
|
when 'deviceName', 'virtualName', 'snapshotId', 'deleteOnTermination'
|
2011-05-12 16:15:13 -04:00
|
|
|
@block_device_mapping[name] = value
|
2010-12-21 13:55:33 -05:00
|
|
|
when 'volumeSize'
|
2011-05-12 16:15:13 -04:00
|
|
|
@block_device_mapping[name] = value.to_i
|
2010-12-21 13:55:33 -05:00
|
|
|
when 'item'
|
|
|
|
@image['blockDeviceMapping'] << @block_device_mapping
|
|
|
|
@block_device_mapping = {}
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
2010-12-21 13:55:33 -05:00
|
|
|
else
|
|
|
|
case name
|
2010-12-21 16:16:42 -05:00
|
|
|
when 'architecture', 'description', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'name', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName','virtualizationType'
|
2011-05-12 16:15:13 -04:00
|
|
|
@image[name] = value
|
2010-12-21 13:55:33 -05:00
|
|
|
when 'isPublic'
|
2011-05-12 16:15:13 -04:00
|
|
|
if value == 'true'
|
2010-12-21 13:55:33 -05:00
|
|
|
@image[name] = true
|
|
|
|
else
|
|
|
|
@image[name] = false
|
|
|
|
end
|
|
|
|
when 'item'
|
2009-08-01 04:15:44 -04:00
|
|
|
@response['imagesSet'] << @image
|
2010-10-12 14:00:59 -04:00
|
|
|
@image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'tagSet' => {} }
|
2010-12-21 13:55:33 -05:00
|
|
|
when 'productCode'
|
2011-05-12 16:15:13 -04:00
|
|
|
@image['productCodes'] << value
|
2010-12-21 16:16:42 -05:00
|
|
|
when 'requestId'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|