1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[ec2] Add blockDeviceMapping information to images

This commit is contained in:
Caleb Tennis 2010-07-26 04:13:35 +08:00 committed by Wesley Beary
parent 9696e21c71
commit 55e1d281e8
4 changed files with 27 additions and 13 deletions

View file

@ -68,6 +68,7 @@ module Fog
end end
{ {
"imageOwnerId" => letters(rand(5) + 4), "imageOwnerId" => letters(rand(5) + 4),
"blockDeviceMapping" => [],
"productCodes" => [], "productCodes" => [],
"kernelId" => kernel_id, "kernelId" => kernel_id,
"ramdiskId" => ramdisk_id, "ramdiskId" => ramdisk_id,

View file

@ -9,6 +9,7 @@ module Fog
identity :id, 'imageId' identity :id, 'imageId'
attribute :architecture attribute :architecture
attribute :block_device_mapping, 'blockDeviceMapping'
attribute :location, 'imageLocation' attribute :location, 'imageLocation'
attribute :owner_id, 'imageOwnerId' attribute :owner_id, 'imageOwnerId'
attribute :state, 'imageState' attribute :state, 'imageState'

View file

@ -6,7 +6,7 @@ module Fog
class DescribeImages < Fog::Parsers::Base class DescribeImages < Fog::Parsers::Base
def reset def reset
@image = { 'productCodes' => [] } @image = { 'productCodes' => [], 'blockDeviceMapping' => nil }
@response = { 'imagesSet' => [] } @response = { 'imagesSet' => [] }
end end
@ -14,6 +14,11 @@ module Fog
super super
if name == 'productCodes' if name == 'productCodes'
@in_product_codes = true @in_product_codes = true
elsif name == 'blockDeviceMapping'
@in_block_device_mapping = true
@image['blockDeviceMapping'] = []
elsif name == 'item' && @in_block_device_mapping
@image['blockDeviceMapping'] << {}
end end
end end
@ -28,7 +33,8 @@ module Fog
@image[name] = false @image[name] = false
end end
when 'item' when 'item'
unless @in_product_codes if @in_block_device_mapping
elsif !@in_product_codes
@response['imagesSet'] << @image @response['imagesSet'] << @image
@image = { 'productCodes' => [] } @image = { 'productCodes' => [] }
end end
@ -36,8 +42,13 @@ module Fog
@image['productCodes'] << @value @image['productCodes'] << @value
when 'productCodes' when 'productCodes'
@in_product_codes = false @in_product_codes = false
when 'blockDeviceMapping'
@in_block_device_mapping = false
when 'requestId' when 'requestId'
@response[name] = @value @response[name] = @value
when 'deviceName','virtualName','snapshotId','volumeSize','deleteOnTermination'
l = @image['blockDeviceMapping'].length
@image['blockDeviceMapping'][l-1].store(name,@value)
end end
end end

View file

@ -20,6 +20,7 @@ module Fog
# * 'requestId'<~String> - Id of request # * 'requestId'<~String> - Id of request
# * 'imagesSet'<~Array>: # * 'imagesSet'<~Array>:
# * 'architecture'<~String> - Architecture of the image # * 'architecture'<~String> - Architecture of the image
# * 'blockDeviceMapping'<~Array> - An array of mapped block devices
# * 'imageId'<~String> - Id of the image # * 'imageId'<~String> - Id of the image
# * 'imageLocation'<~String> - Location of the image # * 'imageLocation'<~String> - Location of the image
# * 'imageOwnerId'<~String> - Id of the owner of the image # * 'imageOwnerId'<~String> - Id of the owner of the image