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-10-11 18:17:57 -07:00
|
|
|
@block_device_mapping = {}
|
2010-10-12 11:00:59 -07:00
|
|
|
@image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'tagSet' => {} }
|
2009-08-01 01:15:44 -07:00
|
|
|
@response = { 'imagesSet' => [] }
|
2010-10-12 11:00:59 -07:00
|
|
|
@tag = {}
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
2010-05-05 13:39:41 -07:00
|
|
|
super
|
2010-10-11 18:17:57 -07:00
|
|
|
case name
|
|
|
|
when 'blockDeviceMapping'
|
2010-07-26 04:13:35 +08:00
|
|
|
@in_block_device_mapping = true
|
2010-10-12 11:00:59 -07:00
|
|
|
when 'tagSet'
|
|
|
|
@in_tag_set = true
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
end
|
2010-10-11 18:17:57 -07:00
|
|
|
|
2009-07-11 13:41:21 -07: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'
|
|
|
|
@tag[name] = @value
|
|
|
|
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'
|
|
|
|
@block_device_mapping[name] = @value
|
|
|
|
when 'volumeSize'
|
|
|
|
@block_device_mapping[name] = @value.to_i
|
|
|
|
when 'item'
|
|
|
|
@image['blockDeviceMapping'] << @block_device_mapping
|
|
|
|
@block_device_mapping = {}
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
2010-12-21 13:55:33 -05:00
|
|
|
else
|
|
|
|
case name
|
2010-12-21 13:16:42 -08:00
|
|
|
when 'architecture', 'description', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'name', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName','virtualizationType'
|
2010-12-21 13:55:33 -05:00
|
|
|
@image[name] = @value
|
|
|
|
when 'isPublic'
|
|
|
|
if @value == 'true'
|
|
|
|
@image[name] = true
|
|
|
|
else
|
|
|
|
@image[name] = false
|
|
|
|
end
|
|
|
|
when 'item'
|
2009-08-01 01:15:44 -07:00
|
|
|
@response['imagesSet'] << @image
|
2010-10-12 11:00:59 -07:00
|
|
|
@image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'tagSet' => {} }
|
2010-12-21 13:55:33 -05:00
|
|
|
when 'productCode'
|
|
|
|
@image['productCodes'] << @value
|
2010-12-21 13:16:42 -08:00
|
|
|
when 'requestId'
|
|
|
|
@response[name] = @value
|
2009-07-11 13:41:21 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|