2009-07-11 16:41:21 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module AWS
|
|
|
|
module EC2
|
|
|
|
|
|
|
|
class DescribeImages < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
2009-08-01 04:15:44 -04:00
|
|
|
@image = { 'productCodes' => [] }
|
|
|
|
@response = { 'imagesSet' => [] }
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
|
|
|
if name == 'productCodes'
|
|
|
|
@in_product_codes = true
|
|
|
|
end
|
|
|
|
@value = ''
|
|
|
|
end
|
2009-07-13 23:00:27 -04:00
|
|
|
|
2009-07-11 16:41:21 -04:00
|
|
|
def end_element(name)
|
|
|
|
case name
|
2009-08-01 04:15:44 -04:00
|
|
|
when 'architecture', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId'
|
|
|
|
@image[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'
|
|
|
|
unless @in_product_codes
|
2009-08-01 04:15:44 -04:00
|
|
|
@response['imagesSet'] << @image
|
|
|
|
@image = { '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
|
|
|
|
when 'requestId'
|
2009-08-01 04:15:44 -04:00
|
|
|
@response[name] = @value
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|